| 1 |
name: Fuzzing |
| 2 |
|
| 3 |
|
| 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_cmp, should_pass: true } |
| 45 |
- { name: fuzz_cmp_args, should_pass: true } |
| 46 |
- { name: fuzz_ed, should_pass: true } |
| 47 |
- { name: fuzz_normal, should_pass: true } |
| 48 |
- { name: fuzz_patch, should_pass: true } |
| 49 |
- { name: fuzz_side, should_pass: true } |
| 50 |
steps: |
| 51 |
- uses: actions/checkout@v4 |
| 52 |
- uses: dtolnay/rust-toolchain@nightly |
| 53 |
- name: Install `cargo-fuzz` |
| 54 |
run: cargo install cargo-fuzz |
| 55 |
- uses: Swatinem/rust-cache@v2 |
| 56 |
with: |
| 57 |
shared-key: "cargo-fuzz-cache-key" |
| 58 |
cache-directories: "fuzz/target" |
| 59 |
- name: Restore Cached Corpus |
| 60 |
uses: actions/cache/restore@v5 |
| 61 |
with: |
| 62 |
key: corpus-cache-${{ matrix.test-target.name }} |
| 63 |
path: | |
| 64 |
fuzz/corpus/${{ matrix.test-target.name }} |
| 65 |
- name: Run ${{ matrix.test-target.name }} for XX seconds |
| 66 |
shell: bash |
| 67 |
continue-on-error: ${{ !matrix.test-target.name.should_pass }} |
| 68 |
run: | |
| 69 |
cargo +nightly fuzz run ${{ matrix.test-target.name }} -- -max_total_time=${{ env.RUN_FOR }} -detect_leaks=0 |
| 70 |
- name: Save Corpus Cache |
| 71 |
uses: actions/cache/save@v5 |
| 72 |
with: |
| 73 |
key: corpus-cache-${{ matrix.test-target.name }} |
| 74 |
path: | |
| 75 |
fuzz/corpus/${{ matrix.test-target.name }} |