-
Notifications
You must be signed in to change notification settings - Fork 1
355 lines (300 loc) · 11.5 KB
/
ci.yml
File metadata and controls
355 lines (300 loc) · 11.5 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
# yaml-language-server: $schema=https://www.schemastore.org/github-workflow.json
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
# Cancel in-progress runs for PRs, queue for main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
# Default to read-only permissions
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
# 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@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
with:
egress-policy: audit
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Install Rust nightly toolchain
uses: dtolnay/rust-toolchain@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@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
with:
egress-policy: audit
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
with:
toolchain: stable
components: clippy
- name: Install system dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq protobuf-compiler mold
protoc --version
mold --version
- name: Install FoundationDB client library
run: |
wget -q https://github.com/apple/foundationdb/releases/download/7.3.69/foundationdb-clients_7.3.69-1_amd64.deb
sudo dpkg -i foundationdb-clients_7.3.69-1_amd64.deb
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
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
# Build workspace once and cache for downstream jobs
build:
name: Build
runs-on: ubuntu-latest
permissions:
contents: read
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-C codegen-units=16 -C link-arg=-fuse-ld=mold"
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
with:
egress-policy: audit
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
with:
toolchain: stable
- name: Install system dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq protobuf-compiler mold
protoc --version
mold --version
- name: Install FoundationDB client library
run: |
wget -q https://github.com/apple/foundationdb/releases/download/7.3.69/foundationdb-clients_7.3.69-1_amd64.deb
sudo dpkg -i foundationdb-clients_7.3.69-1_amd64.deb
- name: Setup sccache
uses: mozilla-actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # v0.0.9
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
with:
shared-key: management-ubuntu-latest-x86_64-unknown-linux-gnu
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Build workspace (debug)
run: cargo build --workspace
- name: Build tests (no run)
run: cargo test --workspace --no-run
- name: Print sccache stats
run: sccache --show-stats
# Run tests (reuses build cache)
test:
name: Tests
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
checks: write # For test result publishing
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@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
with:
egress-policy: audit
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
with:
toolchain: stable
- name: Install system dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq protobuf-compiler mold
protoc --version
mold --version
- name: Install FoundationDB client library
run: |
wget -q https://github.com/apple/foundationdb/releases/download/7.3.69/foundationdb-clients_7.3.69-1_amd64.deb
sudo dpkg -i foundationdb-clients_7.3.69-1_amd64.deb
- name: Install cargo-nextest
uses: taiki-e/install-action@23cc4bc75a6e7b9f65e70281e10bcbe5da78c8c9 # v2.62.54
with:
tool: cargo-nextest
- name: Restore build cache
uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
with:
shared-key: management-ubuntu-latest-x86_64-unknown-linux-gnu
save-if: false # Don't save, only restore from build job
- name: Run tests with nextest
run: cargo nextest run --workspace --profile ci --no-fail-fast
- name: Run doc tests
run: cargo test --workspace --doc
- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action@34d7c956a59aed1bfebf31df77b8de55db9bbaaf # v2.21.0
if: always()
with:
files: target/nextest/ci/junit.xml
check_name: Test Results
comment_mode: off
- name: Upload test results
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
if: always()
with:
name: test-results-ubuntu
path: target/nextest/ci/junit.xml
retention-days: 7
# Test code coverage (reuses build cache)
coverage:
name: Code Coverage
needs: build
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@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
with:
egress-policy: audit
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
with:
toolchain: stable
- name: Install system dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq protobuf-compiler mold
protoc --version
mold --version
- name: Install FoundationDB client library
run: |
wget -q https://github.com/apple/foundationdb/releases/download/7.3.69/foundationdb-clients_7.3.69-1_amd64.deb
sudo dpkg -i foundationdb-clients_7.3.69-1_amd64.deb
- name: Install cargo-tarpaulin
uses: taiki-e/install-action@23cc4bc75a6e7b9f65e70281e10bcbe5da78c8c9 # v2.62.54
with:
tool: cargo-tarpaulin
- name: Restore build cache
uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
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 tarpaulin --workspace --timeout 300 --out xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@26ab1fa0e55b0bbe01d9e3f3a0729cf74f8bd07b # v5.5.1
with:
files: ./cobertura.xml
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
# Check dependencies
dependencies:
name: Dependencies
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@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
with:
egress-policy: audit
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
with:
toolchain: stable
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
- name: Check outdated dependencies
run: |
cargo install cargo-outdated
cargo outdated --exit-code 1 || echo "Some dependencies are outdated"
- name: Check for duplicate dependencies
run: cargo tree --duplicates
# Overall status check
ci-success:
name: CI Success
needs: [fmt, clippy, build, test, 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@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
with:
egress-policy: audit
- name: Check all jobs
run: |
# 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
# Build and test are always required
if [[ "${{ needs.build.result }}" != "success" ]]; then
echo "Build failed"
exit 1
fi
if [[ "${{ needs.test.result }}" != "success" ]]; then
echo "Tests failed"
exit 1
fi
# Coverage and dependencies can be skipped for Dependabot PRs
if [[ "${{ needs.coverage.result }}" != "success" && "${{ needs.coverage.result }}" != "skipped" ]]; then
echo "Coverage check failed"
exit 1
fi
if [[ "${{ needs.dependencies.result }}" != "success" && "${{ needs.dependencies.result }}" != "skipped" ]]; then
echo "Dependencies check failed"
exit 1
fi
echo "All required checks passed!"