Initial commit
This commit is contained in:
commit
b1a1a6866d
23 changed files with 495 additions and 0 deletions
0
nox_actions/__init__.py
Normal file
0
nox_actions/__init__.py
Normal file
17
nox_actions/codetest.py
Normal file
17
nox_actions/codetest.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# Import built-in modules
|
||||
import os
|
||||
|
||||
# Import third-party modules
|
||||
import nox
|
||||
from nox_actions.utils import PACKAGE_NAME
|
||||
from nox_actions.utils import THIS_ROOT
|
||||
|
||||
|
||||
def pytest(session: nox.Session) -> None:
|
||||
session.install(".")
|
||||
session.install("pytest", "pytest_cov", "pytest_mock")
|
||||
test_root = os.path.join(THIS_ROOT, "tests")
|
||||
session.run("pytest", f"--cov={PACKAGE_NAME}",
|
||||
"--cov-report=xml:coverage.xml",
|
||||
f"--rootdir={test_root}",
|
||||
env={"PYTHONPATH": THIS_ROOT.as_posix()})
|
||||
17
nox_actions/lint.py
Normal file
17
nox_actions/lint.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# Import third-party modules
|
||||
import nox
|
||||
from nox_actions.utils import PACKAGE_NAME
|
||||
|
||||
|
||||
def lint(session: nox.Session) -> None:
|
||||
session.install("isort", "ruff")
|
||||
session.run("isort", "--check-only", PACKAGE_NAME)
|
||||
session.run("ruff", "check")
|
||||
|
||||
|
||||
def lint_fix(session: nox.Session) -> None:
|
||||
session.install("isort", "ruff", "pre-commit", "autoflake")
|
||||
session.run("ruff", "check", "--fix")
|
||||
session.run("isort", ".")
|
||||
session.run("pre-commit", "run", "--all-files")
|
||||
session.run("autoflake", "--in-place", "--remove-all-unused-imports", "--remove-unused-variables")
|
||||
45
nox_actions/release.py
Normal file
45
nox_actions/release.py
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# Import built-in modules
|
||||
import argparse
|
||||
import os
|
||||
import shutil
|
||||
import zipfile
|
||||
|
||||
# Import third-party modules
|
||||
import nox
|
||||
from nox_actions.utils import PACKAGE_NAME
|
||||
from nox_actions.utils import THIS_ROOT
|
||||
|
||||
|
||||
@nox.session(name="build-exe", reuse_venv=True)
|
||||
def build_exe(session: nox.Session) -> None:
|
||||
parser = argparse.ArgumentParser(prog="nox -s build-exe --release")
|
||||
parser.add_argument("--release", action="store_true")
|
||||
parser.add_argument("--version", default="0.5.0", help="Version to use for the zip file")
|
||||
parser.add_argument("--test", action="store_true")
|
||||
args = parser.parse_args(session.posargs)
|
||||
build_root = THIS_ROOT / "build"
|
||||
session.install("pyoxidizer")
|
||||
session.run("pyoxidizer", "build", "install", "--path", THIS_ROOT, "--release")
|
||||
for platform_name in os.listdir(build_root):
|
||||
platform_dir = build_root / platform_name / "release" / "install"
|
||||
print(os.listdir(platform_dir))
|
||||
print(f"build {platform_name} -> {platform_dir}")
|
||||
|
||||
if args.test:
|
||||
print("run tests")
|
||||
vexcle_exe = shutil.which("vexcle", path=platform_dir)
|
||||
assert os.path.exists(vexcle_exe)
|
||||
|
||||
if args.release:
|
||||
temp_dir = os.path.join(THIS_ROOT, ".zip")
|
||||
version = str(args.version)
|
||||
print(f"make zip to current version: {version}")
|
||||
os.makedirs(temp_dir, exist_ok=True)
|
||||
zip_file = os.path.join(temp_dir, f"{PACKAGE_NAME}-{version}-{platform_name}.zip")
|
||||
with zipfile.ZipFile(zip_file, "w") as zip_obj:
|
||||
for root, _, files in os.walk(platform_dir):
|
||||
for file in files:
|
||||
zip_obj.write(os.path.join(root, file),
|
||||
os.path.relpath(os.path.join(root, file),
|
||||
os.path.join(platform_dir, ".")))
|
||||
print("Saving to {zipfile}".format(zipfile=zip_file))
|
||||
19
nox_actions/utils.py
Normal file
19
nox_actions/utils.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# Import built-in modules
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
PACKAGE_NAME = ""
|
||||
THIS_ROOT = Path(__file__).parent.parent
|
||||
PROJECT_ROOT = THIS_ROOT.parent
|
||||
|
||||
|
||||
def _assemble_env_paths(*paths):
|
||||
"""Assemble environment paths separated by a semicolon.
|
||||
|
||||
Args:
|
||||
*paths: Paths to be assembled.
|
||||
|
||||
Returns:
|
||||
str: Assembled paths separated by a semicolon.
|
||||
"""
|
||||
return ";".join(paths)
|
||||
Loading…
Add table
Add a link
Reference in a new issue