Skip to content

feat(foreman): codegen-drift check in the coder fast gate (#775)#778

Open
Defilan wants to merge 2 commits into
defilantech:mainfrom
Defilan:foreman/issue-775-gate-codegen
Open

feat(foreman): codegen-drift check in the coder fast gate (#775)#778
Defilan wants to merge 2 commits into
defilantech:mainfrom
Defilan:foreman/issue-775-gate-codegen

Conversation

@Defilan

@Defilan Defilan commented Jun 21, 2026

Copy link
Copy Markdown
Member

What

Add a codegen-drift check to the Foreman coder's fast in-workspace gate
(RunCoderGate). After the existing checks, when bin/controller-gen is
present it runs make manifests chart-crds foreman-chart-crds and fails the
gate 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.yaml that 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: new checkCodegenDrift(ctx, workspace, run)
    using the injectable commandRunner; wired into RunCoderGate as the sixth
    check. Guarded on bin/controller-gen; a make failure or a dirty
    git diff is 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.
  • doc comment corrected to reflect six checks (was a stale "five").

Reviewer note

Adds one make manifests/codegen run per fast-gate invocation (a few seconds);
acceptable for catching the drift in-loop. git diff --quiet catches modified
generated files (same limitation as the cluster gate for brand-new untracked
files).

Checklist

  • Tests added/updated (4 cases via the fake runner)
  • make test passes (verify gate Job, GATE-PASS)
  • make lint passes
  • Commits signed off (DCO)

Defilan added 2 commits June 21, 2026 03:01
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

codecov Bot commented Jun 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

[FEATURE] Foreman coder fast gate: catch codegen/CRD drift in-workspace

1 participant