build: use nox instead of just
This commit is contained in:
parent
0530f03691
commit
0142dfe838
2 changed files with 117 additions and 28 deletions
28
justfile
28
justfile
|
|
@ -1,28 +0,0 @@
|
|||
build *ARGS:
|
||||
cargo build {{ARGS}}
|
||||
|
||||
test *ARGS:
|
||||
cargo test {{ARGS}}
|
||||
|
||||
pytest *ARGS:
|
||||
cd pyargus && pytest {{ARGS}}
|
||||
|
||||
check:
|
||||
pre-commit run -a
|
||||
cd pyargus && stubtest argus
|
||||
|
||||
test-coverage $CARGO_INCREMENTAL="0" $RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort" $RUSTDOCFLAGS="-Cpanic=abort" $LLVM_PROFILE_FILE="argus-%p-%m.profraw":
|
||||
fd -e gcda -e profraw --no-ignore -x rm
|
||||
cargo +nightly build
|
||||
cargo +nightly test
|
||||
|
||||
html-cov: test-coverage
|
||||
grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing -o ./target/debug/coverage/
|
||||
|
||||
doc:
|
||||
cargo doc --no-deps
|
||||
fd -e md . doc/ -x rustdoc {}
|
||||
fd -e html . doc/ -x mv {} target/doc/argus/
|
||||
|
||||
serve-doc: doc
|
||||
python3 -m http.server -d target/doc/
|
||||
117
noxfile.py
Normal file
117
noxfile.py
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
from pathlib import Path
|
||||
|
||||
import nox
|
||||
|
||||
nox.options.default_venv_backend = "mamba"
|
||||
nox.options.sessions = ["check"]
|
||||
nox.options.reuse_existing_virtualenvs = True
|
||||
|
||||
CURRENT_DIR = Path(__file__).parent.resolve()
|
||||
TARGET_DIR = CURRENT_DIR / "target"
|
||||
COVERAGE_DIR = TARGET_DIR / "debug/coverage"
|
||||
|
||||
ENV = dict(
|
||||
CARGO_TARGET_DIR=str(TARGET_DIR),
|
||||
)
|
||||
|
||||
|
||||
@nox.session
|
||||
def dev(session: nox.Session):
|
||||
session.conda_install("pre-commit")
|
||||
session.run("pre-commit", "install")
|
||||
|
||||
|
||||
@nox.session
|
||||
def check(session: nox.Session):
|
||||
session.conda_install("pre-commit")
|
||||
session.run("pre-commit", "run", "-a")
|
||||
|
||||
|
||||
@nox.session
|
||||
def tests(session: nox.Session):
|
||||
session.conda_install("pytest", "hypothesis")
|
||||
session.env.update(ENV)
|
||||
session.install("-e", "./pyargus")
|
||||
session.run("cargo", "test", external=True)
|
||||
session.run("pytest", "pyargus")
|
||||
|
||||
|
||||
@nox.session
|
||||
def coverage(session: nox.Session):
|
||||
session.conda_install("pytest", "coverage", "hypothesis", "maturin", "lcov")
|
||||
session.run("cargo", "install", "grcov", external=True, silent=True)
|
||||
|
||||
session.env.update(ENV)
|
||||
session.env.update(
|
||||
dict(
|
||||
RUSTC_BOOTSTRAP="1",
|
||||
CARGO_INCREMENTAL="0",
|
||||
RUSTFLAGS=" ".join(
|
||||
[
|
||||
"-Zprofile",
|
||||
"-Ccodegen-units=1",
|
||||
"-Copt-level=0",
|
||||
"-Clink-dead-code",
|
||||
"-Coverflow-checks=off",
|
||||
"-Zpanic_abort_tests",
|
||||
"-Cpanic=unwind",
|
||||
]
|
||||
),
|
||||
RUSTDOCFLAGS="-Cpanic=abort",
|
||||
LLVM_PROFILE_FILE="argus-%p-%m.profraw",
|
||||
)
|
||||
)
|
||||
session.run("cargo", "+nightly", "build", external=True, silent=True)
|
||||
session.run(
|
||||
"maturin",
|
||||
"develop",
|
||||
"-m",
|
||||
"./pyargus/Cargo.toml",
|
||||
silent=True,
|
||||
)
|
||||
try:
|
||||
COVERAGE_DIR.mkdir(exist_ok=True)
|
||||
session.run("cargo", "+nightly", "test", external=True, silent=True)
|
||||
except Exception:
|
||||
...
|
||||
finally:
|
||||
session.run(
|
||||
"grcov",
|
||||
".",
|
||||
"-s",
|
||||
f"{CURRENT_DIR}",
|
||||
"--binary-path",
|
||||
f"{TARGET_DIR}/debug",
|
||||
"--filter",
|
||||
"covered",
|
||||
"-t",
|
||||
"lcov",
|
||||
"--branch",
|
||||
"--ignore-not-existing",
|
||||
"--ignore",
|
||||
f"{Path.home()}/.cargo/**",
|
||||
"-o",
|
||||
"rust.lcov",
|
||||
external=True,
|
||||
)
|
||||
|
||||
try:
|
||||
session.run(
|
||||
"coverage", "run", "--source", "pyargus/argus", "-m", "pytest", silent=True
|
||||
)
|
||||
except Exception:
|
||||
...
|
||||
finally:
|
||||
session.run("coverage", "lcov", "-o", "python.lcov")
|
||||
|
||||
session.run(
|
||||
"genhtml",
|
||||
"--show-details",
|
||||
"--highlight",
|
||||
"--ignore-errors",
|
||||
"source",
|
||||
"--legend",
|
||||
"-o",
|
||||
"htmlcov/",
|
||||
*map(str, CURRENT_DIR.glob("*.lcov")),
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue