feat(foreman): codegen-drift check in the coder fast gate (#775)#778
Open
Defilan wants to merge 2 commits into
Open
feat(foreman): codegen-drift check in the coder fast gate (#775)#778Defilan wants to merge 2 commits into
Defilan wants to merge 2 commits into
Conversation
After the existing gofmt/vet/build/lint/test checks, regenerate manifests, CRDs, and Helm chart CRDs via `make manifests chart-crds foreman-chart-crds`, then run `git diff --quiet`. If the tree is dirty, fail the gate with feedback naming the drifted files so the coder can regenerate in-run. The check is skipped gracefully if controller-gen is not available in the workspace. This catches changes to API types, kubebuilder markers, or field doc comments that alter generated CRDs or role.yaml before they reach CI, avoiding wasted cycles where the fast gate green-lights a change that drifts generated files. Fixes defilantech#775 Signed-off-by: Foreman Bot <chris@mahercode.io>
Signed-off-by: Christopher Maher <chris@mahercode.io>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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
Add a codegen-drift check to the Foreman coder's fast in-workspace gate
(
RunCoderGate). After the existing checks, whenbin/controller-genispresent it runs
make manifests chart-crds foreman-chart-crdsand fails thegate if the tree is dirty, naming the drifted files so the coder regenerates
in-run. Skipped gracefully when the generator is absent. Fixes #775.
Foreman-authored (Strix Qwopus-27B) — Foreman improving its own gate —
gate-verified by the in-cluster verify gate (full
make test, GATE-PASS).Why
The fast gate ran gofmt/vet/build/lint + a changed-package unit-test tier but
not codegen, so a coder change to an API type, marker, or field doc comment
left stale CRDs/
role.yamlthat only surfaced at the cluster gate or CI.Caught live this weekend on #754 (a field doc edit drifted the Model CRD).
How
pkg/foreman/agent/coder_gate.go: newcheckCodegenDrift(ctx, workspace, run)using the injectable
commandRunner; wired intoRunCoderGateas the sixthcheck. Guarded on
bin/controller-gen; amakefailure or a dirtygit diffis reported with the drifted file list and a fix directive.pkg/foreman/agent/coder_gate_test.go: four fake-runner cases — drifts,clean, skipped-when-no-controller-gen, make-fails.
Reviewer note
Adds one
make manifests/codegen run per fast-gate invocation (a few seconds);acceptable for catching the drift in-loop.
git diff --quietcatches modifiedgenerated files (same limitation as the cluster gate for brand-new untracked
files).
Checklist
make testpasses (verify gate Job, GATE-PASS)make lintpasses