forked from Dicklesworthstone/beads_rust
-
Notifications
You must be signed in to change notification settings - Fork 0
363 lines (304 loc) · 11.2 KB
/
ci.yml
File metadata and controls
363 lines (304 loc) · 11.2 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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
# Cancel in-progress runs for the same branch
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
permissions:
contents: read
jobs:
check:
name: Check
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
components: rustfmt, clippy
- name: Cache cargo
uses: Swatinem/rust-cache@ad397744b0d591a723ab90405b7247fac0e6b8db # v2
- name: Check formatting
run: cargo fmt --all -- --check
- name: Clippy (all features)
run: cargo clippy --all-targets --all-features
- name: Clippy (no default features)
run: cargo clippy --all-targets --no-default-features
- name: Check (all targets)
run: cargo check --all-targets --all-features
security:
name: Security Audit
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install cargo-audit
uses: taiki-e/install-action@0bc4cd8a3e21db4cb9519857377b0c8c5e150de5 # v2
with:
tool: cargo-audit
- name: Security audit
run: cargo audit --deny warnings
continue-on-error: true # Advisory-only for now
- name: Check for yanked dependencies
run: cargo audit --deny yanked
test:
name: Test Suite
runs-on: ubuntu-latest
timeout-minutes: 20
needs: check
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
- name: Cache cargo
uses: Swatinem/rust-cache@ad397744b0d591a723ab90405b7247fac0e6b8db # v2
- name: Run all tests (all features)
run: cargo test --all-features -- --nocapture
env:
RUST_LOG: beads_rust=debug
- name: Run tests (no default features)
run: cargo test --no-default-features
- name: Run doc tests
run: cargo test --doc
coverage:
name: Code Coverage
runs-on: ubuntu-latest
timeout-minutes: 30
needs: test
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
components: llvm-tools-preview
- name: Cache cargo
uses: Swatinem/rust-cache@ad397744b0d591a723ab90405b7247fac0e6b8db # v2
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@0bc4cd8a3e21db4cb9519857377b0c8c5e150de5 # v2
with:
tool: cargo-llvm-cov
- name: Generate coverage report
run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
continue-on-error: true
- name: Upload coverage to Codecov
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4
with:
files: lcov.info
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
build:
name: Build (${{ matrix.name }})
runs-on: ${{ matrix.os }}
timeout-minutes: 30
needs: check
strategy:
fail-fast: false
matrix:
include:
# Linux x64 (glibc)
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
name: linux-x64
# Linux ARM64 (native runner - 10x faster than QEMU)
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
name: linux-arm64
# macOS Apple Silicon (native)
- os: macos-14
target: aarch64-apple-darwin
name: macos-arm64
# macOS Intel
- os: macos-15
target: x86_64-apple-darwin
name: macos-x64
# Windows x64
- os: windows-latest
target: x86_64-pc-windows-msvc
name: windows-x64
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
targets: ${{ matrix.target }}
- name: Cache cargo
uses: Swatinem/rust-cache@ad397744b0d591a723ab90405b7247fac0e6b8db # v2
with:
key: ${{ runner.os }}-${{ runner.arch }}-${{ matrix.target }}
- name: Build release binary
run: cargo build --release --target ${{ matrix.target }}
- name: Verify binary runs (Unix)
if: runner.os != 'Windows'
run: ./target/${{ matrix.target }}/release/br --version
- name: Verify binary runs (Windows)
if: runner.os == 'Windows'
run: ./target/${{ matrix.target }}/release/br.exe --version
- name: Upload artifact (Unix)
if: runner.os != 'Windows'
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: br-${{ matrix.name }}
path: target/${{ matrix.target }}/release/br
- name: Upload artifact (Windows)
if: runner.os == 'Windows'
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: br-${{ matrix.name }}
path: target/${{ matrix.target }}/release/br.exe
bench:
name: Benchmarks
runs-on: ubuntu-latest
timeout-minutes: 20
needs: check
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
- name: Cache cargo
uses: Swatinem/rust-cache@ad397744b0d591a723ab90405b7247fac0e6b8db # v2
- name: Restore criterion baseline cache
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: target/criterion/
key: ${{ runner.os }}-${{ runner.arch }}-criterion-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-criterion-
- name: Snapshot benchmark baseline (if present)
run: |
if [ -d target/criterion ]; then
mkdir -p target/criterion_prev
cp -a target/criterion/. target/criterion_prev/
fi
- name: Run benchmarks
run: |
set -euo pipefail
if find target/criterion -path "*/main/estimates.json" -type f 2>/dev/null | grep -q .; then
cargo bench --bench benchmarks -- --baseline main --save-baseline main
else
cargo bench --bench benchmarks -- --save-baseline main
fi
continue-on-error: true
- name: Check benchmark regressions (10% threshold)
run: |
python3 - <<'PY'
import glob
import json
import os
import sys
threshold = 1.10
prev_root = "target/criterion_prev"
curr_root = "target/criterion"
if not os.path.isdir(prev_root):
print("benchmark_regression: no previous baseline; skipping")
sys.exit(0)
prev_files = glob.glob(os.path.join(prev_root, "**", "main", "estimates.json"), recursive=True)
if not prev_files:
print("benchmark_regression: no baseline estimates; skipping")
sys.exit(0)
regressions = []
for prev_path in prev_files:
rel = os.path.relpath(prev_path, prev_root)
curr_path = os.path.join(curr_root, rel)
if not os.path.exists(curr_path):
continue
with open(prev_path, "r", encoding="utf-8") as fh:
prev = json.load(fh)
with open(curr_path, "r", encoding="utf-8") as fh:
curr = json.load(fh)
prev_mean = prev.get("mean", {}).get("point_estimate", 0.0)
curr_mean = curr.get("mean", {}).get("point_estimate", 0.0)
if prev_mean <= 0:
continue
ratio = curr_mean / prev_mean
if ratio > threshold:
regressions.append((rel, prev_mean, curr_mean, ratio))
if regressions:
print("benchmark_regression: failures (mean > 10% slower)")
for rel, prev_mean, curr_mean, ratio in regressions:
print(f" {rel}: prev={prev_mean:.2f} curr={curr_mean:.2f} ratio={ratio:.2f}")
sys.exit(1)
print("benchmark_regression: ok")
PY
- name: Upload benchmark results
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: benchmark-results
path: target/criterion/
if-no-files-found: ignore
- name: Save criterion baseline cache
if: always()
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: target/criterion/
key: ${{ runner.os }}-${{ runner.arch }}-criterion-${{ github.run_id }}
# Verify version auditing info is correctly embedded
version-audit:
name: Version Audit
runs-on: ubuntu-latest
timeout-minutes: 10
needs: build
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Download Linux artifact
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: br-linux-x64
path: ./bin
- name: Make binary executable
run: chmod +x ./bin/br
- name: Verify version info
run: |
echo "=== Version output ==="
./bin/br --version
echo ""
echo "=== Checking for build info ==="
VERSION_OUTPUT=$(./bin/br --version 2>&1 || true)
if echo "$VERSION_OUTPUT" | grep -q "br\|beads"; then
echo "Version info present"
else
echo "Warning: Version output may be missing expected info"
fi
e2e-quick:
name: Quick E2E
runs-on: ubuntu-latest
timeout-minutes: 10
needs: check
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
- name: Cache cargo
uses: Swatinem/rust-cache@ad397744b0d591a723ab90405b7247fac0e6b8db # v2
- name: Run quick E2E tests
run: scripts/e2e.sh
env:
NO_COLOR: 1
HARNESS_ARTIFACTS: 1
- name: Upload E2E summary
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: e2e-quick-summary
path: target/test-artifacts/e2e_quick_summary.json
if-no-files-found: ignore