name: Fuzz
on:
push:
branches: [ master, main ]
pull_request:
branches: [ master, main ]
schedule:
- cron: '11 4 * * *'
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
fuzz:
name: Fuzz ${{ matrix.target }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: [fuzz_roundtrip, fuzz_decode, fuzz_stream]
env:
DURATION: ${{ github.event_name == 'schedule' && 300 || 60 }}
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Rust (nightly — cargo-fuzz requires it)
uses: dtolnay/rust-toolchain@nightly
- name: Cache cargo-fuzz binary
id: cache-cargo-fuzz
uses: actions/cache@v4
with:
path: ~/.cargo/bin/cargo-fuzz
key: cargo-fuzz-bin-v1
- name: Install cargo-fuzz
if: steps.cache-cargo-fuzz.outputs.cache-hit != 'true'
run: cargo install cargo-fuzz
- name: Cache fuzz corpus
uses: actions/cache@v4
with:
path: fuzz/corpus
key: fuzz-corpus-${{ matrix.target }}-${{ github.run_id }}
restore-keys: |
fuzz-corpus-${{ matrix.target }}-
- name: Run ${{ matrix.target }} for ${DURATION}s
run: |
cd fuzz
cargo fuzz run ${{ matrix.target }} -- \
-max_total_time=$DURATION \
-timeout=15
- name: Upload crash artifacts (if any)
if: failure()
uses: actions/upload-artifact@v7
with:
name: fuzz-crashes-${{ matrix.target }}-${{ github.run_id }}
path: |
fuzz/artifacts/${{ matrix.target }}/
if-no-files-found: ignore
retention-days: 30