Nightly Fuzz #127
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Nightly Fuzz | |
| on: | |
| schedule: | |
| - cron: '0 3 * * *' | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| discover-targets: | |
| name: Discover fuzz targets | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.targets.outputs.matrix }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Find fuzz targets | |
| id: targets | |
| run: | | |
| targets='[]' | |
| for fuzz_dir in crates/*/fuzz; do | |
| [ -d "$fuzz_dir/fuzz_targets" ] || continue | |
| crate_dir="$(dirname "$fuzz_dir")" | |
| crate_name="$(basename "$crate_dir")" | |
| for target_file in "$fuzz_dir"/fuzz_targets/*.rs; do | |
| [ -f "$target_file" ] || continue | |
| target_name="$(basename "$target_file" .rs)" | |
| targets=$(echo "$targets" | jq -c --arg c "$crate_name" --arg d "$crate_dir" --arg t "$target_name" '. + [{"crate": $c, "crate_dir": $d, "target": $t}]') | |
| done | |
| done | |
| echo "matrix={\"include\":$targets}" >> "$GITHUB_OUTPUT" | |
| fuzz: | |
| name: "Fuzz ${{ matrix.crate }}/${{ matrix.target }}" | |
| needs: discover-targets | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| strategy: | |
| fail-fast: false | |
| matrix: ${{ fromJson(needs.discover-targets.outputs.matrix) }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install system dependencies | |
| run: sudo apt-get update && sudo apt-get install -y libudev-dev | |
| - name: Install Rust nightly | |
| run: | | |
| rustup install nightly | |
| rustup default nightly | |
| - uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| target/ | |
| key: fuzz-${{ matrix.crate }}-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| fuzz-${{ matrix.crate }}- | |
| - name: Install cargo-fuzz | |
| run: cargo install cargo-fuzz --locked | |
| - name: Run fuzzer | |
| id: run_fuzzer | |
| continue-on-error: true | |
| working-directory: ${{ matrix.crate_dir }} | |
| run: | | |
| cargo +nightly fuzz run ${{ matrix.target }} -- -max_total_time=60 | |
| - name: Upload corpus | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: corpus-${{ matrix.crate }}-${{ matrix.target }} | |
| path: ${{ matrix.crate_dir }}/fuzz/corpus/${{ matrix.target }}/ | |
| retention-days: 30 | |
| if-no-files-found: ignore | |
| - name: Upload crash artifacts | |
| if: steps.run_fuzzer.outcome == 'failure' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: crashes-${{ matrix.crate }}-${{ matrix.target }} | |
| path: ${{ matrix.crate_dir }}/fuzz/artifacts/${{ matrix.target }}/ | |
| retention-days: 90 | |
| if-no-files-found: ignore |