refactor(gen): harden generator (errors + smoke test) - #282
Merged
Conversation
replace exec-based gofmt call in gen/format.go with go/format, so the generator formats in-process instead of shelling out. make format and make generate now run gofumpt -extra over gen and githubevents, matching what golangci-lint expects. repo was already gofumpt v0.7.0 clean, so no output diff.
split main into a thin wrapper plus run(outputDir, docs) error so the
generator body is testable and no longer panics on failure. also
fixed a latent bug where filepath.Join(".", outputDir) silently
dropped an absolute output dir down to a relative one.
add a smoke test that runs the generator into a temp dir and checks
events.go comes out with a go-github import.
cbrgm
force-pushed
the
phase-3-generic-dispatch
branch
from
August 12, 2026 12:51
6aa9a45 to
8c76fbe
Compare
cbrgm
force-pushed
the
phase-4-generator-hardening
branch
from
August 12, 2026 12:51
7766143 to
99fca47
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Harden the generator itself.
maininto a thin wrapper +run(outputDir, docs) errorthat returns errors instead ofpanic-inggen/generate_test.go, a smoke test that runs the generator and checksevents.gois produced with the go-github importfilepath.Clean(outputDir)replacesfilepath.Join(".", outputDir), which silently demoted an absolute--outputpath to relativeStacked on #281.
Why
The generator used to
panicon every error, which is fine for a one-shot tool but gives no test surface and ugly failures. Returning errors makes it testable and letsmainexit non-zero cleanly. The smoke test guards thatrun()actually generates.Testing
go test ./gen/ -v-> all pass (gomod + generate smoke)make generate && git diff --exit-code githubevents/-> clean (byte-identical, generator-internals only)make testgreen,make apidiff-> API compatibleChecklist
gen/generate_test.gosmoke test)