-
Notifications
You must be signed in to change notification settings - Fork 2
354 lines (303 loc) · 10 KB
/
Copy pathci.yml
File metadata and controls
354 lines (303 loc) · 10 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
name: CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
concurrency:
group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
RUSTFLAGS: -C debuginfo=0
jobs:
msrv:
name: MSRV Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Rust (MSRV)
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.92
- uses: Swatinem/rust-cache@v2
- name: Check MSRV compatibility
run: cargo check --workspace --all-features
build:
name: Build & Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v6
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Use larger writable target dir on Linux
if: runner.os == 'Linux'
run: echo "CARGO_TARGET_DIR=${RUNNER_TEMP}/target" >> "$GITHUB_ENV"
- uses: Swatinem/rust-cache@v2
if: runner.os == 'Linux'
with:
cache-directories: ${{ runner.temp }}/target
- uses: Swatinem/rust-cache@v2
if: runner.os != 'Linux'
- name: Run tests
run: cargo test --all-features --verbose
env:
CI: true
build-macos:
name: Build & Test (macOS)
if: github.event_name == 'push'
runs-on: macos-latest
steps:
- uses: actions/checkout@v6
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Run tests
run: cargo test --all-features --verbose
env:
CI: true
feature-boundaries:
name: Feature Boundaries
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
cache-directories: ${{ runner.temp }}/target
- name: tokmd-analysis with all features
run: cargo test -p tokmd-analysis --all-features --verbose
env:
CI: true
- name: tokmd-analysis with no default features
run: cargo test -p tokmd-analysis --no-default-features --verbose
env:
CI: true
- name: Guard analysis microcrate boundaries
run: cargo xtask boundaries-check
wasm-compile:
name: Wasm Compile & Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- uses: actions/setup-node@v6
- uses: taiki-e/install-action@v2
with:
tool: wasm-pack
- uses: Swatinem/rust-cache@v2
- name: Check tokmd-scan for wasm32
run: cargo check -p tokmd-scan --target wasm32-unknown-unknown
- name: Check tokmd-core analysis for wasm32
run: cargo check -p tokmd-core --features analysis --target wasm32-unknown-unknown
- name: Check tokmd-wasm core-only for wasm32
run: cargo check -p tokmd-wasm --no-default-features --target wasm32-unknown-unknown
- name: Check tokmd-wasm for wasm32
run: cargo check -p tokmd-wasm --features analysis --target wasm32-unknown-unknown
- name: Run tokmd-wasm core-only wasm tests
run: wasm-pack test --node crates/tokmd-wasm --no-default-features
- name: Run tokmd-wasm analysis wasm tests
run: wasm-pack test --node crates/tokmd-wasm --features analysis
- name: Build browser runner wasm bundle
run: npm --prefix web/runner run build:wasm
- name: Browser runner protocol and wasm boot smoke
run: npm --prefix web/runner test
- name: Browser runner syntax check
run: npm --prefix web/runner run check
gate:
name: Quality Gate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- name: Use larger writable target dir on Linux
if: runner.os == 'Linux'
run: echo "CARGO_TARGET_DIR=${RUNNER_TEMP}/target" >> "$GITHUB_ENV"
- uses: Swatinem/rust-cache@v2
- name: Run quality gate
run: cargo xtask gate --check
deny:
name: Cargo Deny
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: taiki-e/install-action@v2
with:
tool: cargo-deny@0.19.0
- name: Print cargo-deny version
run: cargo deny --version
- name: Check advisories and licenses
run: cargo deny --all-features check
typos:
name: Typos
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: crate-ci/typos@v1
proptest-smoke:
name: Proptest Smoke
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Run property tests (reduced iterations)
run: |
PROPTEST_CASES=50 cargo test -p tokmd-model --test properties --all-features --verbose
PROPTEST_CASES=50 cargo test -p tokmd-types --test properties --all-features --verbose
PROPTEST_CASES=50 cargo test -p tokmd --test properties --all-features --verbose
env:
CI: true
publish-plan:
name: Publish Surface
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Verify publish surface and dry-run checks
run: cargo xtask publish-surface --json --verify-publish
env:
CI: true
version-consistency:
name: Version consistency
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- name: Check release metadata alignment
run: cargo xtask version-consistency
docs-check:
name: Docs Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Check documentation drift
run: cargo xtask docs --check
env:
CI: true
nix-pr:
name: Nix PR Package Gate
runs-on: ubuntu-latest
timeout-minutes: 60
permissions:
contents: read
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
steps:
- uses: actions/checkout@v6
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v22
- name: Setup Nix cache
continue-on-error: true
uses: DeterminateSystems/magic-nix-cache-action@v13
with:
use-flakehub: false
use-gha-cache: enabled
- name: Check flake
run: nix flake check --no-build --accept-flake-config
- name: Build package
run: nix build -L .#tokmd
mutation:
name: Mutation Testing (Required)
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
- name: Install cargo-mutants
run: cargo install cargo-mutants --version 26.1.2 --locked
- name: Get changed Rust files
id: changed
run: |
set -euo pipefail
git fetch origin "${{ github.base_ref }}":"refs/remotes/origin/${{ github.base_ref }}" || true
git diff --name-only "origin/${{ github.base_ref }}...HEAD" -- '*.rs' \
| grep -v '/tests/' \
| grep -v '_test\.rs$' \
| grep -v '^fuzz/' \
| grep -v '/fuzz/' \
> changed_files.txt || true
COUNT="$(wc -l < changed_files.txt | tr -d ' ')"
echo "count=$COUNT" >> "$GITHUB_OUTPUT"
echo "files<<EOF" >> "$GITHUB_OUTPUT"
cat changed_files.txt >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
- name: Mutation Testing
if: steps.changed.outputs.count != '0'
env:
CI: true
run: |
set -euo pipefail
echo "Running mutation testing on ${{ steps.changed.outputs.count }} changed file(s)..."
while IFS= read -r file; do
[ -z "$file" ] && continue
[ -f "$file" ] || continue
# Microcrate dividend: run from crate dir when possible
crate_dir=""
if [[ "$file" == crates/*/* ]]; then
crate_dir="$(echo "$file" | cut -d/ -f1-2)"
fi
echo "::group::Mutants: $file"
if [[ -n "$crate_dir" && -f "$crate_dir/Cargo.toml" ]]; then
rel="${file#$crate_dir/}"
(cd "$crate_dir" && cargo mutants --file "$rel" --timeout 300)
else
cargo mutants --file "$file" --timeout 300
fi
echo "::endgroup::"
done < changed_files.txt
echo "✓ All mutations caught or unviable (0 MISSED)"
- name: Skip notice
if: steps.changed.outputs.count == '0'
run: echo "No production Rust files changed - skipping mutation testing"
- name: Upload mutants report
if: always()
uses: actions/upload-artifact@v7
with:
name: mutants-report
path: |
mutants.out/
crates/**/mutants.out/
if-no-files-found: ignore
retention-days: 14
ci-required:
name: CI (Required)
runs-on: ubuntu-latest
if: always()
needs:
- msrv
- build
- build-macos
- gate
- deny
- wasm-compile
- typos
- proptest-smoke
- publish-plan
- version-consistency
- docs-check
- nix-pr
- mutation
- feature-boundaries
steps:
- name: Check overall status
run: |
# If any needed job failed or was cancelled, fail this job
if [[ "${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
echo "One or more required jobs failed or were cancelled."
exit 1
fi
echo "All required jobs passed (or were skipped)."