Skip to content

Commit 7f1fa74

Browse files
committed
ci(fuzz): add daily fuzz job
- adds a new daily CI fuzz job, it runs every day at 5am UTC and uploads the artifacts on failures. - it currently only uses the `cargo fuzz`, as it's the only supported harness at the moment.
1 parent c02f843 commit 7f1fa74

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

.github/workflows/cron_daily_fuzz.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
on:
2+
schedule:
3+
- cron: "00 05 * * *" # At 05:00 (UTC) every day.
4+
workflow_dispatch: # allows manual triggering
5+
6+
permissions: {}
7+
8+
name: Daily Fuzz
9+
10+
jobs:
11+
fuzz:
12+
name: Cargo Fuzz
13+
runs-on: ubuntu-latest
14+
env:
15+
# The version of `cargo-fuzz` to install and use.
16+
CARGO_FUZZ_VERSION: 0.13.1
17+
18+
# The number of seconds to run the fuzz target. 1800 seconds = 30 minutes.
19+
FUZZ_TIME: 1800
20+
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
include:
25+
- fuzz_target: bdk_wallet
26+
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
with:
31+
persist-credentials: false
32+
33+
- name: Install the nightly Rust channel
34+
uses: actions-rs/toolchain@v1
35+
with:
36+
toolchain: nightly
37+
override: true
38+
profile: minimal
39+
40+
- name: Check cache for cargo-fuzz
41+
id: cache-cargo-fuzz
42+
uses: actions/cache@v4
43+
with:
44+
path: ${{ runner.tool_cache }}/cargo-fuzz
45+
key: cargo-fuzz-bin-${{ env.CARGO_FUZZ_VERSION }}
46+
47+
- name: Install cargo-fuzz
48+
if: steps.cache-cargo-fuzz.outputs.cache-hit != 'true'
49+
run: |
50+
cargo install --root "${{ runner.tool_cache }}/cargo-fuzz" --version $CARGO_FUZZ_VERSION cargo-fuzz --locked
51+
env:
52+
CARGO_FUZZ_VERSION: ${{ env.CARGO_FUZZ_VERSION }}
53+
54+
- name: Add cargo-fuzz to PATH
55+
run: echo "${{ runner.tool_cache }}/cargo-fuzz/bin" >> $GITHUB_PATH
56+
57+
- name: Build & Run Fuzz Target
58+
run: |
59+
cargo fuzz build ${{ matrix.fuzz_target }}
60+
cargo fuzz run ${{ matrix.fuzz_target }} -- -max_total_time=$FUZZ_TIME
61+
env:
62+
FUZZ_TIME: ${{ env.FUZZ_TIME }}
63+
64+
- name: Upload fuzzing artifacts on failure
65+
uses: actions/upload-artifact@v4
66+
if: failure()
67+
with:
68+
name: fuzzing-artifacts-${{ matrix.fuzz_target }}-${{ github.sha }}
69+
path: fuzz/artifacts
70+
71+
# TODO: add a verify-execution job similar to rust-bitcoin's one

0 commit comments

Comments
 (0)