name: Fuzz
on:
push:
branches: [main, develop]
pull_request:
branches: [develop]
schedule:
- cron: '0 2 * * 6' workflow_dispatch:
env:
CARGO_TERM_COLOR: always
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
fuzz:
name: Fuzz (${{ matrix.target }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: [status_flags, ced]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
- name: Install nightly toolchain
uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 with:
toolchain: nightly
- name: Install cargo-fuzz
run: cargo install cargo-fuzz --locked --version 0.13.2
- name: Restore corpus cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 with:
path: fuzz/corpus/${{ matrix.target }}
key: fuzz-corpus-${{ matrix.target }}-${{ github.sha }}
restore-keys: fuzz-corpus-${{ matrix.target }}-
- name: Fuzz (smoke, 60 s) — PRs and pushes
if: github.event_name == 'push' || github.event_name == 'pull_request'
run: cargo +nightly fuzz run ${{ matrix.target }} -- -max_total_time=60
- name: Fuzz (deep, 1 h) — scheduled and manual
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
run: cargo +nightly fuzz run ${{ matrix.target }} -- -max_total_time=3600
- name: Minimise corpus
if: success() && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
run: cargo +nightly fuzz cmin ${{ matrix.target }}
- name: Upload corpus artifact
if: success() && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 with:
name: fuzz-corpus-${{ matrix.target }}
path: fuzz/corpus/${{ matrix.target }}/
- name: Upload crash artifacts
if: failure()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 with:
name: fuzz-crash-${{ matrix.target }}
path: fuzz/artifacts/${{ matrix.target }}/
update-corpus:
name: Update corpus
needs: [fuzz]
if: success() && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
- name: Download all corpus artifacts
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 with:
pattern: fuzz-corpus-*
path: fuzz/corpus/
merge-multiple: false
- name: Flatten artifact subdirectories
run: |
for target in status_flags ced; do
src="fuzz/corpus/fuzz-corpus-${target}"
dst="fuzz/corpus/${target}"
if [ -d "$src" ]; then
mkdir -p "$dst"
cp -r "$src/." "$dst/"
rm -rf "$src"
fi
done
- name: Open PR if corpus changed
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: ci/fuzz-corpus
commit-message: "ci: update fuzz corpus after deep run"
title: "ci: update fuzz corpus after deep run"
body: |
Minimised corpus from the latest deep fuzz run. Covers both targets:
`status_flags`, `ced`.
*Opened automatically by the fuzz CI job.*
add-paths: fuzz/corpus/