Skip to content

Commit 7a8e81a

Browse files
authored
Merge pull request #234 from mattfarina/cache-fuzz
Add caching to fuzz testing
2 parents 4afef01 + 2a7536d commit 7a8e81a

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

.github/workflows/fuzz.yaml

+29
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,41 @@ on:
99
jobs:
1010
test:
1111
runs-on: ubuntu-latest
12+
env:
13+
cache-key: fuzzing
1214
steps:
1315
- name: Install Go
1416
uses: actions/setup-go@v5
1517
with:
1618
go-version: "1.22"
19+
# The cache path may be different on different runners. GitHub may change
20+
# this in the future. So, we dynamically fetch it.
21+
- name: Get Go Cache Paths
22+
id: go-cache-paths
23+
run: |
24+
echo "::set-output name=go-build::$(go env GOCACHE)"
1725
- name: Checkout code
1826
uses: actions/checkout@v4
27+
- name: Restore Cache
28+
id: cache-restore
29+
uses: actions/cache/restore@v3
30+
with:
31+
path: ${{ steps.go-cache-paths.outputs.go-build }}
32+
key: ${{ env.cache-key }}
1933
- name: Fuzz
2034
run: make fuzz
35+
# Cannot overwrite the existing cache (id's are immutable) so we delete it.
36+
- name: Delete Previous Cache
37+
if: ${{ steps.cache-restore.outputs.cache-hit }}
38+
continue-on-error: true
39+
run: |
40+
gh extension install actions/gh-actions-cache
41+
gh actions-cache delete "${{ env.cache-key }}" --confirm
42+
env:
43+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
# Saving the cache so that Fuzz testing can be additive to previous fuzz testing.
45+
- name: Save Cache
46+
uses: actions/cache/save@v3
47+
with:
48+
path: ${{ steps.go-cache-paths.outputs.go-build }}
49+
key: ${{ env.cache-key }}

0 commit comments

Comments
 (0)