ci: gate gofmt in golangci-lint, add make fmt - #330
Conversation
Nothing enforced formatting before this: .golangci.yml had no `formatters` section and no workflow ran gofmt, so six files drifted unnoticed until #329. This closes the loop so it can't recur silently. Enabling the gofmt formatter means `golangci-lint run` reports a formatting diff as an issue and exits non-zero — which gates both `make lint` locally and the CI lint job (golangci-lint-action runs `run` by default), so no workflow change is needed. Generated code is excluded via `exclusions.generated: strict`: genqlient's output carries the standard "Code generated by … DO NOT EDIT." header, and a formatting complaint there isn't hand-fixable since `make generate` rewrites the file. Verified — drift injected into internal/api/gen/generated.go is seen by `gofmt -l` but correctly ignored by the linter. `make fmt` (golangci-lint fmt) applies the fixes, so a failing gate has an obvious remedy. Verified end to end: clean tree passes; injected drift fails `make lint`; `make fmt` repairs it byte-for-byte; `make lint` passes again. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
@codex review |
There was a problem hiding this comment.
Pull request overview
This PR tightens the Go formatting contract by making gofmt enforcement part of the existing golangci-lint gate, preventing formatting drift from silently accumulating in the repo’s Go codebase.
Changes:
- Enable the
gofmtformatter in.golangci.ymlsogolangci-lint runfails on formatting diffs. - Add
make fmtas the standard remediation path viagolangci-lint fmt. - Document the new formatting gate and
make fmtinCLAUDE.md.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
Makefile |
Adds a fmt target (golangci-lint fmt) and marks it phony to provide an easy fix path for formatting-gate failures. |
CLAUDE.md |
Updates the developer command list to reflect that make lint gates gofmt and introduces make fmt. |
.golangci.yml |
Enables the gofmt formatter and excludes generated code (generated: strict) to avoid non-actionable failures on committed generated output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Follow-up to #329, which fixed six drifted files. This stops the drift recurring silently.
Nothing enforced formatting before:
.golangci.ymlhad noformatterssection and no workflow shelled out togofmt, so the drift was invisible to CI.The change
Enabling the gofmt formatter makes
golangci-lint runreport a formatting diff as an issue and exit non-zero. That gates bothmake lintlocally and the CI lint job —golangci-lint-actionrunsrunby default — so no workflow change is needed.Plus a
make fmttarget (golangci-lint fmt) so a failing gate has an obvious remedy, and a line in CLAUDE.md's command list.Generated code is excluded, and I verified it
genqlient's output would otherwise be a trap: you can't hand-fix it, since
make generaterewrites the file.exclusions.generated: strictkeys off the standard header, whichinternal/api/gen/generated.gocarries:Injecting drift into that file:
Verified end to end
The failure output names the file, line, and offending source line:
go test ./...— 16 packages green.make lint— 0 issues.One thing to expect
Any in-flight branch that has drifted will start failing the lint job until it runs
make fmt.mainis clean as of #329, so nothing is failing now.🤖 Generated with Claude Code