-
Notifications
You must be signed in to change notification settings - Fork 2
538 lines (462 loc) · 15.6 KB
/
Copy pathci.yml
File metadata and controls
538 lines (462 loc) · 15.6 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
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
schedule:
# Weekly dependency security check
- cron: '0 0 * * 0'
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUST_BACKTRACE: short
RUSTFLAGS: "-D warnings"
RUSTUP_MAX_RETRIES: 10
# Default to minimal permissions (security best practice)
permissions:
contents: read
# Cancel previous runs on new push
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# Detect which files changed to optimize job execution
changes:
name: Detect Changes
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
rust: ${{ steps.filter.outputs.rust }}
python: ${{ steps.filter.outputs.python }}
node: ${{ steps.filter.outputs.node }}
ci: ${{ steps.filter.outputs.ci }}
docs: ${{ steps.filter.outputs.docs }}
steps:
- uses: actions/checkout@v7
- uses: dorny/paths-filter@v4
id: filter
with:
filters: |
rust:
- '**/*.rs'
- '**/Cargo.toml'
- '**/Cargo.lock'
- 'deny.toml'
- 'clippy.toml'
- 'rustfmt.toml'
python:
- 'crates/exarch-python/**'
- 'crates/exarch-core/**'
- 'Cargo.toml'
- 'Cargo.lock'
node:
- 'crates/exarch-node/**'
- 'crates/exarch-core/**'
- 'Cargo.toml'
- 'Cargo.lock'
ci:
- '.github/workflows/**'
- '.github/labeler.yml'
docs:
- '**/*.md'
- '**/README.md'
# Quick checks first - fail fast
format:
name: Format Check
runs-on: ubuntu-latest
timeout-minutes: 5
needs: changes
if: |
needs.changes.outputs.rust == 'true' ||
github.ref == 'refs/heads/main' ||
github.ref == 'refs/heads/develop'
steps:
- uses: actions/checkout@v7
- name: Install nightly Rust
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- name: Check formatting
run: cargo +nightly fmt --all -- --check
clippy:
name: Clippy
runs-on: ubuntu-latest
timeout-minutes: 15
needs: changes
if: |
needs.changes.outputs.rust == 'true' ||
github.ref == 'refs/heads/main' ||
github.ref == 'refs/heads/develop'
steps:
- uses: actions/checkout@v7
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Cache Cargo dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "clippy"
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Run Clippy
run: cargo clippy --workspace --all-targets --all-features -- -D warnings
documentation:
name: Documentation
runs-on: ubuntu-latest
timeout-minutes: 15
needs: changes
if: |
needs.changes.outputs.rust == 'true' ||
github.ref == 'refs/heads/main' ||
github.ref == 'refs/heads/develop'
steps:
- uses: actions/checkout@v7
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Cache Cargo dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "doc"
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Check documentation
env:
RUSTDOCFLAGS: "-D warnings"
run: |
cargo doc --no-deps --all-features --workspace 2>&1 | tee /tmp/cargo-doc.log
# cargo emits target output-path collisions as a warning, not a rustdoc lint, so
# RUSTDOCFLAGS="-D warnings" above cannot catch it (see #429) — assert it separately.
if grep -q "output filename collision" /tmp/cargo-doc.log; then
echo "::error::cargo doc reported an output filename collision (see #429)"
exit 1
fi
# Security audit
security:
name: Security Audit
runs-on: ubuntu-latest
timeout-minutes: 10
needs: changes
if: |
needs.changes.outputs.rust == 'true' ||
github.ref == 'refs/heads/main' ||
github.ref == 'refs/heads/develop' ||
github.event_name == 'schedule'
steps:
- uses: actions/checkout@v7
- name: Run cargo-deny
uses: EmbarkStudios/cargo-deny-action@v2
with:
log-level: warn
command: check
arguments: --all-features
# Cross-platform tests with matrix
test:
name: Test (${{ matrix.os }})
needs: [changes, format]
runs-on: ${{ matrix.os }}
timeout-minutes: 30
if: |
needs.changes.outputs.rust == 'true' ||
github.ref == 'refs/heads/main' ||
github.ref == 'refs/heads/develop'
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v7
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Cache Cargo dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "test-${{ matrix.os }}"
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Install nextest
uses: taiki-e/install-action@v2.85.10
with:
tool: nextest
- name: Build all targets
run: cargo build --workspace --all-targets --all-features --exclude exarch-python --exclude exarch-node
- name: Run tests
run: cargo nextest run --workspace --all-features --no-fail-fast --exclude exarch-python --exclude exarch-node
- name: Run doctests
run: cargo test --doc --workspace --all-features --exclude exarch-python --exclude exarch-node
# Release-profile tests for exarch-core: exercises cfg(not(debug_assertions))
# tests (e.g. release-only redaction/security assertions) that the debug-mode
# `test` job above never runs (see #476).
test-release:
name: Test (release profile)
needs: [changes, format]
runs-on: ubuntu-latest
timeout-minutes: 20
if: |
needs.changes.outputs.rust == 'true' ||
github.ref == 'refs/heads/main' ||
github.ref == 'refs/heads/develop'
steps:
- uses: actions/checkout@v7
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Cache Cargo dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "test-release"
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Install nextest
uses: taiki-e/install-action@v2.85.10
with:
tool: nextest
- name: Run release-profile tests (exarch-core)
run: cargo nextest run -p exarch-core --release --all-features --no-fail-fast
# Test Python bindings with coverage
test-python:
name: Test Python ${{ matrix.python-version }}
needs: [changes, format]
runs-on: ubuntu-latest
timeout-minutes: 20
# always() + explicit needs.format.result check is required here: a job
# with `needs: [format]` is skipped by GitHub Actions whenever `format`
# itself is skipped (e.g. on a Python-only PR, where rust == 'false'),
# regardless of what this job's own `if` says, unless always() overrides
# that default gating.
if: |
always() &&
needs.changes.result == 'success' &&
(needs.format.result == 'success' || needs.format.result == 'skipped') &&
(needs.changes.outputs.python == 'true' ||
github.ref == 'refs/heads/main' ||
github.ref == 'refs/heads/develop')
strategy:
fail-fast: false
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
steps:
- uses: actions/checkout@v7
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Cache Cargo dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "python"
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Install dependencies
run: |
cd crates/exarch-python
uv pip install --system maturin "ruff==0.16.0" mypy pytest pytest-cov
- name: Run Rust unit tests (exarch-python)
run: cargo test -p exarch-python --lib --no-default-features
- name: Format check with ruff
run: |
cd crates/exarch-python
ruff format --check .
- name: Lint with ruff
run: |
cd crates/exarch-python
ruff check .
- name: Type check with mypy
run: |
cd crates/exarch-python
mypy . --ignore-missing-imports || true
- name: Build Python bindings
run: |
cd crates/exarch-python
# panic-injection exposes a deliberate-panic test hook used by the
# #395 regression test (test_panic_safety.py); never enabled for
# published wheels (see release.yml).
maturin build --release --features panic-injection,abi3
- name: Install Python bindings
run: uv pip install --system target/wheels/*.whl
- name: Test Python bindings
if: matrix.python-version != '3.12'
run: |
cd crates/exarch-python
pytest tests/ -v
# Coverage is only measured once (Python version doesn't change which
# lines of the Rust-backed bindings get exercised), so only one matrix
# leg uploads to Codecov — uploading all 5 would just duplicate the
# same flag's data and race codecov.yml's after_n_builds threshold.
- name: Test Python bindings with coverage
if: matrix.python-version == '3.12'
run: |
cd crates/exarch-python
pytest tests/ -v --cov --cov-report=xml:coverage.xml
- name: Upload Python coverage to Codecov
if: matrix.python-version == '3.12'
uses: codecov/codecov-action@v7
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: crates/exarch-python/coverage.xml
flags: exarch-python
fail_ci_if_error: false
# Test Node.js bindings with coverage
test-node:
name: Test Node.js Bindings
needs: [changes, format]
runs-on: ubuntu-latest
timeout-minutes: 20
if: |
always() &&
needs.changes.result == 'success' &&
(needs.format.result == 'success' || needs.format.result == 'skipped') &&
(needs.changes.outputs.node == 'true' ||
github.ref == 'refs/heads/main' ||
github.ref == 'refs/heads/develop')
steps:
- uses: actions/checkout@v7
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Cache Cargo dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "node"
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version: '20'
- name: Install dependencies
run: |
cd crates/exarch-node
npm install
- name: Run Rust unit tests (exarch-node)
run: cargo test -p exarch-node --lib
- name: Format check with Biome
run: |
cd crates/exarch-node
npm run format:check
- name: Lint with Biome
run: |
cd crates/exarch-node
npm run lint
- name: Build Node.js bindings
run: |
cd crates/exarch-node
npm run build
- name: Test Node.js bindings
run: |
cd crates/exarch-node
npm test
# Quick compile-only check for criterion benchmarks (does not run them)
bench-build:
name: Bench Build Check
needs: [changes, format]
runs-on: ubuntu-latest
timeout-minutes: 15
if: |
needs.changes.outputs.rust == 'true' ||
github.ref == 'refs/heads/main' ||
github.ref == 'refs/heads/develop'
steps:
- uses: actions/checkout@v7
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Cache Cargo dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "bench-build"
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Build benchmarks (compile only, does not run them)
run: cargo build --workspace --benches --all-features --exclude exarch-python --exclude exarch-node
# MSRV check (exarch-core only)
msrv:
name: MSRV Check (exarch-core)
needs: [changes, format]
runs-on: ubuntu-latest
timeout-minutes: 15
if: |
needs.changes.outputs.rust == 'true' ||
github.ref == 'refs/heads/main' ||
github.ref == 'refs/heads/develop'
steps:
- uses: actions/checkout@v7
- name: Install Rust 1.96.0
uses: dtolnay/rust-toolchain@master
with:
toolchain: "1.96.0"
- name: Cache Cargo dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "msrv"
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Check MSRV for exarch-core
run: cargo check -p exarch-core --all-features
# Code coverage (Linux only) - codecov auto-distributes by paths
coverage:
name: Code Coverage
needs: [changes, format]
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
if: |
needs.changes.outputs.rust == 'true' ||
github.ref == 'refs/heads/main' ||
github.ref == 'refs/heads/develop'
steps:
- uses: actions/checkout@v7
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Cache Cargo dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "coverage"
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@v2.85.10
with:
tool: cargo-llvm-cov
- name: Install nextest
uses: taiki-e/install-action@v2.85.10
with:
tool: nextest
- name: Generate coverage report
run: |
cargo llvm-cov --all-features --workspace \
--exclude exarch-python --exclude exarch-node \
--lcov --output-path lcov.info nextest
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v7
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: lcov.info
flags: exarch-core, exarch-cli
fail_ci_if_error: false
verbose: true
# All checks passed
ci-success:
name: CI Success
needs: [format, clippy, documentation, security, test, test-release, test-python, test-node, msrv, bench-build]
runs-on: ubuntu-latest
if: always()
steps:
- name: Check all jobs
run: |
# Required jobs that must pass
REQUIRED_JOBS=(
"${{ needs.format.result }}"
"${{ needs.clippy.result }}"
"${{ needs.documentation.result }}"
"${{ needs.security.result }}"
"${{ needs.test.result }}"
"${{ needs.test-release.result }}"
"${{ needs.test-python.result }}"
"${{ needs.test-node.result }}"
"${{ needs.msrv.result }}"
"${{ needs.bench-build.result }}"
)
for result in "${REQUIRED_JOBS[@]}"; do
if [[ "$result" != "success" && "$result" != "skipped" ]]; then
echo "Required job failed or was cancelled: $result"
exit 1
fi
done
echo "All required jobs passed successfully!"