ci: add go-compatibility job to enforce minimum go version#486
Conversation
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe test workflow adds a ChangesGo compatibility CI
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Checkov (3.3.8).github/workflows/test.yamlTraceback (most recent call last): 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 |
nirs
left a comment
There was a problem hiding this comment.
- Add commit message body - see the ramen change for example
- The commit must have Signed-off-by, see CONTRIBUTING.md
eb64d6c to
19e5c0b
Compare
This has been addressed with updated commit message . |
33bfe0d to
2e9053b
Compare
The current CI using actions/setup-go@924ae3a with go-version-file automatically picks the version from the 'toolchain' directive in go.mod. While this provides a modern development environment, it can mask "standard library leakage" where features from a newer Go version are used but not available in the minimum supported 'go' version. This change adds a dedicated compatibility job that explicitly installs the base Go version by extracting it from go.mod and setting GOTOOLCHAIN=local. This ensures the build fails if any code references symbols not present in the specified minimum version. Only production code is checked, not tests. Tests are internal and not consumed by downstream users, so they can freely use features from the recommended toolchain. Assisted-by: BOB Signed-off-by: Suchi <hiiamsuchi@gmail.com>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.github/workflows/test.yaml (1)
118-135: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueAlign job steps with other workflow jobs.
To ensure consistency and prevent noisy error messages in the CI logs, consider adding the
Create build tagandDownload modulessteps as done in thebuild-matrixandtest-matrixjobs.
- Without a local tag,
git describe --tagsin theMakefilewill fail and print a fatal error to the console during themakestep.- Explicitly downloading modules matches the pattern used in the rest of the workflow.
♻️ Proposed refactor
- name: Checkout source uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 with: persist-credentials: false + - name: Create build tag + run: git tag latest - name: Extract go version id: go-version run: | version=$(awk '/^go [0-9]/ {print $2}' go.mod) echo "version=$version" >> $GITHUB_OUTPUT - name: Setup go uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0 with: # We cannot use go-version-file since in v6 it picks the toolchain # version instead of go version, ignoring GOTOOLCHAIN=local. go-version: ${{ steps.go-version.outputs.version }} cache: false + - name: Download modules + run: go mod download - name: Build ramenctl run: make🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/test.yaml around lines 118 - 135, Add Create build tag and Download modules steps to the workflow job before Build ramenctl, matching the existing implementations in the build-matrix and test-matrix jobs so git describe and dependency setup follow the established workflow pattern.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In @.github/workflows/test.yaml:
- Around line 118-135: Add Create build tag and Download modules steps to the
workflow job before Build ramenctl, matching the existing implementations in the
build-matrix and test-matrix jobs so git describe and dependency setup follow
the established workflow pattern.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 4703b105-2025-421a-bdea-3c03952b84b6
📒 Files selected for processing (1)
.github/workflows/test.yaml
Problem
The current CI uses
actions/setup-go@v6withgo-version-file, whichautomatically picks the version from the
toolchaindirective ingo.modinstead of the
godirective.While this provides a modern development environment, it can mask
"standard library leakage" — cases where code uses features from a
newer Go version that are not actually available in the minimum
supported
goversion declared ingo.mod. Since CI silently buildswith the newer toolchain version, this kind of incompatibility goes
undetected until a downstream consumer builds the project with only
the minimum supported Go version installed.
Solution
Added a dedicated
go-compatibilityjob to the test workflow that:godirective ingo.mod(not thetoolchaindirective).GOTOOLCHAIN=localso Go cannot silently download/switch to anewer toolchain during the build.
actions/setup-go@v6.references symbols or language features not available in the
declared minimum Go version.
This mirrors the same approach already added in the
ramenrepo:RamenDR/ramen#2499
Fixes #411