Skip to content

Commit 5807852

Browse files
committed
Persist fuzz corpus between CI runs
Implements a persistent, global fuzz corpus cache. PRs perform a "read-only" restore from the `main` cache to seed fuzzer runs. The `main` branch performs a "read-write" to save new findings and grow the corpus.
1 parent b06f6c5 commit 5807852

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

.github/workflows/build.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,29 @@ jobs:
267267
- name: Install Rust ${{ env.TOOLCHAIN }} toolchain
268268
run: |
269269
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain ${{ env.TOOLCHAIN }}
270+
# This is read-only for PRs. It seeds the fuzzer for a more effective run.
271+
# NOTE: The `key` is unique and will always miss, forcing a fallback to
272+
# the `restore-keys` to find the latest global cache from the `main` branch.
273+
- name: Restore persistent fuzz corpus (PR)
274+
if: ${{ github.ref != 'refs/heads/main' }}
275+
uses: actions/cache/restore@v4
276+
with:
277+
path: fuzz/hfuzz_workspace
278+
key: fuzz-corpus-${{ github.ref }}-${{ github.sha }}
279+
restore-keys: |
280+
fuzz-corpus-refs/heads/main-
281+
# The `restore-keys` performs a prefix search to find the most recent
282+
# cache from a previous `main` run. We then save with a new, unique
283+
# `key` (using the SHA) to ensure the cache is always updated,
284+
# as caches are immutable.
285+
- name: Restore/Save persistent honggfuzz corpus (Main)
286+
if: ${{ github.ref == 'refs/heads/main' }}
287+
uses: actions/cache@v4
288+
with:
289+
path: fuzz/hfuzz_workspace
290+
key: fuzz-corpus-refs/heads/main-${{ github.sha }}
291+
restore-keys: |
292+
fuzz-corpus-refs/heads/main-
270293
- name: Sanity check fuzz targets on Rust ${{ env.TOOLCHAIN }}
271294
run: |
272295
cd fuzz

0 commit comments

Comments
 (0)