-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjustfile
More file actions
135 lines (107 loc) · 4.41 KB
/
Copy pathjustfile
File metadata and controls
135 lines (107 loc) · 4.41 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# Default to strict shell settings
set shell := ["bash", "-euo", "pipefail", "-c"]
# When just tryping `just`, show list of known commands
_default:
just --list --unsorted
# Timeout (seconds) for Python integration test recipes.
# Override with OPSQUEUE_PYTEST_TIMEOUT, e.g. OPSQUEUE_PYTEST_TIMEOUT=600 just nix-test-integration
pytest_timeout_seconds := env_var_or_default("OPSQUEUE_PYTEST_TIMEOUT", "60")
# The kill window is chosen to be above the `1s` join window on `multiprocess.Process`.
pytest_timeout_kill_seconds := "2s"
# Build-and-run the opsqueue binary (development profile)
[group('run')]
run *OPSQUEUE_ARGS:
cargo run --bin opsqueue -- {{OPSQUEUE_ARGS}}
# Build the binary and all client libraries (development profile)
[group('build')]
build: build-bin build-python
# Build the opsqueue binary executable (development profile)
[group('build')]
build-bin *ARGS:
cargo build --bin opsqueue {{ARGS}}
# Build the `opsqueue_python` Python client library (development profile)
[group('build')]
build-python *ARGS:
#!/usr/bin/env bash
set -euo pipefail
cd libs/opsqueue_python
source "./.setup_local_venv.sh"
maturin develop {{ARGS}}
[group('build')]
clean:
cargo clean
# Run all tests
[group('test')]
test: test-unit test-integration
# Rust unit test suite
[group('test')]
test-unit *TEST_ARGS:
cargo nextest run --workspace {{TEST_ARGS}}
# Python integration test suite. Args are forwarded to pytest
[group('test')]
test-integration *TEST_ARGS: build
#!/usr/bin/env bash
set -euo pipefail
export OPSQUEUE_BIN="$PWD/target/debug/opsqueue"
cd libs/opsqueue_python
source "./.setup_local_venv.sh"
timeout --signal term --kill-after {{pytest_timeout_kill_seconds}} {{pytest_timeout_seconds}} pytest --color=yes {{TEST_ARGS}}
# Python integration test suite, using artefacts built through Nix. Args are forwarded to pytest
[group('nix')]
nix-test-integration *TEST_ARGS: nix-build
#!/usr/bin/env bash
set -euo pipefail
nix_build_python_library_dir=$(just nix-build-python)
nix_build_bin_dir=$(just nix-build-bin)
cd libs/opsqueue_python/tests
export PYTHONPATH="${nix_build_python_library_dir}/lib/python3.13/site-packages"
export OPSQUEUE_BIN="${nix_build_bin_dir}/bin/opsqueue"
export RUST_LOG="opsqueue=debug"
timeout --signal term --kill-after {{pytest_timeout_kill_seconds}} {{pytest_timeout_seconds}} pytest --color=yes {{TEST_ARGS}}
# Run all linters, fast and slow
[group('lint')]
lint: (lint-light "--all-files") lint-heavy
# Run only the fast per-file linters; these might opt to only look at the changed files. Args are passed to pre-commit
[group('lint')]
lint-light *ARGS:
pre-commit run {{ARGS}}
# Run the slow linters/static analysers that need to look at everything
[group('lint')]
[parallel]
lint-heavy: clippy-fix lint-cargo mypy
# Serial execution on the main `CARGO_TARGET_DIR`
[group('lint')]
lint-cargo: clippy hakari
# Verify the workspace-hack crate is up to date
[group('lint')]
hakari:
cargo hakari verify
# Rust static analysis
[group('lint')]
clippy-fix:
# `cargo clippy --fix` caps lints to warnings internally; keep its artifacts separate.
CARGO_TARGET_DIR=target/clippy-fix cargo clippy --no-deps --all-targets --fix --allow-dirty --allow-staged -- -Dwarnings
CARGO_TARGET_DIR=target/clippy-fix cargo clippy --no-deps --all-targets --no-default-features --fix --allow-dirty --allow-staged -- -Dwarnings
CARGO_TARGET_DIR=target/clippy-fix cargo clippy --no-deps --all-targets --all-features --fix --allow-dirty --allow-staged -- -Dwarnings
# Rust static analysis
[group('lint')]
clippy:
cargo clippy --no-deps --all-targets -- -Dwarnings
cargo clippy --no-deps --all-targets --no-default-features -- -Dwarnings
cargo clippy --no-deps --all-targets --all-features -- -Dwarnings
# Python static analysis type-checker
[group('lint')]
mypy:
dmypy --version
dmypy run -- --strict --follow-imports=normal --junit-xml="" ./libs/opsqueue_python
# Build Nix-derivations of binary and all libraries (release profile)
[group('nix')]
nix-build: (_nix-build "opsqueue" "python.pkgs.opsqueue_python")
# Build Nix-derivation of binary (release profile)
[group('nix')]
nix-build-bin: (_nix-build "opsqueue")
# Build Nix-derivation of Python client library (release profile)
[group('nix')]
nix-build-python: (_nix-build "python.pkgs.opsqueue_python")
_nix-build +TARGETS:
nix build --file nix/nixpkgs-pinned.nix --print-out-paths --print-build-logs --no-link --option sandbox true {{TARGETS}}