name: Fuzz
on:
schedule:
- cron: "0 2 * * *"
workflow_dispatch:
inputs:
duration:
description: "Fuzz duration per target (seconds)"
required: false
default: "14400"
env:
CARGO_TERM_COLOR: always
permissions:
contents: read
jobs:
fuzz:
name: fuzz_${{ matrix.target }}
runs-on: ubuntu-latest
timeout-minutes: 260
strategy:
fail-fast: false
matrix:
target: [fuzz_parse, fuzz_strings, fuzz_panics, fuzz_registry, fuzz_output, fuzz_format]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: llvm-tools-preview
- uses: Swatinem/rust-cache@v2
with:
workspaces: "fuzz -> target"
- name: Install cargo-fuzz
run: cargo install --locked cargo-fuzz
- name: Run fuzz target (${{ matrix.target }})
id: fuzz-run
working-directory: fuzz
env:
FUZZ_TARGET: ${{ matrix.target }}
FUZZ_DURATION: ${{ github.event.inputs.duration || '14400' }}
run: |
cargo fuzz run "$FUZZ_TARGET" \
-- -max_total_time="$FUZZ_DURATION" \
-max_len=8192 \
-timeout=30
continue-on-error: true
- name: Check fuzz result and crash artifacts
if: always()
working-directory: fuzz
env:
FUZZ_TARGET: ${{ matrix.target }}
FUZZ_OUTCOME: ${{ steps.fuzz-run.outcome }}
run: |
if [ -d "artifacts/$FUZZ_TARGET" ]; then
CRASHES=$(find "artifacts/$FUZZ_TARGET" -type f | wc -l)
else
CRASHES=0
fi
echo "Found $CRASHES crash artifacts"
if [ "$CRASHES" -gt 0 ]; then
echo "::error::${CRASHES} crash artifacts found for $FUZZ_TARGET"
ls -la "artifacts/$FUZZ_TARGET/"
exit 1
fi
if [ "$FUZZ_OUTCOME" != "success" ]; then
echo "::error::cargo fuzz failed to compile, launch, or complete $FUZZ_TARGET"
exit 1
fi
- name: Upload crash artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: fuzz-crashes-${{ matrix.target }}
path: fuzz/artifacts/
if-no-files-found: ignore
retention-days: 30
- name: Upload corpus
if: always()
uses: actions/upload-artifact@v4
with:
name: fuzz-corpus-${{ matrix.target }}
path: fuzz/corpus/
if-no-files-found: ignore
retention-days: 7