Skip to content

ci: ensure codegen check fails if file(s) changes detected#238

Open
troian wants to merge 4 commits intomainfrom
ci-codegen
Open

ci: ensure codegen check fails if file(s) changes detected#238
troian wants to merge 4 commits intomainfrom
ci-codegen

Conversation

@troian
Copy link
Member

@troian troian commented Apr 30, 2024

No description provided.

@troian troian requested a review from boz as a code owner April 30, 2024 17:14
Signed-off-by: Artur Troian <troian.ap@gmail.com>
@vertex451 vertex451 requested a review from a team as a code owner January 29, 2026 16:27
vertex451
vertex451 previously approved these changes Jan 29, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 29, 2026

Walkthrough

Adds a GitHub Actions codegen job that detects Go version, runs code generation, and fails if generated files change; removes two go:generate directives; updates fake clientset watch calls to include metav1.ListOptions; changes setConfigDefaults to not return an error; and adds context-aware List/Watch variants in multiple informers.

Changes

Cohort / File(s) Summary
GitHub Actions Workflow
.github/workflows/tests.yaml
Adds a codegen job: checkout full history, detect Go version, setup Go and direnv, run code generation, and verify no repo changes. Adds codegen as a dependency for release-dispatch and coverage jobs.
Generate directives removed
cluster/service.go
Removes two //go:generate mockery --name ... directives above Cluster and Service; no interface changes.
Fake clientset watch changes
pkg/client/clientset/versioned/fake/clientset_generated.go
Adds metav1 import and changes reactor watch calls to use metav1.ListOptions (populated from action when possible) and returns (true, watch, nil) from watch reactor.
Client config defaults change
pkg/client/clientset/versioned/typed/akash.network/v2beta2/akash.network_client.go
Changes setConfigDefaults to no longer return an error and removes error handling at callers (NewForConfig, NewForConfigAndClient).
Informer context-aware List/Watch
pkg/client/informers/externalversions/akash.network/v2beta2/...
inventory.go, inventoryrequest.go, manifest.go, providerhost.go, providerleasedip.go
Replaces context.TODO() with context.Background() in List/Watch; adds context-aware callbacks (ListWithContextFunc, WatchFuncWithContext) that forward a provided context.Context to underlying client List/Watch calls.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Dev as Developer
participant GH as GitHub Actions
participant Repo as Repository
participant Tool as Go toolchain
participant CG as Code generator
GH->>Repo: checkout (full history)
GH->>Tool: detect & set Go version
GH->>GH: configure direnv, export GOVERSION
GH->>CG: run code generation
CG->>Repo: modify generated files (if any)
GH->>Repo: git status / diff check
alt changes detected
GH->>Dev: fail job (codegen modified repo)
else no changes
GH->>Dev: pass job (codegen verified)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰
I hopped through branches, sniffed each line,
Detected Go, then ran the gen in time.
If generated carrots wander from the tree,
The workflow shouts, "Return them to me!"
A little hop, a tidy repo—whee!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive No description was provided by the author, making it impossible to evaluate relevance to the changeset. Add a pull request description explaining the purpose and context of the codegen CI check and related code generation changes.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a codegen CI check that fails when generated files are modified, which aligns with the workflow changes in .github/workflows/tests.yaml.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ci-codegen

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@pkg/client/clientset/versioned/fake/clientset_generated.go`:
- Around line 107-113: Fix the misspelled variable name used when asserting the
watch action: replace the incorrect identifier watchActcion with watchAction in
the NewClientset generated code (the block that does if watchActcion, ok :=
action.(testing.WatchActionImpl); ok { opts = watchActcion.ListOptions }),
ensuring metav1.ListOptions is populated from the correct variable and passed to
o.Watch(gvr, ns, opts); update any other identical occurrences coming from the
generator template so the assertion and subsequent use consistently reference
watchAction.
- Around line 54-60: There is a typo in the variable name used for the type
assertion: change the identifier watchActcion to watchAction wherever it appears
(the short variable in the type assertion action.(testing.WatchActionImpl) and
its subsequent use watchAction.ListOptions) so the code compiles and reads
correctly; if this file is generated, fix the generator template that emits the
variable name instead of editing only this generated file.

Comment on lines +54 to +60
var opts metav1.ListOptions
if watchActcion, ok := action.(testing.WatchActionImpl); ok {
opts = watchActcion.ListOptions
}
gvr := action.GetResource()
ns := action.GetNamespace()
watch, err := o.Watch(gvr, ns)
watch, err := o.Watch(gvr, ns, opts)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Typo in variable name: watchActcion should be watchAction.

There's a typo on line 55: watchActcion instead of watchAction. Since this file is marked as generated code (line 17), this suggests either the code generator has a bug or this file was manually edited.

If manually edited, please fix the typo. If this is generated output, the fix should be applied to the generator template.

🐛 Proposed fix
 	cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
 		var opts metav1.ListOptions
-		if watchActcion, ok := action.(testing.WatchActionImpl); ok {
-			opts = watchActcion.ListOptions
+		if watchAction, ok := action.(testing.WatchActionImpl); ok {
+			opts = watchAction.ListOptions
 		}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
var opts metav1.ListOptions
if watchActcion, ok := action.(testing.WatchActionImpl); ok {
opts = watchActcion.ListOptions
}
gvr := action.GetResource()
ns := action.GetNamespace()
watch, err := o.Watch(gvr, ns)
watch, err := o.Watch(gvr, ns, opts)
var opts metav1.ListOptions
if watchAction, ok := action.(testing.WatchActionImpl); ok {
opts = watchAction.ListOptions
}
gvr := action.GetResource()
ns := action.GetNamespace()
watch, err := o.Watch(gvr, ns, opts)
🤖 Prompt for AI Agents
In `@pkg/client/clientset/versioned/fake/clientset_generated.go` around lines 54 -
60, There is a typo in the variable name used for the type assertion: change the
identifier watchActcion to watchAction wherever it appears (the short variable
in the type assertion action.(testing.WatchActionImpl) and its subsequent use
watchAction.ListOptions) so the code compiles and reads correctly; if this file
is generated, fix the generator template that emits the variable name instead of
editing only this generated file.

Comment on lines +107 to +113
var opts metav1.ListOptions
if watchActcion, ok := action.(testing.WatchActionImpl); ok {
opts = watchActcion.ListOptions
}
gvr := action.GetResource()
ns := action.GetNamespace()
watch, err := o.Watch(gvr, ns)
watch, err := o.Watch(gvr, ns, opts)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Same typo: watchActcion should be watchAction.

The same typo appears here in NewClientset. This reinforces that the issue likely originates from the code generator template.

🐛 Proposed fix
 	cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
 		var opts metav1.ListOptions
-		if watchActcion, ok := action.(testing.WatchActionImpl); ok {
-			opts = watchActcion.ListOptions
+		if watchAction, ok := action.(testing.WatchActionImpl); ok {
+			opts = watchAction.ListOptions
 		}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
var opts metav1.ListOptions
if watchActcion, ok := action.(testing.WatchActionImpl); ok {
opts = watchActcion.ListOptions
}
gvr := action.GetResource()
ns := action.GetNamespace()
watch, err := o.Watch(gvr, ns)
watch, err := o.Watch(gvr, ns, opts)
var opts metav1.ListOptions
if watchAction, ok := action.(testing.WatchActionImpl); ok {
opts = watchAction.ListOptions
}
gvr := action.GetResource()
ns := action.GetNamespace()
watch, err := o.Watch(gvr, ns, opts)
🤖 Prompt for AI Agents
In `@pkg/client/clientset/versioned/fake/clientset_generated.go` around lines 107
- 113, Fix the misspelled variable name used when asserting the watch action:
replace the incorrect identifier watchActcion with watchAction in the
NewClientset generated code (the block that does if watchActcion, ok :=
action.(testing.WatchActionImpl); ok { opts = watchActcion.ListOptions }),
ensuring metav1.ListOptions is populated from the correct variable and passed to
o.Watch(gvr, ns, opts); update any other identical occurrences coming from the
generator template so the assertion and subsequent use consistently reference
watchAction.

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.

2 participants