-
Notifications
You must be signed in to change notification settings - Fork 25
401 lines (396 loc) · 14.6 KB
/
test.yml
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
name: Test
on:
push:
pull_request:
workflow_call:
env:
CARGO_TERM_COLOR: always
# Enable backtraces for panics but not for "regular" errors.
RUST_BACKTRACE: 1
RUST_LIB_BACKTRACE: 0
RUSTFLAGS: '-D warnings'
jobs:
build-linux-kernel:
uses: ./.github/workflows/build-linux.yml
secrets: inherit
with:
# TODO: Bump to v6.11 once tagged.
rev: 44eacec2cec1c5f83074e74d00208d15390b00bc
config: 'data/config'
build:
name: Build [${{ matrix.runs-on }}, ${{ matrix.rust }}, ${{ matrix.profile }}, ${{ matrix.args }}]
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
runs-on: [ubuntu-latest, macos-latest]
rust: [stable]
profile: [dev, release]
# gsym-in-apk requires `generate-unit-test-files` feature, which
# requires `llvm-gsymutil` installed. We don't want that dependency in
# this large OS spanning matrix.
args: ["--workspace --exclude=gsym-in-apk"]
include:
- runs-on: ubuntu-latest
rust: stable
profile: dev
# Make sure to build *without* `--workspace` or feature
# unification may mean that `--no-default-features` goes
# without effect.
args: "--lib --no-default-features"
- runs-on: ubuntu-latest
rust: stable
profile: dev
args: "--lib --no-default-features --features=apk"
- runs-on: windows-latest
rust: stable
profile: release
args: "--lib --no-default-features"
- runs-on: ubuntu-latest
rust: stable
profile: dev
args: "--lib --no-default-features --features=breakpad"
- runs-on: ubuntu-latest
rust: stable
profile: dev
args: "--lib --no-default-features --features=gsym"
- runs-on: ubuntu-latest
rust: stable
profile: dev
args: "--lib --no-default-features --features=zlib"
- runs-on: ubuntu-latest
rust: stable
profile: dev
args: "--lib --no-default-features --features=zstd"
- runs-on: ubuntu-latest
rust: stable
profile: dev
args: "--package=blazecli"
- runs-on: ubuntu-latest
rust: stable
profile: dev
args: "--package=blazesym-c"
- runs-on: ubuntu-latest
rust: stable
profile: release
args: "--package=blazesym-c --no-default-features"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.runs-on }}-${{ matrix.rust }}-${{ matrix.profile }}
- name: Build ${{ matrix.profile }}
run: |
cargo build --profile=${{ matrix.profile }} ${{ matrix.args }}
build-cross:
name: Cross-compile [${{ matrix.target }}]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: [
aarch64-linux-android,
arm-linux-androideabi,
armv7-linux-androideabi,
x86_64-unknown-linux-musl,
]
steps:
- uses: actions/checkout@v4
- uses: taiki-e/setup-cross-toolchain-action@v1
with:
target: ${{ matrix.target }}
- run: |
cargo build --lib
build-minimum:
name: Build using minimum versions of dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- run: cargo +nightly -Z minimal-versions update
- uses: dtolnay/rust-toolchain@master
with:
# Please adjust README, `rust-version` field in Cargo.toml,
# and `msrv` in .clippy.toml when bumping version.
toolchain: 1.65.0
- uses: Swatinem/rust-cache@v2
- run: cargo build --features="apk,backtrace,demangle,dwarf,gsym,tracing"
nop-rebuilds:
name: No-op rebuilds
runs-on: ubuntu-22.04
env:
LLVM_GSYMUTIL: /usr/bin/llvm-gsymutil-14
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- name: Install required tools
run: sudo apt-get install -y llvm-14
- name: Check incremental rebuilds
env:
CARGO_OPTS: --features=generate-unit-test-files --workspace --quiet --tests
run: |
cargo check ${CARGO_OPTS}
# We need another build here to have the reference `output` file
# present. As long as we converge eventually it's probably good
# enough...
cargo check ${CARGO_OPTS}
output=$(CARGO_LOG=cargo::core::compiler::fingerprint=info cargo check ${CARGO_OPTS} 2>&1)
[ -z "${output}" ] || (echo "!!!! cargo check --tests rebuild was not a no-op: ${output} !!!!" && false)
test-coverage:
name: Test and coverage
runs-on: ubuntu-22.04
needs: [build-linux-kernel]
env:
LLVM_GSYMUTIL: /usr/bin/llvm-gsymutil-14
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- uses: Swatinem/rust-cache@v2
- uses: actions/setup-python@v5
id: py312
with:
python-version: '3.12'
- name: Install required tools
run: sudo apt-get install -y llvm-14
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Install llvm-tools-preview
# Install llvm-tools-preview, because we don't want this to happen
# from within our `vmtest` instance.
run: rustup component add llvm-tools-preview --toolchain nightly-x86_64-unknown-linux-gnu
- name: Remove .cargo/config.toml
# We don't want a custom test runner because we run in a VM.
run: rm .cargo/config.toml
- name: Build main.sh
env:
ARTIFACT_URL: ${{ needs.build-linux-kernel.outputs.kernel-artifact-url }}
PYTHON: ${{ steps.py312.outputs.python-path }}
run: |
# cargo-llvm-cov ultimately is just a thin wrapper around cargo
# commands with certain environment variables set. Because it
# does not allow us to build binaries and execute them in
# different steps, we have to roll our own logic for doing just
# that, because we do not want to build inside a nested VM...
cargo llvm-cov show-env | sed 's@.*@export \0@' > env.sh
echo "export PYTHON=${PYTHON}" >> env.sh
source env.sh
cargo test --no-run --workspace --all-targets --features=nightly,generate-large-test-files 2>&1 | tee /tmp/cargo-build.log
tests=$(IFS='' grep Executable /tmp/cargo-build.log |
awk '{print $NF}' |
sed 's@[()]@@g' |
sed 's@.*@\0 --include-ignored@'
)
# Yes, there appears to be no way to just retrieve the
# uploaded artifact. One can't use actions/download-artifact
# and provide any of the outputs of actions/upload-artifact.
# Neither does it seem possible to just download the thing
# directly, because contents are unconditionally zipped. Good.
# Lord.
curl --location \
--fail-with-body \
--header "Accept: application/vnd.github+json" \
--header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"\
--header "X-GitHub-Api-Version: 2022-11-28" \
--output artifact.zip \
"${ARTIFACT_URL}"
# This unzip will produce the kernel bzImage.
unzip artifact.zip
cat <<EOF > main.sh
#!/bin/sh
set -e
. ./env.sh
$tests
cargo llvm-cov report --ignore-filename-regex=cli/src/ --lcov --output-path lcov.info
EOF
chmod a+x main.sh
- name: Test and gather coverage
uses: danobi/vmtest-action@f8c84191b5925c3290595743fc46eaaafd827bf3
with:
kernel: bzImage
command: sh -c 'cd ${{ github.workspace }} && ./main.sh'
- name: Upload code coverage results
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: lcov.info
build-test-artifacts:
# Only run Windows tests on the final push. They are very unlikely to break
# at runtime (we build them anyway), but take quite a bit longer than Linux
# based ones.
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
name: Build test artifacts for Windows
runs-on: ubuntu-22.04
env:
LLVM_GSYMUTIL: /usr/bin/llvm-gsymutil-14
steps:
- uses: actions/checkout@v4
- name: Install required tools
run: sudo apt-get install -y llvm-14
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo build --features=generate-unit-test-files
- uses: actions/upload-artifact@v4
with:
name: test-stable-addrs
if-no-files-found: error
path: |
data/test-stable-addrs*
data/test-rs.bin
test-windows:
name: Test on Windows
runs-on: windows-latest
needs: [build-test-artifacts]
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: test-stable-addrs
path: data/
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo test --tests --release --features=dont-generate-unit-test-files -- ':windows:'
test-sanitizers:
name: Test with ${{ matrix.sanitizer }} sanitizer
strategy:
fail-fast: false
matrix:
sanitizer: [address, leak]
runs-on: ubuntu-latest
env:
LLVM_GSYMUTIL: /usr/bin/llvm-gsymutil-14
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.sanitizer }}
- name: Enable debug symbols
run: |
# to get the symbolizer for debug symbol resolution
sudo apt-get install -y llvm-14
# to fix buggy leak analyzer:
# https://github.com/japaric/rust-san#unrealiable-leaksanitizer
sed -i '/\[features\]/i [profile.dev]' Cargo.toml
sed -i '/profile.dev/a opt-level = 1' Cargo.toml
cat Cargo.toml
- name: cargo test -Zsanitizer=${{ matrix.sanitizer }}
env:
# TODO: Ideally we'd set CFLAGS and CXXFLAGS as well, but some
# of our transitive dependencies don't play nice with
# ASAN.
#CFLAGS: "-fsanitize=${{ matrix.sanitizer }}"
#CXXFLAGS: "-fsanitize=${{ matrix.sanitizer }}"
RUSTFLAGS: "-Zsanitizer=${{ matrix.sanitizer }}"
ASAN_OPTIONS: "detect_odr_violation=0:detect_leaks=0"
LSAN_OPTIONS: ""
run: cargo test --workspace --lib --tests --target x86_64-unknown-linux-gnu
test-release:
name: Test with release build
runs-on: ubuntu-22.04
env:
LLVM_GSYMUTIL: /usr/bin/llvm-gsymutil-14
steps:
- uses: actions/checkout@v4
- name: Install required tools
run: sudo apt-get install -y llvm-14
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo test --workspace --release
test-miri:
name: Test with Miri
runs-on: ubuntu-latest
env:
# Stack borrows are very experimental. Disable for now.
MIRIFLAGS: '-Zmiri-disable-stacked-borrows'
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: miri
# Miri would honor our custom test runner, but doesn't work with it. We
# could conceivably override that by specifying
# CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER, except it appears as if Miri
# uses the runner itself. In short, it's a mess. Just remove any
# such custom configuration when running Miri.
- name: Remove .cargo/config.toml
run: rm .cargo/config.toml
- name: Run tests
run: cargo miri test --workspace --features=dont-generate-unit-test-files -- ":miri:"
test-examples:
name: Test examples
runs-on: ubuntu-22.04
env:
LLVM_GSYMUTIL: /usr/bin/llvm-gsymutil-14
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo run --example backtrace
- run: cargo run --package gsym-in-apk
c-header:
name: Check generated C header
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo check --package=blazesym-c --features=generate-c-header
- name: Check that C header is up-to-date
run: git diff --exit-code ||
(echo "!!!! CHECKED IN C HEADER IS OUTDATED !!!!" && false)
bench:
# Only run benchmarks on the final push. They are generally only
# informative because the GitHub Runners do not provide a stable
# performance baseline anyway.
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
name: Benchmark
runs-on: ubuntu-22.04
env:
LLVM_GSYMUTIL: /usr/bin/llvm-gsymutil-14
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- name: Install required tools
run: sudo apt-get install -y llvm-14
- uses: Swatinem/rust-cache@v2
- name: Run benchmarks
shell: bash
run: |
echo '```' >> $GITHUB_STEP_SUMMARY
cargo bench --workspace --features=nightly -- bench_ | tee --append $GITHUB_STEP_SUMMARY
# We use bencher format here for better relation to the above
# but also because it emits less other crap into our summary.
# Note that because libtest does not understand the
# `--output-format` option, we need to specify the benchmark
# binary (`main`) here and have a different invocation for
# libtest style benchmarks above. Sigh.
cargo bench --workspace --bench=main --bench=capi --features=generate-large-test-files,dont-generate-unit-test-files -- --output-format=bencher | tee --append $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
clippy:
name: Lint with clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo clippy --workspace --no-deps --all-targets --features=dont-generate-unit-test-files -- -A unknown_lints -D clippy::todo
rustfmt:
name: Check code formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- run: cargo +nightly fmt --all -- --check
cargo-doc:
name: Generate documentation
runs-on: ubuntu-22.04
env:
LLVM_GSYMUTIL: /usr/bin/llvm-gsymutil-14
RUSTDOCFLAGS: '--cfg docsrs -D warnings'
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- run: cargo doc --workspace --no-deps