Skip to content

Fuzz Testing

Fuzz Testing #824

Workflow file for this run

# .github/workflows/fuzz.yml
name: Fuzz Testing
on:
# Quick fuzz tests on PRs
pull_request:
branches: [main]
paths:
- '**.go'
- 'go.*'
- '.github/workflows/fuzz.yml'
# Extended fuzz tests nightly
schedule:
- cron: '0 0 * * *' # midnight UTC
jobs:
quick-fuzz:
name: Quick Fuzz Tests
# Only run quick fuzz on PRs
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: "1.25"
cache: true
- name: Run Quick Fuzz Tests
run: make fuzz
- name: Upload Fuzz Findings
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: fuzz-findings
path: internal/webhook/testdata/fuzz/
retention-days: 7
extended-fuzz:
name: Extended Fuzz Tests
# Only run extended fuzz on schedule
if: github.event_name == 'schedule'
runs-on: ubuntu-latest
timeout-minutes: 60 # Prevent excessive resource usage
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: "1.25"
cache: true
- name: Run Extended Fuzz Tests
run: |
go test -fuzz=FuzzCreatePatch -fuzztime=15m ./internal/webhook/
go test -fuzz=FuzzHandleMutate -fuzztime=15m ./internal/webhook/
- name: Upload Fuzz Findings
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: fuzz-findings-extended
path: internal/webhook/testdata/fuzz/
retention-days: 30
- name: Create Issue on Failure
if: failure()
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'Extended Fuzz Testing Failed',
body: `Extended fuzz testing failed on ${new Date().toISOString()}\n\nCheck the [workflow run](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}) for details.`,
labels: ['bug', 'fuzz-testing']
})