-
Notifications
You must be signed in to change notification settings - Fork 22
/
justfile
55 lines (48 loc) · 1.48 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
# 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 run pre-commit install -t pre-commit
# Run the pre-commit checks.
check:
uv run pre-commit run --all-files
# Build the project.
build language="[rust|python]": (_run_lang language \
"cargo build" \
"uv run maturin develop"
)
# Run all the tests.
test language="[rust|python]": (_run_lang language \
"cargo test --all-features" \
"uv run maturin develop && uv run pytest"
)
# 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"
)
# 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