fix(ci): Prefer go.work for toolchain info#3285
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refines how Go toolchain versions are managed within the CI pipeline. By centralizing the toolchain definition in the workspace file and ensuring it is preserved during automated workspace regeneration, the changes ensure consistent Go version usage across various CI tasks. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Ignored Files
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. The workspace shifts and changes form, / To keep the build safe from the storm. / The toolchain stays, a steady guide, / With versions locked, side by side. Footnotes
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughPreserve and restore the Go Changes
Sequence Diagram(s)sequenceDiagram
participant Script as Work-init.sh
participant File as go.work
participant GoCLI as go CLI
Script->>File: read toolchain directive (if present)
Script->>Script: store ORIG_TOOLCHAIN
Script->>File: delete/regenerate go.work and go.work.sum
Script->>GoCLI: run workspace init/rebuild commands (unless leaf package -> exit)
alt ORIG_TOOLCHAIN non-empty
Script->>GoCLI: run `go work edit -toolchain="$ORIG_TOOLCHAIN"`
GoCLI-->>File: write toolchain entry
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
X-Test Failure Report |
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
There was a problem hiding this comment.
Code Review
This pull request removes the 'toolchain' directive from various 'go.mod' files and updates the '.github/scripts/work-init.sh' script to preserve and restore the toolchain directive during workspace regeneration. I have suggested an improvement to the toolchain extraction logic using a more efficient 'awk' command and noted that the restoration logic should be scoped to avoid redundant operations on leaf packages.
There was a problem hiding this comment.
Pull request overview
This PR centralizes Go toolchain/version selection in go.work (instead of repeating toolchain directives across module go.mod files) and updates CI to read the version from go.work, keeping patch-level toolchain configuration in one place.
Changes:
- Remove
toolchain go1.25.8directives from modulego.modfiles. - Update CI workflows to use
go-version-file: go.workfor Go setup / govulncheck execution. - Update
.github/scripts/work-init.shto preserve and restore thetoolchaindirective when regeneratinggo.workin release-branch validation flows.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests-bdd/go.mod | Removes per-module toolchain directive to rely on workspace toolchain configuration. |
| test/integration/go.mod | Removes per-module toolchain directive to rely on workspace toolchain configuration. |
| service/go.mod | Removes per-module toolchain directive to rely on workspace toolchain configuration. |
| sdk/go.mod | Removes per-module toolchain directive to rely on workspace toolchain configuration. |
| protocol/go/go.mod | Removes per-module toolchain directive to rely on workspace toolchain configuration. |
| lib/ocrypto/go.mod | Removes per-module toolchain directive to rely on workspace toolchain configuration. |
| lib/identifier/go.mod | Removes per-module toolchain directive to rely on workspace toolchain configuration. |
| lib/flattening/go.mod | Removes per-module toolchain directive to rely on workspace toolchain configuration. |
| lib/fixtures/go.mod | Removes per-module toolchain directive to rely on workspace toolchain configuration. |
| examples/go.mod | Removes per-module toolchain directive to rely on workspace toolchain configuration. |
| .github/workflows/sonarcloud.yml | Switches Go setup to read version from go.work. |
| .github/workflows/checks.yaml | Switches govulncheck to read Go version from go.work. |
| .github/scripts/work-init.sh | Preserves/restores toolchain in regenerated go.work to keep CI version selection stable. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/scripts/work-init.sh:
- Around line 75-76: The script currently runs go work edit
-toolchain="$ORIG_TOOLCHAIN" and immediately echoes a success message; update
the block that invokes go work edit to check the command exit status (or use set
-e around it) and only echo "[INFO] Restored toolchain ${ORIG_TOOLCHAIN} in
go.work" when go work edit succeeds; if it fails, emit an error like "[ERROR]
Failed to restore toolchain ${ORIG_TOOLCHAIN}: <error>" and exit with a non-zero
status so CI fails instead of continuing with a wrong Go version.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: a9916964-10dc-4d38-923a-1a7526e6596a
📒 Files selected for processing (1)
.github/scripts/work-init.sh
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
Leaf packages (lib/*, protocol/go) skip workspace regeneration, so the toolchain restore logic should not run either. Exit early to avoid touching go.work unnecessarily. Addresses Gemini review feedback on PR #3285. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Dave Mihalcik <dmihalcik@virtru.com>
AFAIK dependabot only updates the toolchain as a side effect of dep updates, so it isn't predictable already. It will continue to add toolchain directives to the go.mod files if a dep adds a toolchain dep greater than the one in the go.work, but it will disappear with mod tidy when the go.work is updated past it. |
d649e3f
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
Signed-off-by: Dave Mihalcik <dmihalcik@virtru.com>
d649e3f to
71c326e
Compare
|
I've added a commit to include the new otdfctl go.mod, as well as consolidate the setup-go actions on go.work |
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
|
🤖 I have created a release *beep* *boop* --- ## [0.33.0](otdfctl/v0.32.0...otdfctl/v0.33.0) (2026-06-09) ### Features * **cli:** improve auth ([#3466](#3466)) ([b244910](b244910)) * **core:** add hybrid NIST EC + ML-KEM key wrapping support ([#3276](#3276)) ([1209acc](1209acc)) ### Bug Fixes * **ci:** Prefer go.work for toolchain info ([#3285](#3285)) ([3c05b22](3c05b22)) * **cli:** deprecate flaghelper for new flags ([#3583](#3583)) ([8f3c429](8f3c429)) * **deps:** bump github.com/opentdf/platform/lib/ocrypto from 0.10.0 to 0.11.0 in /otdfctl ([#3530](#3530)) ([745a205](745a205)) * **deps:** bump github.com/opentdf/platform/lib/ocrypto from 0.11.0 to 0.12.0 in /otdfctl ([#3536](#3536)) ([8d1c018](8d1c018)) * **deps:** bump github.com/opentdf/platform/protocol/go from 0.30.0 to 0.31.0 in /otdfctl ([#3499](#3499)) ([fa91478](fa91478)) * **deps:** bump github.com/opentdf/platform/protocol/go from 0.31.0 to 0.32.0 in /otdfctl ([#3531](#3531)) ([23946e4](23946e4)) * **deps:** bump github.com/opentdf/platform/sdk from 0.17.0 to 0.21.0 in /otdfctl ([#3549](#3549)) ([1cb751e](1cb751e)) * **deps:** bump the external group across 1 directory with 4 updates ([#3494](#3494)) ([5b87b2b](5b87b2b)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: opentdf-automation[bot] <149537512+opentdf-automation[bot]@users.noreply.github.com>
🤖 I have created a release *beep* *boop* --- ## [0.22.0](sdk/v0.21.0...sdk/v0.22.0) (2026-06-15) ### Bug Fixes * **ci:** Prefer go.work for toolchain info ([#3285](#3285)) ([3c05b22](3c05b22)) * **deps:** bump github.com/opentdf/platform/protocol/go from 0.32.0 to 0.33.1 in /sdk ([#3609](#3609)) ([d5cfc8d](d5cfc8d)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: opentdf-automation[bot] <149537512+opentdf-automation[bot]@users.noreply.github.com>
Proposed Changes
govulncheckgo.workfile lets us keep everything up to date while only editing one fileChecklist
Testing Instructions
Summary by CodeRabbit