-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjustfile
More file actions
283 lines (239 loc) · 9.25 KB
/
Copy pathjustfile
File metadata and controls
283 lines (239 loc) · 9.25 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
# Development tasks for Singularity Language Registry
# Run `just` to see available commands
# Default recipe - show help
default:
@just --list
# Enter Nix development shell
shell:
nix develop
# Build the project with Nix
build:
nix build -L
# Run all flake checks
check:
nix flake check -L
# Update flake inputs
update:
nix flake update
git add flake.lock
git commit -m "chore(nix): update flake.lock" || true
# Format all code
fmt:
cargo fmt
if command -v nix >/dev/null 2>&1; then \
nix shell nixpkgs#nixpkgs-fmt --command nixpkgs-fmt *.nix; \
elif command -v nixpkgs-fmt >/dev/null 2>&1; then \
nixpkgs-fmt *.nix; \
else \
echo "nixpkgs-fmt not available; install it or run 'nix develop'."; \
fi
# Run clippy with pedantic mode
clippy:
if command -v nix >/dev/null 2>&1; then \
OPENSSL_OUTPUT=$(nix eval --raw nixpkgs#openssl.out); \
OPENSSL_DEV=$(nix eval --raw nixpkgs#openssl.dev); \
PKG_CONFIG_PATH="$OPENSSL_DEV/lib/pkgconfig:${PKG_CONFIG_PATH:-}" \
OPENSSL_DIR="$OPENSSL_DEV" \
OPENSSL_INCLUDE_DIR="$OPENSSL_DEV/include" \
OPENSSL_LIB_DIR="$OPENSSL_OUTPUT/lib" \
nix shell nixpkgs#pkg-config nixpkgs#openssl --command cargo clippy --all-targets --all-features -- -D warnings -W clippy::pedantic -W clippy::nursery; \
else \
if [ -n "${OPENSSL_DIR:-}" ] || { command -v pkg-config >/dev/null 2>&1 && pkg-config --exists openssl; }; then \
cargo clippy --all-targets --all-features -- -D warnings -W clippy::pedantic -W clippy::nursery; \
else \
echo "openssl headers not found; skipping clippy (set OPENSSL_DIR or install pkg-config + openssl)"; \
fi; \
fi
# Run tests
test:
if command -v nix >/dev/null 2>&1; then \
OPENSSL_OUTPUT=$(nix eval --raw nixpkgs#openssl.out); \
OPENSSL_DEV=$(nix eval --raw nixpkgs#openssl.dev); \
PKG_CONFIG_PATH="$OPENSSL_DEV/lib/pkgconfig:${PKG_CONFIG_PATH:-}" \
OPENSSL_DIR="$OPENSSL_DEV" \
OPENSSL_INCLUDE_DIR="$OPENSSL_DEV/include" \
OPENSSL_LIB_DIR="$OPENSSL_OUTPUT/lib" \
nix shell nixpkgs#pkg-config nixpkgs#openssl --command cargo test --all-features; \
else \
if [ -n "${OPENSSL_DIR:-}" ] || { command -v pkg-config >/dev/null 2>&1 && pkg-config --exists openssl; }; then \
cargo test --all-features; \
else \
echo "openssl headers not found; running cargo test with default features instead (set OPENSSL_DIR or install pkg-config + openssl to enable full tests)"; \
cargo test; \
fi; \
fi
# Aggregate all checks used by the git pre-commit hook
pre-commit: fmt clippy test
@echo "✅ Pre-commit checks passed"
# Aggregate all checks used by the git pre-push hook
pre-push: fmt clippy test
@echo "✅ Pre-push checks passed"
# Run tests in release mode
test-release:
cargo test --all-features --release
# Generate code coverage
coverage:
cargo tarpaulin --all-features --out html
# Check for outdated dependencies
outdated:
cargo outdated
# Security audit
audit:
cargo audit
# Validate Renovate configuration
renovate-validate:
nix develop --command renovate-config-validator renovate.json5
# Build documentation
doc:
cargo doc --all-features --no-deps --open
# Run benchmarks
bench:
cargo bench
# Clean build artifacts
clean:
cargo clean
rm -rf result result-*
# Watch and run tests
watch:
cargo watch -x test
# Run example
example:
cargo run --example usage
# Check reproducibility with Nix
reproducible:
#!/usr/bin/env bash
set -e
echo "Building first time..."
nix build -L -o result-1
echo "Building second time..."
nix build -L -o result-2 --rebuild
echo "Comparing builds..."
if diff -r result-1 result-2; then
echo "✅ Builds are reproducible!"
else
echo "⚠️ Builds differ"
exit 1
fi
# Create a new release
release version:
#!/usr/bin/env bash
set -e
# Update version in Cargo.toml
cargo set-version {{version}}
# Commit changes
git add Cargo.toml Cargo.lock
git commit -m "chore: release v{{version}}"
# Create tag
git tag -a v{{version}} -m "Release v{{version}}"
echo "Release prepared. Run 'git push && git push --tags' to publish"
# Setup git hooks
setup:
./setup-hooks.sh
# Run CI locally with act
ci-local:
act -P ubuntu-latest=ubuntu:latest
# Generate changelog
changelog:
git log --pretty=format:"- %s (%h)" --reverse > CHANGELOG.md
# Sync file classification (Phase 2) and language detection heuristics (Phase 3) from GitHub Linguist
# Pure Rust implementation with no Python/Perl/Bash dependencies
sync-linguist:
#!/usr/bin/env bash
set -e
echo "🚀 Synchronizing patterns from GitHub Linguist (100% Rust)..."
echo ""
echo "Phase 2: File classification (vendor, generated, binary)"
echo "Phase 3: Language detection heuristics (ambiguous extensions)"
echo ""
# Run the Rust sync tool (writes outputs directly into src/)
cargo run --bin sync-linguist --features sync-tool
echo ""
echo "✅ Patterns synced!"
echo ""
echo "Next steps:"
echo " 1. cargo test"
echo " 2. cargo run --bin sync-linguist --features sync-tool 2>/dev/null | head -20 # Preview Phase 2"
echo " 3. git add src/file_classifier_generated.rs"
echo " 4. git commit -m 'chore(linguist): sync Phase 2 & 3 patterns'"
# Verify everything before PR
verify: fmt clippy test audit renovate-validate doc
@echo "✅ All checks passed!"
quality: fmt clippy test audit
@echo "✅ Quality checks passed!"
# Nix-specific commands
# Build Docker image with Nix
docker:
nix build .#docker
echo "Docker image built at: ./result"
# Enter Nix REPL
repl:
nix repl .
# Show flake info
info:
nix flake show
nix flake metadata
# Garbage collect Nix store
gc:
nix-collect-garbage -d
# Update a specific flake input
update-input input:
nix flake lock --update-input {{input}}
# Build and push to cachix (requires cachix setup)
cache:
nix build --json | jq -r '.[].outputs | to_entries[].value' | cachix push singularity-language-registry || true
# Generate release reports locally (simulates CI release reports)
release-reports:
#!/usr/bin/env bash
set -e
echo "Generating release reports..."
mkdir -p release-reports
# Clippy report (0 warnings tolerance)
echo "# Clippy Report - Zero Warnings Tolerance" > release-reports/clippy-report.md
echo "" >> release-reports/clippy-report.md
echo "**Date:** $(date -u +"%Y-%m-%d %H:%M:%S UTC")" >> release-reports/clippy-report.md
echo "## Configuration" >> release-reports/clippy-report.md
echo "- \`-D warnings\` - \`-W clippy::pedantic\` - \`-W clippy::nursery\`" >> release-reports/clippy-report.md
echo "\`\`\`" >> release-reports/clippy-report.md
cargo clippy --all-targets --all-features -- -D warnings -W clippy::pedantic -W clippy::nursery 2>&1 | tee -a release-reports/clippy-report.md
echo "\`\`\`" >> release-reports/clippy-report.md
# Security audit
echo "# Security Audit Report" > release-reports/security-audit.md
echo "" >> release-reports/security-audit.md
echo "**Date:** $(date -u +"%Y-%m-%d %H:%M:%S UTC")" >> release-reports/security-audit.md
echo "## Cargo Audit" >> release-reports/security-audit.md
echo "\`\`\`" >> release-reports/security-audit.md
cargo audit 2>&1 | tee -a release-reports/security-audit.md || true
echo "\`\`\`" >> release-reports/security-audit.md
echo "## Cargo Deny" >> release-reports/security-audit.md
echo "\`\`\`" >> release-reports/security-audit.md
cargo deny check 2>&1 | tee -a release-reports/security-audit.md || true
echo "\`\`\`" >> release-reports/security-audit.md
# SBOM
echo "# Software Bill of Materials" > release-reports/sbom.md
echo "" >> release-reports/sbom.md
echo "**Date:** $(date -u +"%Y-%m-%d %H:%M:%S UTC")" >> release-reports/sbom.md
echo "## Direct Dependencies" >> release-reports/sbom.md
echo "\`\`\`toml" >> release-reports/sbom.md
grep -A 100 '^\[dependencies\]' Cargo.toml | grep -B 100 '^\[' | head -n -1 >> release-reports/sbom.md
echo "\`\`\`" >> release-reports/sbom.md
echo "## Full Dependency Tree" >> release-reports/sbom.md
echo "\`\`\`" >> release-reports/sbom.md
cargo tree --all-features >> release-reports/sbom.md
echo "\`\`\`" >> release-reports/sbom.md
# Coverage
echo "# Test Coverage Report" > release-reports/coverage-report.md
echo "" >> release-reports/coverage-report.md
echo "**Date:** $(date -u +"%Y-%m-%d %H:%M:%S UTC")" >> release-reports/coverage-report.md
echo "\`\`\`" >> release-reports/coverage-report.md
cargo tarpaulin --all-features --out Stdout 2>&1 | tee -a release-reports/coverage-report.md || true
echo "\`\`\`" >> release-reports/coverage-report.md
# Copy user-focused AGENTS.md for release
echo "🤖 Including user-focused AGENTS.md for release..."
cp AGENTS.md.release release-reports/AGENTS.md
echo ""
echo "✅ Reports generated in ./release-reports/"
echo " - clippy-report.md"
echo " - security-audit.md"
echo " - sbom.md"
echo " - coverage-report.md"
echo " - AGENTS.md (user-focused)"