-
Notifications
You must be signed in to change notification settings - Fork 1
443 lines (384 loc) · 14.7 KB
/
ci.yml
File metadata and controls
443 lines (384 loc) · 14.7 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
# yaml-language-server: $schema=https://www.schemastore.org/github-workflow.json
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
# Nightly at midnight UTC (for coverage)
- cron: "0 0 * * *"
# Cancel in-progress runs when new commits are pushed
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Default to read-only permissions
permissions:
contents: read
pull-requests: read
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
# Validate conventional commit messages
commits:
name: Commit Messages
runs-on: ubuntu-latest
# Only run on pull requests - push to main is already validated
if: github.event_name == 'pull_request'
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
with:
egress-policy: audit
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Validate PR title
uses: step-security/action-semantic-pull-request@bc0cf74f5be4ce34accdec1ae908dff38dc5def1 # v6.1.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
types: |
feat
fix
docs
style
refactor
perf
test
build
ci
chore
revert
dx
ai
imp
requireScope: false
subjectPattern: ^[a-z].*$
subjectPatternError: |
The subject "{subject}" must start with a lowercase letter.
Example: "feat: add user authentication" or "fix(api): handle empty requests"
# Check code formatting
fmt:
name: Formatting
runs-on: ubuntu-latest
if: github.actor != 'dependabot[bot]'
permissions:
contents: read
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
with:
egress-policy: audit
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Rust nightly toolchain
uses: dtolnay/rust-toolchain@0b1efabc08b657293548b77fb76cc02d26091c7e # master
with:
toolchain: nightly
components: rustfmt
- name: Check formatting
run: cargo +nightly fmt --all -- --check
# Run Clippy for linting
clippy:
name: Linting
runs-on: ubuntu-latest
if: github.actor != 'dependabot[bot]'
permissions:
contents: read
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-C codegen-units=16 -C link-arg=-fuse-ld=mold"
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
with:
egress-policy: audit
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
with:
toolchain: stable
components: clippy
- name: Install development tools via Mise
uses: step-security/mise-action@d65cf9dcb78b983ae2530c89fd28e72286713505 # v3.5.1
with:
install_args: protobuf
cache: true
- name: Install mold linker
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq mold
mold --version
- name: Cache Rust dependencies
uses: step-security/rust-cache@9be15b830520fab0ec3939586e917e4855cf76bd # v2.8.3
with:
shared-key: management-ubuntu-latest-x86_64-unknown-linux-gnu
save-if: false
- name: Run clippy
run: cargo clippy --workspace --all-targets --all-features -- -D warnings
# Run tests on multiple platforms
test:
name: Test (${{ matrix.name }})
needs: [fmt, clippy]
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
name: Linux AMD64
- runner: ubuntu-24.04-arm
name: Linux ARM64
- runner: macos-latest
name: macOS Apple Silicon
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
with:
egress-policy: audit
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
with:
toolchain: stable
- name: Install mold linker (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq mold
- name: Install protobuf compiler (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get install -y -qq protobuf-compiler
- name: Install protobuf compiler (macOS)
if: runner.os == 'macOS'
run: |
brew install protobuf
- name: Install cargo-nextest
uses: taiki-e/install-action@650c5ca14212efbbf3e580844b04bdccf68dac31 # v2.67.18
with:
tool: cargo-nextest
- name: Cache Rust dependencies
uses: step-security/rust-cache@9be15b830520fab0ec3939586e917e4855cf76bd # v2.8.3
with:
shared-key: test-${{ matrix.runner }}
- name: Run unit tests
env:
RUSTFLAGS: ${{ runner.os == 'Linux' && '-C codegen-units=16 -C link-arg=-fuse-ld=mold' || '' }}
run: cargo nextest run --workspace --profile ci
- name: Run doc tests
run: cargo test --workspace --doc
# Ledger Integration Tests
# Runs Control tests against a real Ledger server to verify storage backend integration.
# Uses Docker Compose to start a single-node Ledger cluster, then runs native cargo tests.
ledger-integration-tests:
name: Ledger Integration Tests
needs: [fmt, clippy]
runs-on: ubuntu-latest
permissions:
contents: read
timeout-minutes: 10
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-C codegen-units=16 -C link-arg=-fuse-ld=mold"
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
with:
egress-policy: audit
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
with:
toolchain: stable
- name: Install mold linker
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq mold
- name: Install development tools via Mise
uses: step-security/mise-action@d65cf9dcb78b983ae2530c89fd28e72286713505 # v3.5.1
with:
install_args: protobuf cargo:cargo-nextest
cache: true
- name: Cache Rust dependencies
uses: step-security/rust-cache@9be15b830520fab0ec3939586e917e4855cf76bd # v2.8.3
with:
shared-key: management-ubuntu-latest-x86_64-unknown-linux-gnu
save-if: false
- name: Start Ledger server
working-directory: docker/ledger-integration-tests
run: |
docker compose up -d ledger
echo "Waiting for Ledger to be ready..."
# Wait for metrics endpoint to be available (indicates server is running)
# Then add delay for Raft bootstrap to complete
for i in {1..30}; do
if curl -sf http://localhost:9092/metrics > /dev/null 2>&1; then
echo "Ledger metrics endpoint is available"
# Give Raft a moment to fully bootstrap after server starts
sleep 3
echo "Ledger should be ready!"
break
fi
echo "Attempt $i/30: Ledger not ready yet..."
sleep 2
done
# Final check - metrics endpoint must be available
curl -sf http://localhost:9092/metrics > /dev/null || (docker compose logs ledger && exit 1)
- name: Run Ledger integration tests
env:
LEDGER_ENDPOINT: "http://localhost:50052"
RUST_BACKTRACE: "1"
run: |
cargo nextest run \
--package inferadb-control-storage \
--features integration \
--test ledger_integration_tests \
--profile ci \
--no-fail-fast
- name: Stop Ledger server
if: always()
working-directory: docker/ledger-integration-tests
run: docker compose down -v
# Test code coverage (nightly only to reduce CI costs)
coverage:
name: Code Coverage
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'schedule'
continue-on-error: true
permissions:
contents: read
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-C codegen-units=16 -C link-arg=-fuse-ld=mold"
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
with:
egress-policy: audit
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
with:
toolchain: stable
- name: Install mold linker
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq mold
mold --version
- name: Install development tools via Mise
uses: step-security/mise-action@d65cf9dcb78b983ae2530c89fd28e72286713505 # v3.5.1
with:
install_args: protobuf cargo:cargo-llvm-cov
cache: true
- name: Restore build cache
uses: step-security/rust-cache@9be15b830520fab0ec3939586e917e4855cf76bd # v2.8.3
with:
shared-key: management-ubuntu-latest-x86_64-unknown-linux-gnu
save-if: false # Don't save, only restore from build job
- name: Generate coverage
run: cargo llvm-cov --workspace --lcov --output-path lcov.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
with:
files: lcov.info
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
# Check dependencies (main branch only - informational, not blocking PRs)
dependencies:
name: Dependencies
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
permissions:
contents: read
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
with:
egress-policy: audit
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Rust toolchain (stable + nightly for udeps)
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
with:
toolchain: stable
- name: Install Rust nightly toolchain (for cargo-udeps)
uses: dtolnay/rust-toolchain@0b1efabc08b657293548b77fb76cc02d26091c7e # master
with:
toolchain: nightly
- name: Install cargo-outdated
uses: taiki-e/install-action@650c5ca14212efbbf3e580844b04bdccf68dac31 # v2.67.18
with:
tool: cargo-outdated
- name: Install cargo-udeps
uses: taiki-e/install-action@650c5ca14212efbbf3e580844b04bdccf68dac31 # v2.67.18
with:
tool: cargo-udeps
- name: Cache Rust dependencies
uses: step-security/rust-cache@9be15b830520fab0ec3939586e917e4855cf76bd # v2.8.3
- name: Check outdated dependencies
run: cargo outdated --exit-code 1 || echo "Some dependencies are outdated"
- name: Check for unused dependencies
run: cargo +nightly udeps --workspace --all-targets || echo "Some dependencies may be unused"
- name: Check for duplicate dependencies
run: cargo tree --duplicates
# Overall status check
ci-success:
name: CI Success
needs: [commits, fmt, clippy, test, ledger-integration-tests, coverage, dependencies]
runs-on: ubuntu-latest
permissions:
contents: read
if: always()
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
with:
egress-policy: audit
- name: Check all jobs
run: |
# Commits check is only required on PRs
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
if [[ "${{ needs.commits.result }}" != "success" ]]; then
echo "Commit message validation failed"
echo "PR title must follow Conventional Commits format:"
echo " <type>(<scope>): <description>"
echo " Examples: 'feat: add new feature' or 'fix(api): handle edge case'"
exit 1
fi
fi
# Format and Clippy can be skipped for Dependabot PRs
if [[ "${{ needs.fmt.result }}" != "success" && "${{ needs.fmt.result }}" != "skipped" ]]; then
echo "Format check failed"
exit 1
fi
if [[ "${{ needs.clippy.result }}" != "success" && "${{ needs.clippy.result }}" != "skipped" ]]; then
echo "Clippy check failed"
exit 1
fi
# Test job runs on multiple platforms
if [[ "${{ needs.test.result }}" != "success" && "${{ needs.test.result }}" != "skipped" ]]; then
echo "Tests failed"
exit 1
fi
# Ledger integration tests verify storage backend
if [[ "${{ needs.ledger-integration-tests.result }}" != "success" && "${{ needs.ledger-integration-tests.result }}" != "skipped" ]]; then
echo "Ledger integration tests failed"
exit 1
fi
# Coverage and dependencies are optional (skipped on PRs or non-main branches)
if [[ "${{ needs.coverage.result }}" == "failure" ]]; then
echo "::warning::Coverage check failed (non-blocking)"
fi
if [[ "${{ needs.dependencies.result }}" == "failure" ]]; then
echo "::warning::Dependencies check failed (non-blocking)"
fi
echo "All required checks passed!"