Skip to content

refactor(gen): harden generator (errors + smoke test) - #282

Merged
cbrgm merged 7 commits into
mainfrom
phase-4-generator-hardening
Aug 12, 2026
Merged

refactor(gen): harden generator (errors + smoke test)#282
cbrgm merged 7 commits into
mainfrom
phase-4-generator-hardening

Conversation

@cbrgm

@cbrgm cbrgm commented Aug 12, 2026

Copy link
Copy Markdown
Owner

What

Harden the generator itself.

  • refactor main into a thin wrapper + run(outputDir, docs) error that returns errors instead of panic-ing
  • add gen/generate_test.go, a smoke test that runs the generator and checks events.go is produced with the go-github import
  • incidental fix: filepath.Clean(outputDir) replaces filepath.Join(".", outputDir), which silently demoted an absolute --output path to relative

Stacked on #281.

Why

The generator used to panic on every error, which is fine for a one-shot tool but gives no test surface and ugly failures. Returning errors makes it testable and lets main exit non-zero cleanly. The smoke test guards that run() 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 test green, make apidiff -> API compatible

Checklist

  • Tests added/updated (gen/generate_test.go smoke test)
  • No breaking changes (emitted code byte-identical, public API untouched)
  • Readable commit history (1 commit)
  • AI code review considered and comments resolved

cbrgm added 6 commits August 12, 2026 14:49
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
cbrgm force-pushed the phase-3-generic-dispatch branch from 6aa9a45 to 8c76fbe Compare August 12, 2026 12:51
@cbrgm
cbrgm force-pushed the phase-4-generator-hardening branch from 7766143 to 99fca47 Compare August 12, 2026 12:51
Base automatically changed from phase-3-generic-dispatch to main August 12, 2026 12:52
@cbrgm
cbrgm enabled auto-merge (squash) August 12, 2026 12:53
@cbrgm
cbrgm merged commit 03b8fa1 into main Aug 12, 2026
4 checks passed
@cbrgm
cbrgm deleted the phase-4-generator-hardening branch August 12, 2026 12:53
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.

1 participant