Skip to content

Onboard CodeRabbit and enable golangci-lint standard linters#5132

Open
dhiller wants to merge 8 commits into
kubevirt:mainfrom
dhiller:worktree-onboard-coderabbit-golangci
Open

Onboard CodeRabbit and enable golangci-lint standard linters#5132
dhiller wants to merge 8 commits into
kubevirt:mainfrom
dhiller:worktree-onboard-coderabbit-golangci

Conversation

@dhiller

@dhiller dhiller commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Port of kubevirt/ci-health#150 to project-infra:

  • Add .coderabbit.yaml with "chill" profile, non-blocking reviews, and path-specific instructions for Go, tests, Prow job YAML, and shell scripts
  • Switch .golangci.yaml from default: none to default: standard (adds errcheck; keeps gocyclo via explicit enable)
  • Add goimports formatter to golangci-lint config
  • Fix all linter warnings across the codebase: errcheck (defer Close patterns, unchecked fs.Parse/tmpl.Execute/os.WriteFile), goimports formatting

This is a prerequisite of replacing Gemini Code Assist (which will be sunset) with CodeRabbit.

Special notes for your reviewer:

  • golangci-lint run ./... passes with 0 issues
  • go test ./... passes for all packages
  • The errcheck fix patterns follow the same approach used in ci-health#150

🤖 Assisted by Claude

dhiller added 5 commits June 11, 2026 10:46
As a precondition for enabling golangci-lint goimports formatter we
reformat source files with import ordering issues.

Assisted-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Daniel Hiller <dhiller@redhat.com>
Re-enable errcheck linter and fix all warnings: use deferred closures
for file/response body Close() calls, suppress fmt.Fprint* to
stdout/stderr with nolint:errcheck, check fs.Parse/tmpl.Execute/
os.WriteFile return values, and use blank identifier for cleanup
operations like os.RemoveAll.

Assisted-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Daniel Hiller <dhiller@redhat.com>
Switch from default: none with explicit linter list to default: standard
which includes errcheck, govet, ineffassign, staticcheck, and unused.
Re-add gocyclo via enable: since it is not part of the standard set.
Add goimports formatter for automatic import ordering.

Assisted-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Daniel Hiller <dhiller@redhat.com>
Add CodeRabbit configuration with "chill" profile and non-blocking
reviews. Enable golangci-lint integration and add path-specific review
instructions for Go code, tests, Prow job configs, and shell scripts.

This is a prerequisite of replacing Gemini Code Assist (which will be
sunset) with CodeRabbit.

Assisted-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Daniel Hiller <dhiller@redhat.com>
The original code intentionally ignored the generateReleaseNotes error
since release notes generation failing should not block tag creation.
Change from hard error to warning log to preserve this behavior.

Assisted-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Daniel Hiller <dhiller@redhat.com>
@kubevirt-bot

Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@kubevirt-bot kubevirt-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. size/L labels Jun 11, 2026
@kubevirt-bot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign tiraboschi for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request systematically addresses unhandled errors across the codebase by explicitly ignoring them, adding inline linter bypasses, or properly handling deferred cleanups. The review feedback highlights several critical areas for improvement: first, ignoring errors on deferred Close() calls for GCS writers can lead to silent upload failures, so these should be explicitly checked on success paths. Second, rather than scattering //nolint:errcheck comments across dozens of fmt.Fprint* calls, the linter should be configured globally in .golangci.yaml. Finally, the feedback addresses inconsistent error handling in release-tool.go and corrects an anti-pattern in org-access-check/main.go where os.WriteFile is used on an already open temporary file.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread pkg/mirror/bazel.go Outdated
Comment thread robots/flakefinder/report.go Outdated
Comment thread .golangci.yaml
Comment thread releng/release-tool/release-tool.go Outdated
Comment thread robots/org-access-check/main.go Outdated
- Add errcheck exclude-functions for fmt.Fprint/Fprintf/Fprintln in
  .golangci.yaml and remove all inline //nolint:errcheck comments
- Check GCS writer Close() errors on success path in pkg/mirror/bazel.go
  since Close() performs the actual upload
- Check GCS writer Close() errors via named return in
  robots/flakefinder/report.go for all three report writers
- Use writeString helper in releng/release-tool for consistent error
  handling across all WriteString calls
- Fix os.WriteFile anti-pattern in robots/org-access-check: use
  temp.Write() on the already-open file handle instead

Assisted-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Daniel Hiller <dhiller@redhat.com>
@dhiller

dhiller commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

/gemini please review again

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces widespread improvements to error handling, resource cleanup, and linter compliance across the codebase, including wrapping deferred close operations, explicitly ignoring unhandled errors, and updating the static analysis configurations. The review feedback correctly highlights two critical issues where defer is used inside for loops in pkg/mirror/bazel.go and robots/per-test-execution/main.go, which could lead to resource leaks and file descriptor exhaustion.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread pkg/mirror/bazel.go Outdated
Comment thread robots/per-test-execution/main.go Outdated
@dhiller

dhiller commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

Replace deferred Close() calls inside for loops with explicit close on
each exit path, preventing accumulation of unclosed resources across
loop iterations.

Assisted-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Daniel Hiller <dhiller@redhat.com>
@dhiller

dhiller commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces widespread updates across the codebase to improve error handling, resource cleanup, and linter compliance. Key changes include updating the .golangci.yaml configuration, explicitly ignoring unused return values (such as _ = fs.Parse(...) and _ = writer.Write(...)), wrapping deferred close operations in anonymous functions to ignore their errors, and adding proper error assertions in tests. Feedback on these changes highlights two issues: a potential connection leak in pkg/flake-stats/report.go if the HTTP status check fails before the body is deferred closed, and a potential nil pointer dereference panic in external-plugins/referee/metrics/metrics_test.go if the response is nil when the test times out.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread pkg/flake-stats/report.go Outdated
Comment thread external-plugins/referee/metrics/metrics_test.go Outdated

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces widespread improvements across the codebase to address unhandled errors, explicitly ignore discarded errors, and ensure proper resource cleanup, alongside updates to the linter configurations. The review feedback highlights critical issues where calling Close() on GCS writers during error paths or checksum mismatches commits corrupted or partial data to Google Cloud Storage; it is recommended to use CloseWithError(err) to safely abort these writes. Additionally, the feedback suggests wrapping a loop body in an immediately invoked function expression (IIFE) to manage file resources safely with defer rather than relying on fragile manual close calls before multiple return statements.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread pkg/mirror/bazel.go
Comment thread robots/flakefinder/report.go
Comment thread robots/test-label-analyzer/cmd/stats.go Outdated
Comment thread robots/per-test-execution/main.go Outdated
- Use context cancellation to abort GCS writer uploads on error paths
  instead of Close() which commits partial/corrupt data (bazel.go,
  report.go, stats.go)
- Check GCS writer Close() error on success path (stats.go)
- Move resp.Body.Close() defer before status check to prevent
  connection leak on non-200 responses (flake-stats/report.go)
- Add nil check on resp before closing body in test (metrics_test.go)
- Extract readTopXFromFile helper so defer scopes correctly per
  iteration instead of accumulating in loop (per-test-execution)

Assisted-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Daniel Hiller <dhiller@redhat.com>
@dhiller dhiller marked this pull request as ready for review June 11, 2026 15:10
@kubevirt-bot kubevirt-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 11, 2026
@kubevirt-bot

Copy link
Copy Markdown
Contributor

@dhiller: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-project-infra-ci-search-deploy-test 55cd2c9 link true /test pull-project-infra-ci-search-deploy-test
Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@dhiller

dhiller commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

/uncc @rthallisey
/cc @Whitedyl

@kubevirt-bot kubevirt-bot requested review from Whitedyl and removed request for rthallisey June 12, 2026 07:54
@dhiller

dhiller commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

/test pull-project-infra-ci-search-deploy-test

🤖 Assisted by Claude

@kubevirt-prow

kubevirt-prow Bot commented Jun 12, 2026

Copy link
Copy Markdown

@dhiller: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-project-infra-ci-search-deploy-test 55cd2c9 link true /test pull-project-infra-ci-search-deploy-test
Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has DCO signed all their commits. size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants