-
Notifications
You must be signed in to change notification settings - Fork 58
400 lines (341 loc) · 13 KB
/
Copy pathci.yml
File metadata and controls
400 lines (341 loc) · 13 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
name: CI
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
permissions:
contents: read
env:
RUST_BACKTRACE: 1
CARGO_TERM_COLOR: always
jobs:
test:
name: Test (${{ matrix.os }}, ${{ matrix.profile }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
# macOS ARM64
- os: macos-arm64
runner: macos-14
profile: debug
- os: macos-arm64
runner: macos-14
profile: release
# Linux x86_64
- os: linux-x86
runner: ubuntu-latest
profile: debug
- os: linux-x86
runner: ubuntu-latest
profile: release
# Linux ARM64
- os: linux-arm64
runner: ubuntu-24.04-arm
profile: debug
- os: linux-arm64
runner: ubuntu-24.04-arm
profile: release
steps:
- name: Checkout code
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c
with:
components: rustfmt, clippy
- name: Install WABT (WebAssembly Binary Toolkit)
uses: ./.github/actions/install-wabt
- name: Cache Rust dependencies
# Pinned commit resolved from the annotated Swatinem/rust-cache@v2 tag.
uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32
with:
key: ${{ matrix.profile }}
save-if: ${{ github.ref == 'refs/heads/main' }}
cache-bin: false
- name: Run tests (debug)
if: matrix.profile == 'debug'
run: cargo test --workspace --verbose
- name: Run tests (release)
if: matrix.profile == 'release'
run: cargo test --workspace --release --verbose
- name: Run tests with strict-assertions (debug)
if: matrix.profile == 'debug'
run: cargo test --workspace --features strict-assertions --verbose
- name: Run tests with strict-assertions (release)
if: matrix.profile == 'release'
run: cargo test --workspace --release --features strict-assertions --verbose
test-32bit:
name: Test (i686-unknown-linux-gnu, ${{ matrix.profile }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
profile:
- debug
- release
steps:
- name: Checkout code
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- name: Install 32-bit system libraries
run: |
sudo apt-get update
sudo apt-get install -y gcc-multilib
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c
with:
targets: i686-unknown-linux-gnu
- name: Install WABT (WebAssembly Binary Toolkit)
uses: ./.github/actions/install-wabt
# Only the interpreter library is deployed to the 32-bit target, so the
# host-only workspace tooling is not built here. Running the suite on a
# 32-bit `usize` guards pointer-width regressions (e.g. memory
# effective-address overflow) that the 64-bit test matrix cannot observe.
- name: Run tests (debug)
if: matrix.profile == 'debug'
run: cargo test -p spacewasm --target i686-unknown-linux-gnu --verbose
- name: Run tests (release)
if: matrix.profile == 'release'
run: cargo test -p spacewasm --release --target i686-unknown-linux-gnu --verbose
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- name: Install Rust toolchain
# Pinned to the commit the `stable` branch resolved to (its action.yml
# defaults `toolchain: stable`); immutable ref for supply-chain safety.
uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c # stable
with:
components: rustfmt, clippy
- name: Check formatting
run: cargo fmt --all -- --check
- name: Run clippy
run: cargo clippy --workspace --all-targets --all-features -- -D warnings
- name: Check C header codegen is up to date
run: |
# Regenerate include/spacewasm.h from the Rust source. The build
# script writes the header in place when the `codegen` feature is on.
cargo build -p spacewasm_c_api --features codegen
# Fail if the regenerated header differs from what is tracked in git.
if ! git diff --exit-code -- crates/spacewasm_c_api/include/spacewasm.h; then
echo "::error::spacewasm.h is out of date. Run 'cargo build -p spacewasm_c_api --features codegen' and commit the result."
exit 1
fi
build:
name: Build (${{ matrix.os }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- os: macos-arm64
runner: macos-14
- os: linux-x86
runner: ubuntu-latest
- os: linux-arm64
runner: ubuntu-24.04-arm
steps:
- name: Checkout code
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c
- name: Build all targets
run: cargo build --workspace --all-targets --verbose
- name: Build release
run: cargo build --workspace --release --verbose
benchmark:
name: Benchmark
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
fetch-depth: 0
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c
- name: Install WABT (WebAssembly Binary Toolkit)
uses: ./.github/actions/install-wabt
- name: Cache Rust dependencies
# Pinned commit resolved from the annotated Swatinem/rust-cache@v2 tag.
uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
cache-bin: false
- name: Run CoreMark benchmark
id: benchmark
run: |
# Build and run the benchmark from workspace root, capturing output
output=$(cargo bench -p spacewasm_std --bench coremark --no-fail-fast 2>&1)
echo "$output"
# Extract the CoreMark score from the output
score=$(echo "$output" | grep -m1 "CoreMark Score:" | awk '{print $3}')
if [ -z "$score" ]; then
echo "Failed to extract CoreMark score"
exit 1
fi
echo "score=$score" >> $GITHUB_OUTPUT
echo "Benchmark score: $score"
- name: Download baseline benchmark
id: baseline
continue-on-error: true
run: |
# Try to get baseline from main branch
if [ "${{ github.event_name }}" == "pull_request" ]; then
git fetch origin main:main
git checkout main
baseline_output=$(cargo bench -p spacewasm_std --bench coremark --no-fail-fast 2>&1) || true
baseline_score=$(echo "$baseline_output" | grep -m1 "CoreMark Score:" | awk '{print $3}')
git checkout -
if [ -n "$baseline_score" ]; then
echo "baseline=$baseline_score" >> $GITHUB_OUTPUT
echo "Baseline score: $baseline_score"
else
echo "baseline=" >> $GITHUB_OUTPUT
fi
else
echo "baseline=" >> $GITHUB_OUTPUT
fi
- name: Save benchmark results
if: github.event_name == 'pull_request'
run: |
cat > benchmark-results.json <<EOF
{
"prNumber": "${{ github.event.pull_request.number }}",
"currentScore": "${{ steps.benchmark.outputs.score }}",
"baselineScore": "${{ steps.baseline.outputs.baseline }}"
}
EOF
- name: Upload benchmark results
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: benchmark-results
path: benchmark-results.json
model-checking:
name: Formal Verification
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
fetch-depth: 0
- name: Run Kani on repo
uses: model-checking/kani-github-action@f838096619a707b0f6b2118cf435eaccfa33e51f # v1.1
with:
args: "-j --output-format=terse"
miri:
name: Miri
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
fetch-depth: 0
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c
with:
toolchain: nightly-2026-08-30
components: miri
- name: Run Miri
env:
MIRIFLAGS: -Zmiri-disable-isolation
run: cargo miri test --lib --no-fail-fast --verbose --features miri-soft-floats
coverage:
name: Code Coverage
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
fetch-depth: 0
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c
with:
components: llvm-tools-preview
- name: Install WABT (WebAssembly Binary Toolkit)
uses: ./.github/actions/install-wabt
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@37f7c5781271959fb65b6b35224e28652ff2b63d # v2.87.0
with:
tool: cargo-llvm-cov
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
cache-bin: false
- name: Generate coverage
run: |
# Cover the main library and the C-API layer. spacewasm_c_api's Rust
# `#[cfg(test)]` suite drives the `spacewasm_*` entry points directly,
# so its coverage is attributed like any other crate.
cargo llvm-cov \
--package spacewasm \
--package spacewasm_c_api \
--lcov --output-path lcov.info
cargo llvm-cov \
--package spacewasm \
--package spacewasm_c_api \
--json --output-path coverage.json
- name: Extract coverage percentage
id: coverage
run: |
# Extract coverage percentage from JSON output
coverage=$(jq -r '.data[0].totals.lines.percent' coverage.json)
echo "percentage=$coverage" >> $GITHUB_OUTPUT
echo "Current coverage: $coverage%"
- name: Download baseline coverage
id: baseline-coverage
continue-on-error: true
run: |
# Try to get baseline from main branch
if [ "${{ github.event_name }}" == "pull_request" ]; then
git fetch origin main:main
git checkout main
cargo llvm-cov \
--package spacewasm \
--package spacewasm_c_api \
--json --output-path baseline-coverage.json 2>&1 || true
git checkout -
if [ -f baseline-coverage.json ]; then
baseline=$(jq -r '.data[0].totals.lines.percent' baseline-coverage.json)
echo "baseline=$baseline" >> $GITHUB_OUTPUT
echo "Baseline coverage: $baseline%"
else
echo "baseline=" >> $GITHUB_OUTPUT
fi
else
echo "baseline=" >> $GITHUB_OUTPUT
fi
- name: Save coverage results
if: github.event_name == 'pull_request'
run: |
cat > coverage-results.json <<EOF
{
"prNumber": "${{ github.event.pull_request.number }}",
"currentCoverage": "${{ steps.coverage.outputs.percentage }}",
"baselineCoverage": "${{ steps.baseline-coverage.outputs.baseline }}"
}
EOF
- name: Upload coverage results
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: coverage-results
path: coverage-results.json
- name: Upload coverage to Codecov
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7
with:
files: lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
verbose: true