-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
206 lines (181 loc) · 7.18 KB
/
justfile
File metadata and controls
206 lines (181 loc) · 7.18 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
# smb2 Development Commands
# =========================
#
# Available commands (run `just --list` for details):
#
# Individual checks:
# fmt - Format code with cargo fmt
# fmt-check - Check formatting (CI mode)
# clippy - Run clippy with -D warnings
# test - Run tests
# doc - Build documentation
# msrv - Check MSRV (1.85) compatibility
# audit - Security audit (requires cargo-audit)
# deny - License/dependency check (requires cargo-deny)
# udeps - Find unused dependencies (requires nightly + cargo-udeps)
#
# Composite commands:
# check - Run fast checks: fmt-check, clippy, test, doc (default)
# check-all - Run all checks including audit and deny
# fix - Auto-fix formatting and clippy warnings
#
# Utility commands:
# clean - Remove build artifacts
# install-tools - Install required development tools
#
# MSRV: 1.85
set shell := ["bash", "-uc"]
# Default recipe - run fast checks
default: check
# ==============================================================================
# Individual Checks
# ==============================================================================
# Format code with cargo fmt
fmt:
@echo "[*] Formatting..."
@cargo fmt
@echo "[+] Formatted"
# Check formatting without modifying files (for CI)
fmt-check:
@echo "[*] Checking formatting..."
@cargo fmt --check
@echo "[+] Formatting OK"
# Run clippy with strict warnings
clippy:
@echo "[*] Running clippy..."
@cargo clippy --all-targets --quiet -- -D warnings
@echo "[+] Clippy passed"
# Run tests
test:
@echo "[*] Running tests..."
@cargo test --quiet
@echo "[+] Tests passed"
# Run integration tests against real SMB servers (requires NAS + Pi on LAN)
test-integration:
@echo "[*] Running integration tests..."
@cargo test --test integration -- --ignored --quiet
@echo "[+] Integration tests passed"
# Run Docker integration tests (starts/stops containers automatically)
test-docker:
@echo "[*] Starting Docker containers..."
@./tests/docker/start.sh internal
@echo "[*] Running Docker integration tests..."
@cargo test --test docker_integration -- --ignored --quiet && \
(echo "[*] Stopping Docker containers..." && ./tests/docker/stop.sh && echo "[+] Docker integration tests passed") || \
(echo "[*] Stopping Docker containers..." && ./tests/docker/stop.sh && exit 1)
# Run consumer integration tests (starts/stops containers automatically)
test-consumer:
@echo "[*] Starting consumer containers..."
@./tests/docker/start.sh consumer
@echo "[*] Running consumer integration tests..."
@cargo test --features testing --test consumer_integration -- --ignored --quiet && \
(echo "[*] Stopping consumer containers..." && ./tests/docker/stop.sh && echo "[+] Consumer integration tests passed") || \
(echo "[*] Stopping consumer containers..." && ./tests/docker/stop.sh && exit 1)
# Build documentation
doc:
@echo "[*] Building docs..."
@cargo doc --no-deps --quiet
@echo "[+] Docs built"
# Check MSRV compatibility (requires rustup with 1.85 toolchain)
msrv:
@echo "[*] Checking MSRV (1.85) compatibility..."
@if ! rustup run 1.85.0 rustc --version &> /dev/null; then \
echo "[!] Rust 1.85 not found. Install with: rustup toolchain install 1.85.0"; \
exit 1; \
fi
@RUSTFLAGS="-D warnings" cargo +1.85.0 check --quiet
@cargo +1.85.0 clippy --all-targets --quiet -- -D warnings
@echo "[+] MSRV check passed"
# Run security audit (requires cargo-audit)
audit:
@echo "[*] Running security audit..."
@if ! command -v cargo-audit &> /dev/null; then \
echo "[!] cargo-audit not found. Install with: just install-tools"; \
exit 1; \
fi
@cargo audit --deny warnings
@echo "[+] Security audit passed"
# Run cargo-deny checks (requires cargo-deny)
deny:
@echo "[*] Running cargo-deny..."
@if ! command -v cargo-deny &> /dev/null; then \
echo "[!] cargo-deny not found. Install with: just install-tools"; \
exit 1; \
fi
@cargo deny --log-level error check
@echo "[+] Cargo deny passed"
# Find unused dependencies (requires nightly + cargo-udeps)
udeps:
@echo "[*] Checking for unused dependencies..."
@if ! command -v cargo-udeps &> /dev/null; then \
echo "[!] cargo-udeps not found. Install with: just install-tools"; \
exit 1; \
fi
@if ! rustup run nightly rustc --version &> /dev/null; then \
echo "[!] Nightly toolchain not found. Install with: rustup install nightly"; \
exit 1; \
fi
cargo +nightly udeps --all-targets
@echo "[+] No unused dependencies found"
# ==============================================================================
# Composite Commands
# ==============================================================================
# Run fast checks: fmt-check, clippy, test, doc
check: fmt-check clippy test doc
@echo ""
@echo "[+] All fast checks passed!"
# Run fast checks + integration tests against real servers
check-live: check test-integration
@echo ""
@echo "[+] All checks + integration tests passed!"
# Run all checks including slow ones: check + msrv + audit + deny
check-all: check msrv audit deny
@echo ""
@echo "[+] All checks passed!"
# Auto-fix formatting and clippy warnings
fix: fmt
@echo "[*] Running clippy --fix..."
@cargo clippy --all-targets --fix --allow-dirty --allow-staged --quiet -- -D warnings
@echo "[+] Fixed"
# ==============================================================================
# Utility Commands
# ==============================================================================
# Remove build artifacts
clean:
@echo "[*] Cleaning build artifacts..."
cargo clean
@echo "[+] Clean complete"
# Run a single fuzz target for a short sweep (default: 5 minutes).
# Example: `just fuzz fuzz_header_parse` or `just fuzz fuzz_frame_parse 1800`.
# Requires the nightly toolchain and `cargo-fuzz` (run `cargo install cargo-fuzz`).
fuzz target duration="300":
@if ! rustup run nightly rustc --version &> /dev/null; then \
echo "[!] Nightly toolchain not found. Install with: rustup toolchain install nightly"; \
exit 1; \
fi
@if ! command -v cargo-fuzz &> /dev/null; then \
echo "[!] cargo-fuzz not found. Install with: cargo install cargo-fuzz"; \
exit 1; \
fi
@echo "[*] Fuzzing {{target}} for {{duration}}s..."
cargo +nightly fuzz run {{target}} -- -max_total_time={{duration}} -print_final_stats=1
# Regenerate the committed seed corpus under `fuzz/corpus/`.
fuzz-seeds:
@echo "[*] Regenerating fuzz seed corpus..."
@cargo test --test fuzz_seeds -- --ignored --nocapture
@echo "[+] Seed corpus updated"
# Install required development tools
install-tools:
@echo "[*] Installing development tools..."
@echo ""
@echo "Installing cargo-audit..."
cargo install cargo-audit
@echo ""
@echo "Installing cargo-deny..."
cargo install cargo-deny
@echo ""
@echo "Installing cargo-udeps (requires nightly)..."
rustup install nightly
cargo install cargo-udeps
@echo ""
@echo "[+] All tools installed"