-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy path.justfile
More file actions
387 lines (329 loc) · 12 KB
/
.justfile
File metadata and controls
387 lines (329 loc) · 12 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
# Set shell to bash for better compatibility
set shell := ["bash", "-c"]
# Variables
git_tag := `git describe --tags --abbrev=0 2>/dev/null || echo "no-tag"`
build_path := "target"
functional_tests_dir := "functional-tests"
functional_tests_datadir := "_dd"
docker_dir := "docker"
docker_datadir := ".data"
prover_perf_eval_dir := "bin/prover-perf"
prover_proofs_cache_dir := "provers/tests/proofs"
prover_programs := "alpen-chunk,alpen-acct,checkpoint,"
profile := env("PROFILE", "release")
cargo_install_extra_flags := env("CARGO_INSTALL_EXTRA_FLAGS", "")
features := env("FEATURES", "")
docker_image_name := env("DOCKER_IMAGE_NAME", "")
unit_test_args := "--locked --workspace -E 'kind(lib)' -E 'kind(bin)' -E 'kind(proc-macro)'"
cov_file := "lcov.info"
# Default recipe - show available commands
default:
@just --list
# Build the workspace
[group('build')]
build:
cargo build --workspace --all-features --lib --bins --examples --benches --locked
# Run unit tests
[group('test')]
test-unit: ensure-cargo-nextest
cargo nextest run {{unit_test_args}}
# Run unit tests with coverage
[group('test')]
cov-unit: ensure-cargo-llvm-cov ensure-cargo-nextest
rm -f {{cov_file}}
cargo llvm-cov nextest --lcov --output-path {{cov_file}} {{unit_test_args}}
# Generate an HTML coverage report and open it in the browser
[group('test')]
cov-report-html: ensure-cargo-llvm-cov ensure-cargo-nextest
cargo llvm-cov --open --workspace --locked nextest
# Run integration tests
[group('test')]
test-int: ensure-cargo-nextest
cargo nextest run -p "integration-tests" --status-level=fail --no-capture --no-tests=warn
# Runs `nextest` under `cargo-mutants`. Caution: This can take *really* long to run
[group('test')]
mutants-test: ensure-cargo-mutants
cargo mutants --workspace -j2
# Check for security advisories on any dependencies
[group('test')]
sec: ensure-cargo-audit
cargo audit
# Generate reports and profiling data for proofs
[group('prover')]
prover-eval: prover-clean
cd {{prover_perf_eval_dir}} && RUST_LOG=info SP1_PROVER=light ZKVM_MOCK=1 ZKVM_PROFILING=1 cargo run --release -- --programs {{prover_programs}}
# Cleans up proofs and profiling data generated
[group('prover')]
prover-clean:
rm -rf {{prover_perf_eval_dir}}/*.trace
rm -rf {{prover_proofs_cache_dir}}/*.proof
# Check if cargo-audit is installed
[group('prerequisites')]
ensure-cargo-audit:
#!/usr/bin/env bash
if ! command -v cargo-audit &> /dev/null;
then
echo "cargo-audit not found. Please install it by running the command 'cargo install cargo-audit'"
exit 1
fi
# Check if cargo-llvm-cov is installed
[group('prerequisites')]
ensure-cargo-llvm-cov:
#!/usr/bin/env bash
if ! command -v cargo-llvm-cov &> /dev/null;
then
echo "cargo-llvm-cov not found. Please install it by running the command 'cargo install cargo-llvm-cov --locked'"
exit 1
fi
# Check if cargo-mutants is installed
[group('prerequisites')]
ensure-cargo-mutants:
#!/usr/bin/env bash
if ! command -v cargo-mutants &> /dev/null;
then
echo "cargo-mutants not found. Please install it by running the command 'cargo install cargo-mutants'"
exit 1
fi
# Check if cargo-nextest is installed
[group('prerequisites')]
ensure-cargo-nextest:
#!/usr/bin/env bash
if ! command -v cargo-nextest &> /dev/null;
then
echo "cargo-nextest not found. Please install it by running the command 'cargo install cargo-nextest --locked'"
exit 1
fi
# Check if codespell is installed
[group('prerequisites')]
ensure-codespell:
#!/usr/bin/env bash
if ! command -v codespell &> /dev/null;
then
echo "codespell not found. Please install it by running the command 'pip install codespell' or refer to the following link for more information: https://github.com/codespell-project/codespell"
exit 1
fi
# Check if shellcheck is installed
[group('prerequisites')]
ensure-shellcheck:
#!/usr/bin/env bash
if ! command -v shellcheck &> /dev/null;
then
echo "shellcheck not found. Please install it. See: https://www.shellcheck.net/"
exit 1
fi
# Check if uv is installed
[group('prerequisites')]
ensure-uv:
#!/usr/bin/env bash
if ! command -v uv &> /dev/null;
then
echo "uv not found. Please install it by following the instructions from: https://docs.astral.sh/uv/"
exit 1
fi
# Check if taplo is installed
[group('prerequisites')]
ensure-taplo:
#!/usr/bin/env bash
if ! command -v taplo &> /dev/null;
then
echo "taplo not found. Please install it by following the instructions from: https://taplo.tamasfe.dev/cli/installation/binary.html"
exit 1
fi
# Activate uv environment for integration tests
[group('functional-tests')]
activate-uv: ensure-uv
cd {{functional_tests_dir}} && uv venv --clear
@if [ -n "${FISH_VERSION:-}" ]; then source {{functional_tests_dir}}/.venv/bin/activate.fish; else source {{functional_tests_dir}}/.venv/bin/activate; fi
# Remove the data directory used by functional tests
[group('functional-tests')]
clean-dd:
rm -rf {{functional_tests_dir}}/{{functional_tests_datadir}} 2>/dev/null || true
# cargo clean
[group('functional-tests')]
clean-cargo:
cargo clean 2>/dev/null || true
# Remove docker data files inside /docker/.data
[group('functional-tests')]
clean-docker-data:
rm -rf {{docker_dir}}/{{docker_datadir}} 2>/dev/null || true
# Remove uv virtual environment
[group('functional-tests')]
clean-uv:
cd {{functional_tests_dir}} && rm -rf .venv 2>/dev/null || true
# Clean functional tests directory, cargo clean, clean docker data, clean uv virtual environment
[group('functional-tests')]
clean: clean-dd clean-docker-data clean-cargo clean-uv
@echo "\n\033[36m======== CLEAN_COMPLETE ========\033[0m\n"
# Runs functional tests
[group('functional-tests')]
test-functional: ensure-uv activate-uv clean-dd
cd {{functional_tests_dir}} && ./run_tests.sh
# Check formatting issues but do not fix automatically
[group('code-quality')]
fmt-check-ws:
cargo fmt --check
# Format source code in the workspace
[group('code-quality')]
fmt-ws:
cargo fmt --all
# Runs `taplo` to check that TOML files are properly formatted
[group('code-quality')]
fmt-check-toml: ensure-taplo
taplo fmt --check
# Runs `taplo` to format TOML files
[group('code-quality')]
fmt-toml: ensure-taplo
taplo fmt
# Check formatting of python files inside `test` directory
[group('code-quality')]
fmt-check-func-tests: ensure-uv activate-uv
cd {{functional_tests_dir}} && uv run ruff format --check
# Apply formatting of python files inside `test` directory
[group('code-quality')]
fmt-func-tests: ensure-uv activate-uv
cd {{functional_tests_dir}} && uv run ruff format
# Checks for lint issues in the workspace
[group('code-quality')]
lint-check-ws:
cargo clippy \
--workspace \
--lib \
--bins \
--examples \
--tests \
--benches \
--all-features \
--no-deps \
-- -D warnings
# Lints the workspace and applies fixes where possible
[group('code-quality')]
lint-fix-ws:
cargo clippy \
--workspace \
--lib \
--bins \
--examples \
--tests \
--benches \
--all-features \
--fix \
--no-deps \
--allow-dirty \
-- -D warnings
# Runs `codespell` to check for spelling errors
[group('code-quality')]
lint-check-codespell: ensure-codespell
codespell
# Runs `codespell` to fix spelling errors if possible
[group('code-quality')]
lint-fix-codespell: ensure-codespell
codespell -w
# Lints TOML files
[group('code-quality')]
lint-check-toml: ensure-taplo
taplo lint
# Lints the functional tests
[group('code-quality')]
lint-check-func-tests: ensure-uv activate-uv
cd {{functional_tests_dir}} && uv run ruff check
# Lints shell scripts
[group('code-quality')]
lint-check-shell: ensure-shellcheck
@echo "Linting shell scripts..."
@find . -type f \( -name '*.sh' -o -name '*.bash' \) -not -path "./target/*" -not -path "./.git/*" -not -path "./.ropeproject/*" -not -path "./functional-tests/.venv/*" -execdir shellcheck -x {} +
# Check for struct naming style issues
[group('code-quality')]
lint-check-style:
./contrib/find_with_structs.sh crates/
./contrib/find_with_structs.sh bin/
# Check that new TODO/FIXME comments include a ticket reference
[group('code-quality')]
lint-check-todos base_ref="main":
./contrib/check_ticketless_todos.sh {{base_ref}}
# Lints the functional tests and applies fixes where possible
[group('code-quality')]
lint-fix-func-tests: ensure-uv activate-uv
cd {{functional_tests_dir}} && uv run ruff check --fix
# Runs all lints and checks for issues without trying to fix them
[group('code-quality')]
lint: fmt-check-ws fmt-check-func-tests fmt-check-toml lint-check-ws lint-check-func-tests lint-check-codespell lint-check-shell lint-check-style lint-check-todos
@echo "\n\033[36m======== OK: Lints and Formatting ========\033[0m\n"
# Runs all lints and applies fixes where possible
[group('code-quality')]
lint-fix: fmt-toml fmt-ws lint-fix-ws lint-fix-codespell
@echo "\n\033[36m======== OK: Lints and Formatting Fixes ========\033[0m\n"
# Runs `cargo docs` to generate the Rust documents in the `target/doc` directory
[group('code-quality')]
rustdocs:
RUSTDOCFLAGS="\
--show-type-layout \
--enable-index-page -Z unstable-options \
-A rustdoc::private-doc-tests \
-D warnings" \
cargo doc \
--workspace \
--no-deps
# Runs doctests on the workspace
[group('code-quality')]
test-doc:
cargo test --doc --workspace
# Runs all tests in the workspace including unit and docs tests
[group('code-quality')]
test: test-unit test-doc
# Runs lints (without fixing), audit, docs, and tests (run this before creating a PR)
[group('code-quality')]
pr: lint rustdocs test-doc test-unit test-functional
@echo "\n\033[36m======== CHECKS_COMPLETE ========\033[0m\n"
@test -z \`git status --porcelain\` || echo "WARNING: You have uncommitted changes"
@echo "All good to create a PR!"
# Runs lints (without fixing), audit, docs, and tests(except functional tests)
# NOTE: This is a command to check everything else except the functional tests pass
# because sometimes running functional tests might be redundant.
[group('code-quality')]
pr-lite: lint rustdocs test-doc test-unit
@echo "\n\033[36m======== CHECKS_COMPLETE ========\033[0m\n"
@test -z \`git status --porcelain\` || echo "WARNING: You have uncommitted changes"
@echo "All good to create a PR!"
# Run all benchmarks in the workspace
[group('benches')]
bench: bench-db
# Open benchmark results in Criterion default output folder
[group('benches')]
bench-results:
#!/usr/bin/env bash
if [[ "$OSTYPE" == "darwin"* ]]; then
open target/criterion/
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
xdg-open target/criterion/
else
echo "Unsupported OS. Benchmark results are in target/criterion/"
fi
# Run all database benchmarks
[group('benches')]
bench-db: bench-db-sled
# Run database benchmarks with `sled` backend only
[group('benches')]
bench-db-sled:
cargo bench --package alpen-benchmarks --no-default-features --features=db,sled
# Rebuild sequencer stack images (uses docker cache, fast if no changes)
[group('docker')]
docker-seq-build:
cd {{docker_dir}} && docker compose -f compose-ol-el-seq.yml build
# Start local signet bitcoin node
[group('docker')]
docker-signet-up:
cd {{docker_dir}} && docker compose -f compose-signet.yml up -d
# Stop local signet bitcoin node
[group('docker')]
docker-signet-down:
cd {{docker_dir}} && docker compose -f compose-signet.yml down
# Start sequencer stack (signet + sequencer)
[group('docker')]
docker-seq-up: docker-signet-up
cd {{docker_dir}} && ./gen-params-and-elfs.sh
cd {{docker_dir}} && docker compose -f compose-ol-el-seq.yml up -d
# Stop sequencer stack (signet + sequencer)
[group('docker')]
docker-seq-down:
cd {{docker_dir}} && docker compose -f compose-ol-el-seq.yml down
cd {{docker_dir}} && docker compose -f compose-signet.yml down