forked from CQCL/hugr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
justfile
87 lines (73 loc) · 2.62 KB
/
justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# List the available commands
help:
@just --list --justfile {{justfile()}}
# Prepare the environment for development, installing all the dependencies and
# setting up the pre-commit hooks.
setup:
uv sync
[[ -n "${HUGR_JUST_INHIBIT_GIT_HOOKS:-}" ]] || uv run pre-commit install -t pre-commit
# Run the pre-commit checks.
check:
HUGR_TEST_SCHEMA=1 uv run pre-commit run --all-files
# Run all the tests.
test language="[rust|python]" : (_run_lang language \
"HUGR_TEST_SCHEMA=1 cargo test --all-features" \
"cargo build -p hugr-cli && HUGR_RENDER_DOT=1 uv run pytest"
)
# Run all the benchmarks.
bench language="[rust|python]": (_run_lang language \
"cargo bench" \
"true"
)
# Auto-fix all clippy warnings.
fix language="[rust|python]": (_run_lang language \
"cargo clippy --all-targets --all-features --workspace --fix --allow-staged --allow-dirty" \
"uv run ruff check --fix"
)
# Format the code.
format language="[rust|python]": (_run_lang language \
"cargo fmt" \
"uv run ruff format"
)
# Generate a test coverage report.
coverage language="[rust|python]": (_run_lang language \
"cargo llvm-cov --lcov > lcov.info" \
"uv run pytest --cov=./ --cov-report=html"
)
# Run unsoundness checks using miri
miri *TEST_ARGS:
PROPTEST_DISABLE_FAILURE_PERSISTENCE=true MIRIFLAGS='-Zmiri-env-forward=PROPTEST_DISABLE_FAILURE_PERSISTENCE' cargo +nightly miri test {{TEST_ARGS}}
# Update the HUGR schema.
update-schema:
uv run scripts/generate_schema.py specification/schema/
# Update snapshots used in the pytest tests.
update-pytest-snapshots:
uv run pytest --snapshot-update
# Generate serialized declarations for the standard extensions and prelude.
gen-extensions:
cargo run -p hugr-cli gen-extensions -o specification/std_extensions
cp -r specification/std_extensions/* hugr-py/src/hugr/std/_json_defs/
# Build the python documentation in hugr-py/docs.
build-py-docs:
cd hugr-py/docs && ./build.sh
# Run rust semver-checks to detect breaking changes since the last release.
semver-checks:
cargo semver-checks
# Runs a rust and a python command, depending on the `language` variable.
#
# If `language` is set to `rust` or `python`, only run the command for that language.
# Otherwise, run both commands.
_run_lang language rust_cmd python_cmd:
#!/usr/bin/env bash
set -euo pipefail
if [ "{{ language }}" = "rust" ]; then
set -x
{{ rust_cmd }}
elif [ "{{ language }}" = "python" ]; then
set -x
{{ python_cmd }}
else
set -x
{{ rust_cmd }}
{{ python_cmd }}
fi