|
| 1 | +name: Fuzzing |
| 2 | + |
| 3 | +# spell-checker:ignore fuzzer |
| 4 | + |
| 5 | +on: |
| 6 | + pull_request: |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 16 | + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} |
| 17 | + |
| 18 | +jobs: |
| 19 | + fuzz-build: |
| 20 | + name: Build the fuzzers |
| 21 | + runs-on: ubuntu-latest |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v4 |
| 24 | + - uses: dtolnay/rust-toolchain@nightly |
| 25 | + - name: Install `cargo-fuzz` |
| 26 | + run: cargo install cargo-fuzz |
| 27 | + - uses: Swatinem/rust-cache@v2 |
| 28 | + with: |
| 29 | + shared-key: "cargo-fuzz-cache-key" |
| 30 | + cache-directories: "fuzz/target" |
| 31 | + - name: Run `cargo-fuzz build` |
| 32 | + run: cargo +nightly fuzz build |
| 33 | + |
| 34 | + fuzz-run: |
| 35 | + needs: fuzz-build |
| 36 | + name: Run the fuzzers |
| 37 | + runs-on: ubuntu-latest |
| 38 | + timeout-minutes: 5 |
| 39 | + env: |
| 40 | + RUN_FOR: 60 |
| 41 | + strategy: |
| 42 | + matrix: |
| 43 | + test-target: |
| 44 | + - { name: fuzz_ed, should_pass: true } |
| 45 | + - { name: fuzz_normal, should_pass: true } |
| 46 | + - { name: fuzz_patch, should_pass: true } |
| 47 | + steps: |
| 48 | + - uses: actions/checkout@v4 |
| 49 | + - uses: dtolnay/rust-toolchain@nightly |
| 50 | + - name: Install `cargo-fuzz` |
| 51 | + run: cargo install cargo-fuzz |
| 52 | + - uses: Swatinem/rust-cache@v2 |
| 53 | + with: |
| 54 | + shared-key: "cargo-fuzz-cache-key" |
| 55 | + cache-directories: "fuzz/target" |
| 56 | + - name: Restore Cached Corpus |
| 57 | + uses: actions/cache/restore@v4 |
| 58 | + with: |
| 59 | + key: corpus-cache-${{ matrix.test-target.name }} |
| 60 | + path: | |
| 61 | + fuzz/corpus/${{ matrix.test-target.name }} |
| 62 | + - name: Run ${{ matrix.test-target.name }} for XX seconds |
| 63 | + shell: bash |
| 64 | + continue-on-error: ${{ !matrix.test-target.name.should_pass }} |
| 65 | + run: | |
| 66 | + cargo +nightly fuzz run ${{ matrix.test-target.name }} -- -max_total_time=${{ env.RUN_FOR }} -detect_leaks=0 |
| 67 | + - name: Save Corpus Cache |
| 68 | + uses: actions/cache/save@v4 |
| 69 | + with: |
| 70 | + key: corpus-cache-${{ matrix.test-target.name }} |
| 71 | + path: | |
| 72 | + fuzz/corpus/${{ matrix.test-target.name }} |
0 commit comments