govulncheck: update Go before running the vuln checks#161
Conversation
The `entrypoint.sh` runs the `go mod verify` command which will download the version of Go matching the `toolchain` in `go.mod`. This requires the `GOTOOLCHAIN` env var to be set to `auto` This change sure that the vuln check is executed with the same version of Go as the one used to build the binary :) see https://go.dev/doc/toolchain also, upgrade the code and the builder image to Go 1.24 also, upgrade other GitHub actions to their latest versions Signed-off-by: Xavier Coulon <xcoulon@redhat.com>
WalkthroughUpdates to CI/workflows, container build, and Go toolchain: workflows bump actions/checkout and actions/setup-go to v6; Containerfile and go.mod move to Go 1.24, the built binary is renamed to govulncheckx, and a new entrypoint.sh is added and used as the container ENTRYPOINT. Changes
Sequence Diagram(s)(omitted — changes do not introduce a multi-component runtime control flow requiring a sequence diagram) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
.github/workflows/govulncheck-action-publish.yml(1 hunks).github/workflows/govulncheck-action-test-lint.yml(1 hunks)govulncheck-action/Containerfile(2 hunks)govulncheck-action/entrypoint.sh(1 hunks)govulncheck-action/go.mod(1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.11.0)
govulncheck-action/entrypoint.sh
[error] 12-12: Double quote array expansions to avoid re-splitting elements.
(SC2068)
🔇 Additional comments (5)
govulncheck-action/Containerfile (1)
1-1: LGTM on the builder upgrade, binary rename, and entrypoint setup.The following changes look correct:
- Builder image upgraded to golang:1.24
- Binary renamed to
govulncheckxto avoid conflicts- Both binary and entrypoint script properly copied
GOTOOLCHAIN=autoenvironment variable set- Entrypoint script configured as the container entry point
These changes align well with the PR objectives once the final image version is corrected.
Also applies to: 11-11, 18-19, 21-21, 23-23
govulncheck-action/entrypoint.sh (1)
6-6: Verify that go mod verify runs in the correct working directory.The script runs
go mod verifywhich requires access togo.modandgo.sumfiles. Ensure that when this entrypoint is invoked, the working directory is set to the target repository being scanned (not the govulncheck-action directory itself). Check theaction.ymlconfiguration andDockerfile/Containerfileto confirm theWORKDIRis properly set to the repository root where the Go module files are located..github/workflows/govulncheck-action-publish.yml (1)
16-16: v6 is the latest stable version of actions/checkout—no action needed.Verification confirms that
actions/checkout@v6is the current latest stable version available on the GitHub Marketplace.govulncheck-action/go.mod (1)
3-3: Go 1.24.0 is officially released and stable (as of February 11, 2025), so no action is required..github/workflows/govulncheck-action-test-lint.yml (1)
19-19: actions/setup-go@v6 is the latest stable version and requires no changes.The v6 tag currently resolves to v6.1.0 (released November 20, 2025), which is the latest stable release. Using the major version tag (@v6) is appropriate and allows for automatic patch and minor version updates while preventing breaking changes from major version upgrades.
Signed-off-by: Xavier Coulon <xcoulon@redhat.com>
Signed-off-by: Xavier Coulon <xcoulon@redhat.com>
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (1)
govulncheck-action/Containerfile (1)
13-13: Final image still on Go 1.23 – update to 1.24 to match builder and runtime expectations.The final stage still uses
golang:1.23, while the builder andgo.modare on 1.24. Since the container runsgo mod verifyand relies onGOTOOLCHAIN=autoto pull the toolchain declared in the repo, aligning the base image to Go 1.24 avoids version skew and keeps behavior consistent with the build environment.Consider updating the final stage as well:
-FROM golang:1.23 +FROM golang:1.24
🧹 Nitpick comments (3)
govulncheck-action/Containerfile (2)
10-11: Optional: collapse echo + build into a single RUN layer.Functionally this is fine, but you could slightly simplify the image and reduce layers by combining these into one RUN:
-RUN echo "Building govulncheckx binary for $GOOS/$GOARCH" -RUN GOOS=$GOOS GOARCH=$GOARCH go build -v -o govulncheckx main.go +RUN echo "Building govulncheckx binary for $GOOS/$GOARCH" && \ + GOOS=$GOOS GOARCH=$GOARCH go build -v -o govulncheckx main.go
18-23: Ensureentrypoint.shis executable and consistent with ENV GOTOOLCHAIN usage.Copying
entrypoint.shinto/usr/local/binand usingENTRYPOINT ["entrypoint.sh"]relies on:
/usr/local/binbeing on PATH (true for the standard golang image), and- the script having the executable bit set in git so Docker preserves it on
COPY.Also,
ENV GOTOOLCHAIN=autohere complements the entrypoint logic; if the script is also exportingGOTOOLCHAIN=auto, you’re double-covered (redundant but harmless). Just ensure the shebang and shell used inentrypoint.shmatches what’s available in the base image.govulncheck-action/action.yaml (1)
18-18: Confirm the:entrypoint-testimage tag is intended for production use.Using the
govulncheck-action:entrypoint-testtag here looks like a temporary/testing tag. Before merging, consider whether this should point to a stable tag (e.g.:latestor a versioned tag) that will be published by your release workflow, so consumers of the action don’t depend on a test-specific image name.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
govulncheck-action/Containerfile(2 hunks)govulncheck-action/action.yaml(1 hunks)
🔇 Additional comments (1)
govulncheck-action/Containerfile (1)
1-1: Builder upgraded to Go 1.24 – looks good.Using
golang:1.24in the builder stage aligns with the updatedgo.mod/ toolchain requirements and the PR’s goal of testing against Go 1.24.
|
works fine on codeready-toolchain/guardian-cockpit 🤩 |
Signed-off-by: Xavier Coulon <xcoulon@redhat.com>
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
govulncheck-action/Containerfile (1)
13-25: Final stage now matches Go 1.24; consider a couple of small hardening tweaks.The previous mismatch between builder and final image is resolved — both now use
golang:1.24, and addingGOTOOLCHAIN=autoplus wiringentrypoint.shis consistent with the described behavior.Two optional improvements you may want to consider:
- Use an absolute entrypoint path for clarity and to avoid relying on PATH:
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"].- Optionally pin the image to a patch version (
golang:1.24.x) or digest for better reproducibility.If you decide to pin, ensure the chosen
golang:1.24.x(or digest) matches the version you expectGOTOOLCHAINto bootstrap against in your target repositories.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
govulncheck-action/Containerfile(2 hunks)
🔇 Additional comments (1)
govulncheck-action/Containerfile (1)
1-11: Builder stage upgrade and binary rename look consistent.Using
golang:1.24in the builder and emittinggovulncheckx(with the corresponding echo) aligns with the PR intent and keeps the build stage self-consistent. No issues from this file’s context.Please just double‑check that any callers (e.g., entrypoint script or CI wiring) expect the
govulncheckxbinary name and there are no remaining references to the oldgovulncheckname elsewhere in the repo.
Signed-off-by: Xavier Coulon <xcoulon@redhat.com>
Signed-off-by: Xavier Coulon <xcoulon@redhat.com>
Signed-off-by: Xavier Coulon <xcoulon@redhat.com>
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
govulncheck-action/Containerfile (1)
23-23: Prefer absolute path in ENTRYPOINT for clarity.While
entrypoint.shshould be found via PATH lookup, using the absolute path makes the configuration more explicit and avoids any potential PATH-related issues.Apply this diff to use the absolute path:
-ENTRYPOINT ["entrypoint.sh"] +ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
govulncheck-action/Containerfile(2 hunks)govulncheck-action/entrypoint.sh(1 hunks)govulncheck-action/go.mod(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- govulncheck-action/go.mod
- govulncheck-action/entrypoint.sh
🔇 Additional comments (2)
govulncheck-action/Containerfile (2)
1-1: LGTM! Go 1.24 upgrade and binary rename look good.The builder and final stages both correctly use
golang:1.24, and the binary has been consistently renamed togovulncheckxthroughout the build process.Also applies to: 10-11, 13-13
16-17: LGTM! Helpful documentation.The comments clearly explain the entrypoint's behavior regarding Go version management, which aligns with the PR objectives.
The
entrypoint.shruns thego mod verifycommand which will downloadthe version of Go matching the
toolchainingo.mod.This requires the
GOTOOLCHAINenv var to be set toautoThis change sure that the vuln check is executed with the same version of
Go as the one used to build the binary :)
see https://go.dev/doc/toolchain
also, upgrade the code and the builder image to Go 1.24
also, upgrade other GitHub actions to their latest versions
Signed-off-by: Xavier Coulon xcoulon@redhat.com
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.