-
Notifications
You must be signed in to change notification settings - Fork 43
Description
🏥 CI Failure Investigation - Run #20984232736
Summary
The CI workflow failed because Go code was not properly formatted before committing. The "Check Go formatting" step in the lint-go job detected unformatted code.
Failure Details
- Run: #20984232736
- Commit: b1b5f4b
- Trigger: push to main
- PR: Fix MCP Gateway v0.0.47+ schema validation in metrics-collector workflow #9903 - "Fix MCP Gateway v0.0.47+ schema validation in metrics-collector workflow"
- Duration: 2.8 minutes
- Failed Job: lint-go (Job ID: 60315087487)
- Failed Step: Step 5 - "Check Go formatting"
Root Cause Analysis
The commit modified workflow files (.github/workflows/metrics-collector.lock.yml and .github/workflows/metrics-collector.md) but Go code in the repository was not properly formatted according to go fmt standards before the commit was pushed.
The CI workflow includes a formatting check that runs:
unformatted=$(go fmt ./...)
if [ -n "$unformatted" ]; then
echo "❌ Code is not formatted. Run 'make fmt' to fix."
exit 1
fiThis check detected that running go fmt ./... would modify files, indicating they were not properly formatted.
Files Changed in Failing Commit
.github/workflows/metrics-collector.lock.yml(+7/-10 lines).github/workflows/metrics-collector.md(+0/-1 lines)
Failed Jobs and Errors
lint-go (Job ID: 60315087487)
- Failed Step: Check Go formatting (Step 5)
- Error:
go fmtdetected unformatted Go code - Root Cause: Code was committed without running
make fmtorgo fmt ./...first
All subsequent steps were skipped:
- Install golangci-lint (skipped)
- Run golangci-lint (skipped)
- Lint error messages (skipped)
Recommended Actions
Immediate Fix
- Run formatting:
make fmt - Recompile workflows:
make recompile - Commit the formatting changes
- Push to main branch
For Future Commits
ALWAYS run before committing:
make agent-finish # Runs build, test, recompile, fmt, lint (~10-15s)Or at minimum:
make fmt # Format Go code
make recompile # Recompile workflow lock files (if workflows changed)Prevention Strategies
Current Documentation Issues
The repository's AGENTS.md file states:
ALWAYS RUN AGENT-FINISH BEFORE COMMITTING:
make agent-finish # Runs build, test, recompile, fmt, lint
However, this requirement was not followed in PR #9903, suggesting:
- The AI agent (Copilot) did not follow the documented workflow
- Pre-commit checks may not be enforced
- The requirement needs to be more prominent in the workflow
Recommended Improvements
- Add pre-commit git hooks to automatically run
make fmt - Update GitHub Actions to run formatting checks on PRs before merge
- Enhance AI agent instructions with stricter formatting requirements
- Add automated reminders in PR templates about running
make agent-finish
AI Team Self-Improvement
Additional Prompting Instructions for AI Coding Agents
BEFORE EVERY COMMIT, you MUST:
- Run formatting:
make fmt(formats Go code usinggo fmt ./...) - Run recompile:
make recompile(recompiles all workflow lock files) - Run complete validation:
make agent-finish(runs build, test, recompile, fmt, lint)
These are NOT optional - they are MANDATORY steps.
Why This Matters
The CI workflow has a "Check Go formatting" step that runs go fmt ./... and fails the build if ANY files would be changed. This means:
- ❌ If you skip
make fmt, your PR will fail CI - ❌ If you modify workflow files without
make recompile, your PR will fail CI - ✅ The only way to prevent CI failures is to run these commands BEFORE committing
Failure Pattern Detection
If you see CI failures with:
- Failed job: "lint-go"
- Failed step: "Check Go formatting"
- Error message: "Code is not formatted. Run 'make fmt' to fix."
This means someone committed code without running formatting. The fix is:
make fmt
git add .
git commit --amend --no-edit
git push --force-with-leaseCommit Checklist for AI Agents
Before every commit:
- Run
make fmt- Format all Go code - Run
make recompile- Recompile workflow lock files (if workflow files changed) - Run
make lint- Check for linting errors - Run
make test-unit- Run unit tests - Run
make agent-finish- Complete validation (recommended)
If you skip these steps, your commit WILL fail CI and waste time.
Historical Context
This is a code quality enforcement failure, not a recurring pattern. The repository has clear documentation about running make agent-finish before commits, but this requirement was not followed in PR #9903.
Pattern Signature: GO_FORMAT_CHECK_FAILED
Severity: Medium
Is Flaky: No
Is Recurring: No
Fix Urgency: Medium
Investigation Notes
- Category: Code Quality - Formatting
- Type: Go Code Formatting Check Failed
- Impact: CI failure blocks the main branch until formatting is fixed
- Time to Fix: ~5 minutes (run
make fmt, commit, push) - Preventable: Yes - following documented pre-commit workflow prevents this
This failure is straightforward and easily preventable by following the repository's documented workflow. The issue highlights the need for better enforcement of pre-commit formatting checks, either through git hooks or automated reminders.
AI generated by CI Failure Doctor
To add this workflow in your repository, run
gh aw add githubnext/agentics/workflows/ci-doctor.md@ea350161ad5dcc9624cf510f134c6a9e39a6f94d. See usage guide.