Skip to content

ci: add go-compatibility job to enforce minimum go version#486

Merged
nirs merged 1 commit into
RamenDR:mainfrom
SuchiBhargav:suchi-ci-go-compat
Jul 20, 2026
Merged

ci: add go-compatibility job to enforce minimum go version#486
nirs merged 1 commit into
RamenDR:mainfrom
SuchiBhargav:suchi-ci-go-compat

Conversation

@SuchiBhargav

@SuchiBhargav SuchiBhargav commented Jul 15, 2026

Copy link
Copy Markdown

Problem

The current CI uses actions/setup-go@v6 with go-version-file, which
automatically picks the version from the toolchain directive in go.mod
instead of the go directive.

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 go version declared in go.mod. Since CI silently builds
with 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-compatibility job to the test workflow that:

  • Extracts the minimum required Go version from the go directive in
    go.mod (not the toolchain directive).
  • Sets GOTOOLCHAIN=local so Go cannot silently download/switch to a
    newer toolchain during the build.
  • Installs that exact minimum version via actions/setup-go@v6.
  • Builds the project against it, so the build fails if any code
    references symbols or language features not available in the
    declared minimum Go version.

This mirrors the same approach already added in the ramen repo:
RamenDR/ramen#2499

Fixes #411

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • Tests
    • Added a Go compatibility check to CI that builds the project using the Go version specified in the repository.
    • The check runs on Ubuntu 24.04 and enforces the local Go toolchain configuration for compatibility validation.

Walkthrough

The test workflow adds a go-compatibility job on Ubuntu 24.04. It extracts the Go version from go.mod, configures actions/setup-go, forces the local toolchain, and runs make.

Changes

Go compatibility CI

Layer / File(s) Summary
Go compatibility build
.github/workflows/test.yaml
Adds a go-compatibility job that uses the go.mod version with GOTOOLCHAIN=local and builds through make.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: parikshithb

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the new CI job that enforces the minimum supported Go version.
Description check ✅ Passed The description matches the workflow change and explains the Go compatibility check rationale.
Linked Issues check ✅ Passed The PR implements the requested Go compatibility check for issue #411 by using the go directive and building with GOTOOLCHAIN=local.
Out of Scope Changes check ✅ Passed The changes stay focused on the CI workflow and do not introduce unrelated scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.yaml

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'


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.

❤️ Share

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

@nirs
nirs requested review from nirs and parikshithb July 15, 2026 09:55

@nirs nirs left a comment

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.

  • Add commit message body - see the ramen change for example
  • The commit must have Signed-off-by, see CONTRIBUTING.md

@SuchiBhargav

Copy link
Copy Markdown
Author
  • Add commit message body - see the ramen change for example

    • The commit must have Signed-off-by, see CONTRIBUTING.md

This has been addressed with updated commit message .

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>
@nirs
nirs force-pushed the suchi-ci-go-compat branch from 2e9053b to bd4190d Compare July 20, 2026 11:32

@nirs nirs left a comment

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.

@SuchiBhargav Thanks!

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
.github/workflows/test.yaml (1)

118-135: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Align job steps with other workflow jobs.

To ensure consistency and prevent noisy error messages in the CI logs, consider adding the Create build tag and Download modules steps as done in the build-matrix and test-matrix jobs.

  • Without a local tag, git describe --tags in the Makefile will fail and print a fatal error to the console during the make step.
  • 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

📥 Commits

Reviewing files that changed from the base of the PR and between 2e9053b and bd4190d.

📒 Files selected for processing (1)
  • .github/workflows/test.yaml

@nirs
nirs merged commit 3e27f78 into RamenDR:main Jul 20, 2026
16 checks passed
@SuchiBhargav
SuchiBhargav deleted the suchi-ci-go-compat branch July 20, 2026 12:14
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.

ci: Add go compatibility check

2 participants