-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjustfile
More file actions
357 lines (279 loc) · 9.31 KB
/
Copy pathjustfile
File metadata and controls
357 lines (279 loc) · 9.31 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
# Stringy justfile -- run `just` or `just --list` to see available recipes.
#
# Windows uses PowerShell, Unix uses bash. mise manages every dev tool
# (Rust toolchain + components, cargo subcommands, mdbook plugins, mdformat,
# zig, etc.) -- see mise.toml. There are no per-tool install recipes; `setup`
# just runs `mise install`.
set shell := ["bash", "-cu"]
set windows-shell := ["powershell", "-NoProfile", "-Command"]
set dotenv-load
set ignore-comments
set quiet
mise_exec := "mise exec --"
root := justfile_dir()
# General
[private]
default:
just --choose
[group('general')]
help:
just --list
# Cross-platform helpers. Each keeps Windows and Unix variants only because
# the underlying shell command genuinely differs.
[private]
[windows]
ensure-dir dir:
New-Item -ItemType Directory -Force -Path "{{ dir }}" | Out-Null
[private]
[unix]
ensure-dir dir:
/bin/mkdir -p "{{ dir }}"
[private]
[windows]
rmrf path:
if (Test-Path "{{ path }}") { Remove-Item "{{ path }}" -Recurse -Force }
[private]
[unix]
rmrf path:
/bin/rm -rf "{{ path }}"
# Setup
# Development setup. mise installs every tool from mise.toml, including the
# Rust toolchain + components, all cargo subcommands, the mdbook plugins,
# and mdformat -- so there are no separate per-tool install recipes.
[group('setup')]
setup:
mise trust
mise install
# Update dependencies
[group('setup')]
update-deps:
mise upgrade --bump --local
{{ mise_exec }} cargo update --workspace
{{ mise_exec }} pre-commit autoupdate
# Formatting and Linting
alias format-rust := fmt
alias format-just := fmt-justfile
# Run every formatter
[group('quality')]
format: fmt format-json-yaml fmt-justfile
[group('quality')]
format-json-yaml:
{{ mise_exec }} prettier --write "**/*.{json,yaml,yml}"
[group('quality')]
fmt:
{{ mise_exec }} cargo fmt --all
[group('quality')]
fmt-check:
{{ mise_exec }} cargo fmt --all --check
[group('quality')]
lint-rust: fmt-check
{{ mise_exec }} cargo clippy --workspace --all-targets --all-features -- -D warnings
[group('quality')]
lint-rust-min:
{{ mise_exec }} cargo clippy --workspace --all-targets --no-default-features -- -D warnings
# Format justfile
[group('quality')]
fmt-justfile:
just --fmt --unstable
# Lint justfile formatting
[group('quality')]
lint-justfile:
just --fmt --check --unstable
# Run every linter
[group('quality')]
lint: lint-rust lint-actions lint-docs lint-justfile
[group('quality')]
lint-actions:
{{ mise_exec }} actionlint .github/workflows/*.yml
[group('quality')]
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
[group('quality')]
fix:
{{ mise_exec }} cargo clippy --fix --allow-dirty --allow-staged
# Quick development check
[group('quality')]
check: pre-commit-run lint
[private]
pre-commit-run:
{{ mise_exec }} pre-commit run -a
# Format a single file (for pre-commit hooks)
[group('quality')]
format-files +FILES:
{{ mise_exec }} prettier --write --config .prettierrc.json {{ FILES }}
# Building and Testing
[group('build')]
build:
{{ mise_exec }} cargo build --workspace
[group('build')]
build-release:
{{ mise_exec }} cargo build --workspace --release --all-features
[group('test')]
test:
{{ mise_exec }} cargo nextest run --workspace --no-capture
[group('test')]
test-ci:
{{ mise_exec }} cargo nextest run --workspace --all-features --no-capture
# Run all tests including ignored/slow tests across workspace
[group('test')]
test-all:
{{ mise_exec }} cargo nextest run --workspace --no-capture -- --ignored
# Run all benchmarks
[group('test')]
bench:
{{ mise_exec }} cargo bench --workspace
# Test Fixtures
# Zig cross-compiles test fixtures for all targets from any host.
# Changing the Zig version in mise.toml may alter compiled layouts,
# which breaks insta snapshots. After bumping, run:
# just gen-fixtures
# INSTA_UPDATE=always cargo nextest run
# cargo insta accept # review & commit updated snapshots
# Generate all test fixtures via Zig cross-compilation
[group('test')]
gen-fixtures:
just ensure-dir tests/fixtures
{{ mise_exec }} zig cc -target x86_64-linux-gnu -o tests/fixtures/test_binary_elf tests/fixtures/test_binary.c
{{ mise_exec }} zig cc -target x86_64-windows-gnu -o tests/fixtures/test_binary_pe.exe tests/fixtures/test_binary.c
{{ mise_exec }} zig rc /fo tests/fixtures/test_binary_with_resources.res -- tests/fixtures/test_binary_with_resources.rc
{{ mise_exec }} zig cc -target x86_64-windows-gnu -o tests/fixtures/test_binary_with_resources.exe tests/fixtures/test_binary_with_resources.c tests/fixtures/test_binary_with_resources.res
just rmrf tests/fixtures/test_binary_with_resources.res
# Zig bundles macOS libc stubs, so this works from any host without an Apple SDK.
# The fixture only needs to be a valid Mach-O container for parser tests, not a runnable binary.
{{ mise_exec }} zig cc -target x86_64-macos -o tests/fixtures/test_binary_macho tests/fixtures/test_binary.c
just gen-static-fixtures
# Write the committed, platform-independent fixtures (empty file + unknown
# blob). Only the byte-writing primitive differs per OS; keep the two in sync.
[private]
[unix]
gen-static-fixtures:
truncate -s 0 tests/fixtures/test_empty.bin
printf '\xde\xad\xbe\xef\x00\x00\x00\x00NOT_A_BINARY\nhttp://example.com/test\n' > tests/fixtures/test_unknown.bin
[private]
[windows]
gen-static-fixtures:
New-Item -ItemType File -Force -Path "tests/fixtures/test_empty.bin" | Out-Null
[System.IO.File]::WriteAllBytes("tests/fixtures/test_unknown.bin", [byte[]]@(0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00) + [System.Text.Encoding]::ASCII.GetBytes("NOT_A_BINARY`nhttp://example.com/test`n"))
# Security and Auditing
[group('security')]
audit:
{{ mise_exec }} cargo audit
[group('security')]
deny:
{{ mise_exec }} cargo deny check
[group('security')]
outdated:
{{ mise_exec }} cargo outdated --depth=1 --exit-code=1
# CI and Quality Assurance
# Generate coverage report
[group('ci')]
coverage:
{{ mise_exec }} cargo llvm-cov --workspace --all-features --lcov --output-path lcov.info
# Check coverage thresholds
[group('ci')]
coverage-check:
{{ mise_exec }} cargo llvm-cov --workspace --all-features --lcov --output-path lcov.info --fail-under-lines 9.7
# Full local CI parity check (gen-fixtures ensures compiled test binaries exist)
[group('ci')]
ci-check: pre-commit-run fmt-check lint-rust lint-rust-min gen-fixtures test-ci build-release audit coverage-check dist-check
# Development and Execution
[group('dev')]
run *args:
{{ mise_exec }} cargo run -p stringy -- {{ args }}
# Distribution and Packaging
[group('dist')]
dist:
{{ mise_exec }} dist build
[group('dist')]
dist-check:
{{ mise_exec }} dist plan
alias dist-plan := dist-check
# Regenerate cargo-dist CI workflow safely
[group('dist')]
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."
[group('dist')]
install:
{{ mise_exec }} cargo install --path .
# Documentation
# Build complete documentation (mdBook + rustdoc)
[group('docs')]
[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
[group('docs')]
[unix]
docs-serve:
cd docs && {{ mise_exec }} mdbook serve --open
# Clean documentation artifacts
[group('docs')]
[unix]
docs-clean:
rm -rf docs/book target/doc
# Check documentation (build + link validation + formatting)
[group('docs')]
[unix]
docs-check:
cd docs && {{ mise_exec }} mdbook build
just fmt-check
# Generate and serve documentation
[group('docs')]
[unix]
docs: docs-build docs-serve
[group('docs')]
[windows]
docs:
echo "mdbook requires a Unix-like environment to serve"
# GoReleaser Testing
# Test GoReleaser configuration
[group('dist')]
goreleaser-check:
{{ mise_exec }} goreleaser check
# Build binaries locally with GoReleaser (test build process)
[group('dist')]
goreleaser-build:
{{ mise_exec }} goreleaser build --clean
# Run snapshot release (test full pipeline without publishing)
[group('dist')]
goreleaser-snapshot:
{{ mise_exec }} goreleaser release --snapshot --clean
# Test GoReleaser with specific target
[arg("target", help="Target triple to build for (e.g., x86_64-unknown-linux-gnu)")]
[group('dist')]
goreleaser-build-target target:
{{ mise_exec }} goreleaser build --clean --single-target {{ target }}
# Clean GoReleaser artifacts
[group('dist')]
goreleaser-clean:
just rmrf dist
# Release Management
[group('release')]
release:
{{ mise_exec }} cargo release
[group('release')]
release-dry-run:
{{ mise_exec }} cargo release --dry-run
[group('release')]
release-patch:
{{ mise_exec }} cargo release patch
[group('release')]
release-minor:
{{ mise_exec }} cargo release minor
[group('release')]
release-major:
{{ mise_exec }} cargo release major