Skip to content

ci go improvements#1631

Open
flavio wants to merge 4 commits intokubewarden:mainfrom
flavio:ci-go-improvements
Open

ci go improvements#1631
flavio wants to merge 4 commits intokubewarden:mainfrom
flavio:ci-go-improvements

Conversation

@flavio
Copy link
Copy Markdown
Member

@flavio flavio commented Apr 2, 2026

This PR does some improvements to some GHA that deal with Go.

We now install the same version of go that is mentioned inside of the go.mod file. Moreover, we intruct govulncheck to look also at the go.mod.

@flavio flavio requested a review from a team as a code owner April 2, 2026 10:38
Copilot AI review requested due to automatic review settings April 2, 2026 10:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates GitHub Actions workflows for Go to derive the Go toolchain version from go.mod and ensures the govulncheck workflow also runs when go.mod changes.

Changes:

  • Update govulncheck workflow triggers to include go.mod changes.
  • Switch Go installation in govulncheck and CI jobs from a hard-coded version to go-version-file: go.mod.
  • Remove check-latest: true from Go setup steps in the main CI workflow.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
.github/workflows/govulncheck.yml Trigger govulncheck on go.mod changes and install Go based on go.mod.
.github/workflows/ci.yml Install Go based on go.mod across Go-related CI jobs (tests/lint/manifests).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/ci.yml
Comment on lines 138 to 141
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: "1.26"
check-latest: true # Always check for the latest patch release
go-version-file: "go.mod"
- run: make test-go
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

actions/setup-go is now driven by go.mod, but this step no longer sets check-latest: true. That can lead to CI running a different (and potentially older) Go patch level than other workflows (e.g. govulncheck still forces the latest patch). Consider re-adding check-latest: true here (or alternatively pin via a toolchain go1.x.y directive in go.mod if you want deterministic patch selection).

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/ci.yml
with:
go-version: "1.26"
check-latest: true # Always check for the latest patch release
go-version-file: "go.mod"
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

This setup-go invocation switched to go-version-file, but dropped check-latest: true. If the intent is still “latest patch for the declared Go version”, re-add check-latest: true so e2e tests don’t run against a different patch than other Go jobs.

Suggested change
go-version-file: "go.mod"
go-version-file: "go.mod"
check-latest: true

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/ci.yml
Comment on lines 175 to 178
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: "1.26"
check-latest: true # Always check for the latest patch release
go-version-file: "go.mod"
- name: golangci-lint
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

Same as other Go jobs: after switching to go-version-file, check-latest: true was removed. Unless you intentionally want to test an older cached patch, re-add check-latest: true to keep linting aligned with the patch level used elsewhere.

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/ci.yml
with:
go-version: "1.26"
check-latest: true
go-version-file: "go.mod"
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

This job also switched to go-version-file without check-latest: true. If the goal is “use Go version from go.mod but always get the newest patch”, add check-latest: true here to avoid running controller-gen/manifests generation on a different patch level than other Go checks.

Suggested change
go-version-file: "go.mod"
go-version-file: "go.mod"
check-latest: true

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

@viccuad viccuad left a comment

Choose a reason for hiding this comment

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

Oh, this is nice. We should do the same for the policies repos.

I'm ok with removing check-latest: true, I prefer to pin the version from go.mod.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.46%. Comparing base (2a6b879) to head (f70bb67).
⚠️ Report is 33 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1631      +/-   ##
==========================================
- Coverage   80.48%   80.46%   -0.03%     
==========================================
  Files         127      127              
  Lines       16411    16411              
==========================================
- Hits        13209    13205       -4     
- Misses       3202     3206       +4     
Flag Coverage Δ
rust-tests 80.46% <ø> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread .github/workflows/govulncheck.yml Outdated
Comment on lines +20 to +21
go-version: "1.26"
go-version-file: "go.mod"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We do not need this step. govulncheck-action already install go. You can define the go.mod file in its inputs as well

Considering the action has the check-latest as true by default. I suspect that means the go lang version will be update under the hood. That's what copilot is warning us. Therefore, I would say to remove the setup-go step here and move this configuration to the govulncheck-action instead.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think I need to remove the chack-latest, then the govulncheck is going to use the version cached by this step (hence the one we have inside of go.mod:

The precedence for inputs go-version-input, go-version-file, check-latest, cache, and cache-dependency-path specifying Go version and caches is inherited from actions/setup-go

From the README of the project.

What do you think?

Copy link
Copy Markdown
Member

@jvanz jvanz Apr 2, 2026

Choose a reason for hiding this comment

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

Ah, I just saw the check-latest in this setup-go action. But I think you cannot remove the input. Actually, we need to keep the go version configuration in sync with the govulncheck input values. Otherwise, you will install a go version here and govulncheck may update the version before run.

Copy link
Copy Markdown
Member

@jvanz jvanz left a comment

Choose a reason for hiding this comment

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

I think we need to do a little change. See my comment in the govulncheck.yml file

@viccuad viccuad moved this from Pending review to In Progress in Kubewarden Admission Controller Apr 7, 2026
flavio added 3 commits April 9, 2026 14:56
Check also `go.mod`, plus use the same version of go mentioned inside of
`go.mod`.

Signed-off-by: Flavio Castelli <fcastelli@suse.com>
Signed-off-by: Flavio Castelli <fcastelli@suse.com>
Checkout the source code to ensure `go.mod` is available.

Signed-off-by: Flavio Castelli <fcastelli@suse.com>
Apply lessons learnt from sbomscanner

Signed-off-by: Flavio Castelli <fcastelli@suse.com>
@flavio flavio moved this from In Progress to Pending review in Kubewarden Admission Controller Apr 16, 2026
@flavio
Copy link
Copy Markdown
Member Author

flavio commented Apr 16, 2026

@jvanz ready for review again

Copy link
Copy Markdown
Member

@jvanz jvanz left a comment

Choose a reason for hiding this comment

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

Thanks for the changes! But I think we need to consider the copilot comments. Just to ensure that we are run the same go version in all CI jobs. Maybe we can follow the suggestion from its first comment and define the version including the patch version.

Comment on lines +28 to +29
go-version-input: ""
go-version-file: "go.mod"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@flavio flavio moved this from Pending review to In Progress in Kubewarden Admission Controller Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

4 participants