Skip to content

Add fuzz tests to ci#156

Open
dmcgowan wants to merge 1 commit intocontainerd:mainfrom
dmcgowan:add-ci-fuzz-tests
Open

Add fuzz tests to ci#156
dmcgowan wants to merge 1 commit intocontainerd:mainfrom
dmcgowan:add-ci-fuzz-tests

Conversation

@dmcgowan
Copy link
Copy Markdown
Member

Run fuzz tests as a part of CI

Signed-off-by: Derek McGowan <derek@mcg.dev>
Copilot AI review requested due to automatic review settings April 13, 2026 05:59
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the GitHub Actions CI workflow to run Go unit tests and Go fuzz tests as part of pull request/merge-queue validation.

Changes:

  • Add a new “Unit Tests” CI job running go test -race across all non-integration packages.
  • Add a new “Fuzz Tests” CI job that discovers Fuzz* targets and runs each for a fixed fuzzing duration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/ci.yml
Comment on lines +145 to +151
grep -r --include='*_test.go' -l '^func Fuzz' . | while read -r file; do
pkg=$(dirname "$file")
grep -o '^func Fuzz[A-Za-z0-9_]*' "$file" | sed 's/^func //' | while read -r target; do
echo "=== Fuzzing ${target} in ${pkg} ==="
go test "${pkg}" -fuzz="^${target}$" -fuzztime=60s
done
done
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fuzz step will fail the job when no fuzz targets exist. In GitHub Actions’ default bash settings (errexit + pipefail), grep -r ... -l '^func Fuzz' exits 1 when it finds no matches, which currently happens in this repo (no func Fuzz... found). Make this step a no-op when there are no fuzz tests (e.g., capture matches and exit 0 when empty) or add the fuzz tests in the same PR.

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/ci.yml
# Find all packages containing fuzz tests and run each target.
# go test -fuzz only accepts one package at a time and one
# matching fuzz target, so we discover and iterate.
grep -r --include='*_test.go' -l '^func Fuzz' . | while read -r file; do
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grep -r ... . will recursively scan everything in the checkout (including .git/ and any vendored/generated directories), which can be slow and may produce false positives. Prefer restricting discovery to tracked Go test files (e.g., via git ls-files '*_test.go') and/or explicitly excluding .git, vendor, and _output from the search.

Suggested change
grep -r --include='*_test.go' -l '^func Fuzz' . | while read -r file; do
git ls-files '*_test.go' | while read -r file; do
grep -q '^func Fuzz' "$file" || continue

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants