-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjustfile
More file actions
319 lines (243 loc) · 9.69 KB
/
justfile
File metadata and controls
319 lines (243 loc) · 9.69 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
# Cross-platform justfile using OS annotations
# Windows uses PowerShell, Unix uses bash
set windows-shell := ["powershell.exe", "-c"]
set shell := ["bash", "-c"]
set dotenv-load := true
set ignore-comments := true
# Use mise to manage all dev tools (go, pre-commit, uv, etc.)
# See mise.toml for tool versions
mise_exec := "mise exec --"
root := justfile_dir()
# =============================================================================
# GENERAL COMMANDS
# =============================================================================
default:
@just --list
# =============================================================================
# SETUP AND INITIALIZATION
# =============================================================================
# Development setup - mise handles all tool installation via mise.toml
setup:
mise install
# =============================================================================
# FORMATTING AND LINTING
# =============================================================================
alias format-rust := fmt
alias format-md := format-docs
alias format-just := fmt-justfile
# Main format recipe - calls all formatters
format: fmt format-json-yaml format-docs fmt-justfile
# Individual format recipes
format-json-yaml:
@{{ mise_exec }} prettier --write "**/*.{json,yaml,yml}"
format-docs:
@{{ mise_exec }} mdformat .
fmt:
@{{ mise_exec }} cargo fmt --all
fmt-check:
@{{ mise_exec }} cargo fmt --all --check
lint-rust: fmt-check
@{{ mise_exec }} cargo clippy --workspace --all-targets --all-features -- -D warnings
lint-rust-min:
@{{ mise_exec }} cargo clippy --workspace --all-targets --no-default-features -- -D warnings
# Format justfile
fmt-justfile:
@just --fmt --unstable
# Lint justfile formatting
lint-justfile:
@just --fmt --check --unstable
# Main lint recipe - calls all sub-linters
lint: lint-rust lint-actions lint-docs lint-justfile
# Individual lint recipes
# Lint GitHub Actions workflows. Uses a glob so new workflow files
# added by future contributors are picked up automatically instead of
# having to extend a hand-curated list. `release.yml` is generated by
# cargo-dist and is excluded to avoid false positives in generated
# code; `release-plz.yml` is included (review finding D-L5).
lint-actions:
@{{ mise_exec }} actionlint -ignore 'release.yml' .github/workflows/*.yml
lint-docs:
@{{ mise_exec }} markdownlint-cli2 docs/**/*.md README.md
@{{ mise_exec }} lychee docs/**/*.md README.md
alias lint-just := lint-justfile
# Run clippy with fixes
fix:
@{{ mise_exec }} cargo clippy --fix --allow-dirty --allow-staged
# Quick development check
check: pre-commit-run lint
[private]
pre-commit-run:
@{{ mise_exec }} pre-commit run -a
# Format a single file (for pre-commit hooks)
format-files +FILES:
@{{ mise_exec }} prettier --write --config .prettierrc.json {{ FILES }}
# =============================================================================
# BUILDING AND TESTING
# =============================================================================
build:
@{{ mise_exec }} cargo build --workspace
build-release:
@{{ mise_exec }} cargo build --workspace --release
test:
@{{ mise_exec }} cargo nextest run --workspace --no-capture
# Verify compatibility test files are available
[windows]
verify-compatibility-tests:
@echo "Verifying compatibility test files are available..."
if (-not (Test-Path "third_party/tests")) { Write-Error "third_party/tests directory not found" }
if (-not (Test-Path "third_party/magic.mgc")) { Write-Error "third_party/magic.mgc not found" }
[unix]
verify-compatibility-tests:
@echo "Verifying compatibility test files are available..."
@if [ ! -d "third_party/tests" ]; then echo "third_party/tests directory not found" && exit 1; fi
@if [ ! -f "third_party/magic.mgc" ]; then echo "third_party/magic.mgc not found" && exit 1; fi
# Run compatibility tests against original libmagic test suite
test-compatibility:
@{{ mise_exec }} cargo test test_compatibility_with_original_libmagic -- --ignored
# Run all compatibility tests (including setup)
test-compatibility-full: verify-compatibility-tests
@{{ mise_exec }} cargo build --release
@{{ mise_exec }} cargo test test_compatibility_with_original_libmagic -- --ignored
test-ci:
@{{ mise_exec }} cargo nextest run --workspace --no-capture
# Run all tests including ignored/slow tests across workspace
test-all:
@{{ mise_exec }} cargo nextest run --workspace --no-capture -- --ignored
# =============================================================================
# BENCHMARKING
# =============================================================================
# Run all benchmarks
bench:
@{{ mise_exec }} cargo bench --workspace
# =============================================================================
# SECURITY AND AUDITING
# =============================================================================
audit:
@{{ mise_exec }} cargo audit
deny:
@{{ mise_exec }} cargo deny check
# =============================================================================
# CI AND QUALITY ASSURANCE
# =============================================================================
# Private helper: run cargo llvm-cov with proper setup
[private]
[unix]
_coverage +args:
#!/usr/bin/env bash
set -euo pipefail
rm -rf target/llvm-cov-target
RUSTFLAGS="--cfg coverage" {{ mise_exec }} cargo llvm-cov --workspace --lcov --output-path lcov.info {{ args }}
[private]
[windows]
_coverage +args:
Remove-Item -Recurse -Force target/llvm-cov-target -ErrorAction SilentlyContinue
$env:RUSTFLAGS = "--cfg coverage"; {{ mise_exec }} cargo llvm-cov --workspace --lcov --output-path lcov.info {{ args }}
coverage:
@just _coverage
coverage-check:
@just _coverage --fail-under-lines 85
# Generate HTML coverage report for local viewing
[unix]
coverage-report:
#!/usr/bin/env bash
set -euo pipefail
rm -rf target/llvm-cov-target
RUSTFLAGS="--cfg coverage" {{ mise_exec }} cargo llvm-cov --workspace --html --open
[windows]
coverage-report:
$env:RUSTFLAGS = "--cfg coverage"; {{ mise_exec }} cargo llvm-cov --workspace --html --open
# Show coverage summary by file
[unix]
coverage-summary:
#!/usr/bin/env bash
set -euo pipefail
rm -rf target/llvm-cov-target
RUSTFLAGS="--cfg coverage" {{ mise_exec }} cargo llvm-cov --workspace
[windows]
coverage-summary:
$env:RUSTFLAGS = "--cfg coverage"; {{ mise_exec }} cargo llvm-cov --workspace
# Full local CI parity check. Includes `deny` so the local run covers
# the same gates as CI -- the recipe previously omitted `cargo deny
# check` even though CI runs it daily (review finding D-L4).
ci-check: pre-commit-run fmt-check lint-rust lint-rust-min test-ci build-release audit deny coverage-check dist-plan
# Run compatibility tests as part of CI
ci-check-compatibility: pre-commit-run fmt-check lint-rust lint-rust-min test-ci build-release audit deny coverage-check test-compatibility dist-plan
# =============================================================================
# DISTRIBUTION AND PACKAGING
# =============================================================================
dist:
@{{ mise_exec }} dist build
dist-check:
@{{ mise_exec }} dist check
dist-plan:
@{{ mise_exec }} dist plan
# Regenerate cargo-dist CI workflow safely
dist-generate-ci:
{{ mise_exec }} dist generate --ci github
@echo "Generated CI workflow. Remember to fix any expression errors if they exist."
@echo "Run 'just lint:actions' to validate the generated workflow."
install:
@{{ mise_exec }} cargo install --path .
# =============================================================================
# DOCUMENTATION
# =============================================================================
# Build complete documentation (mdBook + rustdoc)
[unix]
docs-build:
#!/usr/bin/env bash
set -euo pipefail
# Build rustdoc
{{ mise_exec }} cargo doc --no-deps --document-private-items --target-dir docs/book/api-temp
# Move rustdoc output to final location
mkdir -p docs/book/api
cp -r docs/book/api-temp/doc/* docs/book/api/
rm -rf docs/book/api-temp
# Build mdBook
cd docs && {{ mise_exec }} mdbook build
# Serve documentation locally with live reload
[unix]
docs-serve:
cd docs && {{ mise_exec }} mdbook serve --open
# Clean documentation artifacts
[unix]
docs-clean:
rm -rf docs/book target/doc
# Check documentation (build + link validation + formatting)
[unix]
docs-check:
cd docs && {{ mise_exec }} mdbook build
@just fmt-check
# Generate and serve documentation
[unix]
docs: docs-build docs-serve
[windows]
docs:
@echo "mdbook requires a Unix-like environment to serve"
# =============================================================================
# CHANGELOG
# =============================================================================
# Generate changelog
[group('docs')]
changelog:
@{{ mise_exec }} git-cliff --output CHANGELOG.md
# Generate changelog for a specific version
[group('docs')]
changelog-version version:
@{{ mise_exec }} git-cliff --tag {{ version }} --output CHANGELOG.md
# Generate changelog for unreleased changes only
[group('docs')]
changelog-unreleased:
@{{ mise_exec }} git-cliff --unreleased --output CHANGELOG.md
# =============================================================================
# RELEASE MANAGEMENT
# =============================================================================
release:
@{{ mise_exec }} cargo release
release-dry-run:
@{{ mise_exec }} cargo release --dry-run
release-patch:
@{{ mise_exec }} cargo release patch
release-minor:
@{{ mise_exec }} cargo release minor
release-major:
@{{ mise_exec }} cargo release major