Skip to content

Commit 78f58d4

Browse files
rnijvelddavidv1992
authored andcommitted
Update fuzzing on CI
1 parent a367023 commit 78f58d4

File tree

1 file changed

+36
-14
lines changed

1 file changed

+36
-14
lines changed

.github/workflows/rust.yml

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
- name: Build stm32
3939
working-directory: statime-stm32
4040
run: cargo build
41-
41+
4242
# Build std is handled by test job
4343

4444
test:
@@ -108,24 +108,46 @@ jobs:
108108
fuzz:
109109
name: Smoke-test fuzzing targets
110110
runs-on: ubuntu-latest
111+
strategy:
112+
matrix:
113+
include:
114+
- fuzz_target: message_sound
115+
corpus: ""
116+
features: ''
111117
steps:
112118
- name: Checkout sources
113-
uses: actions/checkout@v4
119+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
114120
with:
115121
persist-credentials: false
116-
- name: Install stable toolchain
117-
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af
122+
- name: Install nightly toolchain
123+
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
118124
with:
119125
toolchain: nightly
120-
override: true
121-
default: true
122-
- name: Install cargo fuzz
123-
uses: taiki-e/install-action@70233fe3d27d863712ee34eede2087e36bde6b5e
126+
components: llvm-tools-preview
127+
- name: Install cargo fuzz & rustfilt
128+
uses: taiki-e/install-action@d6912b47771be2c443ec90dbb3d28e023987e782
124129
with:
125-
tool: cargo-fuzz
126-
- name: Smoke-test fuzz targets
130+
tool: cargo-fuzz,rustfilt
131+
- name: Run `cargo fuzz`
132+
env:
133+
RUST_BACKTRACE: "1"
134+
# prevents `cargo fuzz coverage` from rebuilding everything
135+
RUSTFLAGS: "-C instrument-coverage"
136+
run: |
137+
cargo fuzz run --target $(rustc --print host-tuple) ${{matrix.features}} ${{matrix.fuzz_target}} ${{matrix.corpus}} -- -max_total_time=10
138+
- name: Fuzz codecov
127139
run: |
128-
cargo fuzz build
129-
for target in $(cargo fuzz list) ; do
130-
cargo fuzz run $target -- -max_total_time=10
131-
done
140+
cargo fuzz coverage --target $(rustc --print host-tuple) ${{matrix.features}} ${{matrix.fuzz_target}} ${{matrix.corpus}}
141+
$(rustc --print sysroot)/lib/rustlib/$(rustc --print host-tuple)/bin/llvm-cov export -Xdemangler=rustfilt \
142+
target/x86_64-unknown-linux-musl/coverage/$(rustc --print host-tuple)/release/${{matrix.fuzz_target}} \
143+
-instr-profile=fuzz/coverage/${{matrix.fuzz_target}}/coverage.profdata \
144+
--format=lcov \
145+
-ignore-filename-regex="\.cargo|\.rustup" > lcov.info
146+
- name: Upload coverage to Codecov
147+
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7
148+
with:
149+
files: ./lcov.info
150+
fail_ci_if_error: false
151+
flags: fuzz, fuzz-${{ matrix.fuzz_target }}
152+
token: ${{ secrets.CODECOV_TOKEN }}
153+
name: fuzz

0 commit comments

Comments
 (0)