build: generate every generated file with go generate, and check them all with one stale-file step #513
Labels
No labels
breaking
bug
documentation
enhancement
epic
good first issue
help wanted
refactoring
resolution/duplicate
resolution/invalid
resolution/wontfix
security
severity/critical
severity/high
severity/low
severity/medium
status/abandoned
status/blocked
status/needs-decision
status/needs-info
status/needs-verification
testing
upstream
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
sixfold-space/madtea#513
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What happens
madtea commits three kinds of generated output, each with its own generator and its own check mode:
docs/reference/*.md,internal/mcp/help_generated.gogo run ./cmd/madtea-dev docs generatedocs generate --verifyTHIRD-PARTY-LICENSES.mdscripts/gen-third-party-licenses.shgen-third-party-licenses.sh --checkgo.mod,go.sumgo mod tidygo mod tidy -diffThere is no
//go:generateline anywhere in the repo. A contributor must know each generator, run each one by hand, and read a separateCONTRIBUTING.mdline for each. Every new generator adds a flag, a gate step, and a doc line. The gate only reports stale files; it never tells you the one command that fixes them all, because there is none.The Go way
From
go help generate:^// Code generated .* DO NOT EDIT\.$.//go:generatelines in the source declare the generators, andgo generate ./...runs all of them.The usual CI check is: run the generators, then
git diff --exit-code. The toolchain does the same for modules withgo mod tidy -diff.Ask
//go:generatelines for every generated output: the docs reference andhelp_generated.go(viamadtea-dev docs generate), andTHIRD-PARTY-LICENSES.md(via the script). Put them in the package that owns each output, or in onegen.go.go generate ./...on the feature branch, then commit the output throughfinish. No generated file changes outside a branch.go generate ./..., thengit diff --exit-code, which names every stale file. It replacesdocs generate --verifyandgen-third-party-licenses.sh --check. The license generator keeps its current order in the gate: serial, before the tests, because it runsgo mod download alland restoresgo.sum.CONTRIBUTING.mdsays "rungo generate ./..." once, in place of the per-generator lines, anddocs/contributing/ci.mddescribes the single step.go generate ./...and commits to that same branch. It is still a branch and a PR, never a direct write tomain.Acceptance
go generate ./...on a clean tree changes nothing.go generate ./...fixes all of them.--verifyand--checkmodes are gone from the gate (a generator may keep a check mode for its own tests).CONTRIBUTING.mdhas one generate instruction.