name: Fuzz on: schedule: - cron: "0 3 */3 * *" workflow_dispatch: permissions: contents: read jobs: fuzz: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: persist-credentials: false - name: Install Go uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0 with: go-version: 'stable' # Cache interesting fuzzing inputs so subsequential fuzz runs # don't start from zero. - name: Locate fuzz cache run: echo "GOFUZZCACHE=$(go env GOCACHE)/fuzz" >> "$GITHUB_ENV" - name: Restore fuzz corpus uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: ${{ env.GOFUZZCACHE }} # The key is unique per run so a fresh cache is always saved; restore-keys # falls back to the most recent corpus from a previous run. key: fuzz-${{ runner.os }}-${{ github.run_id }} restore-keys: | fuzz-${{ runner.os }}- # 2m per target is chosen so that roughly half of the 2000 free CI minutes # offered by Github will be used each month. The other half is reserved for # tests in PRs. Keep an eye on the total run time when adding fuzz targets. - name: Run all fuzz tests run: | for pkg in $(go list ./...); do for target in $(go test -list '^Fuzz' "$pkg" | grep '^Fuzz' || true); do echo "=== fuzzing $target in $pkg for 64bit ===" go test -fuzztime=3m -fuzz="^${target}\$" "$pkg" echo "=== fuzzing $target in $pkg for 32bit ===" GOARCH=386 go test -fuzztime=1m -fuzz="^${target}\$" "$pkg" done done - name: Save fuzz corpus if: always() uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: ${{ env.GOFUZZCACHE }} key: fuzz-${{ runner.os }}-${{ github.run_id }}