-
Notifications
You must be signed in to change notification settings - Fork 6
/
justfile
68 lines (58 loc) · 2.01 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
# 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 "${TKET2_JUST_INHIBIT_GIT_HOOKS:-}" ]] || uv run pre-commit install -t pre-commit
# Run the pre-commit checks.
check:
uv run pre-commit run --all-files
# Compile the wheels for the python package.
build:
cd tket2-py && uv run maturin build --release
# Run all the tests.
test language="[rust|python]" : (_run_lang language \
"uv run cargo test --all-features" \
"uv run maturin develop --uv && uv run pytest"
)
# Auto-fix all clippy warnings.
fix language="[rust|python]": (_run_lang language \
"uv run 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 \
"uv run cargo fmt" \
"uv run ruff format"
)
# Generate a test coverage report.
coverage language="[rust|python]": (_run_lang language \
"uv run cargo llvm-cov --lcov > lcov.info" \
"uv run maturin develop && uv run pytest --cov=./ --cov-report=html"
)
# Runs `compile-rewriter` on the ECCs in `test_files/eccs`
recompile-eccs:
scripts/compile-test-eccs.sh
# Generate serialized declarations for the tket2 extensions
gen-extensions:
cargo run -p tket2-hseries gen-extensions -o tket2-exts/src/tket2_exts/data
# 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