Skip to content

fix(ci): Prefer go.work for toolchain info#3285

Open
dmihalcik-virtru wants to merge 6 commits intomainfrom
DSPX-2565-golang-toolchain-simplify
Open

fix(ci): Prefer go.work for toolchain info#3285
dmihalcik-virtru wants to merge 6 commits intomainfrom
DSPX-2565-golang-toolchain-simplify

Conversation

@dmihalcik-virtru
Copy link
Copy Markdown
Member

@dmihalcik-virtru dmihalcik-virtru commented Apr 8, 2026

Proposed Changes

  • We have been setting toolchain explicitly to satisfy govulncheck
  • Setting it in the go.work file lets us keep everything up to date while only editing one file
  • Updates toolchain to latest on current minor branch: 1.25.9

Checklist

  • I have added or updated unit tests
  • I have added or updated integration tests (if appropriate)
  • I have added or updated documentation

Testing Instructions

Summary by CodeRabbit

  • Chores
    • Removed explicit per-module toolchain pins in favor of workspace-specified toolchain.
    • CI workflows now read Go toolchain from the workspace file instead of hardcoded versions.
    • Workspace regeneration now preserves/restores the original toolchain when present and skips unnecessary work for leaf modules to avoid unintended changes.

@dmihalcik-virtru dmihalcik-virtru requested review from a team as code owners April 8, 2026 19:53
@github-actions github-actions bot added comp:ci Github Actions Work comp:sdk A software development kit, including library, for client applications and inter-service communicati comp:examples comp:lib:fixtures comp:lib:flattening comp:lib:ocrypto labels Apr 8, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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

  • CI Script Update: Updated .github/scripts/work-init.sh to capture and restore the toolchain directive from go.work during workspace regeneration.
  • Go Module Cleanup: Removed redundant toolchain directives from multiple go.mod files across the repository to centralize toolchain management in go.work.

🧠 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
  • Ignored by pattern: .github/workflows/** (2)
    • .github/workflows/checks.yaml
    • .github/workflows/sonarcloud.yml
  • Ignored by pattern: protocol/**/* (1)
    • protocol/go/go.mod
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions github-actions bot added the size/s label Apr 8, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 8, 2026

📝 Walkthrough

Walkthrough

Preserve and restore the Go toolchain directive when regenerating go.work; remove explicit toolchain go1.25.8 lines from multiple go.mod files; update CI workflows to obtain the Go version from go.work instead of hardcoded Go-version fields.

Changes

Cohort / File(s) Summary
Work-init script
.github/scripts/work-init.sh
Capture existing toolchain from go.work into ORIG_TOOLCHAIN, skip workspace rebuild for leaf packages, regenerate workspace files, and conditionally restore toolchain via go work edit -toolchain="$ORIG_TOOLCHAIN" if present.
CI workflows
.github/workflows/checks.yaml, .github/workflows/sonarcloud.yml
Switch Go selection from pinned go-version inputs to reading the version from go.work via go-version-file: go.work / remove hardcoded go-version.
Module manifests (toolchain removal)
examples/go.mod, lib/fixtures/go.mod, lib/flattening/go.mod, lib/identifier/go.mod, lib/ocrypto/go.mod, protocol/go/go.mod, sdk/go.mod, service/go.mod, test/integration/go.mod, tests-bdd/go.mod
Removed toolchain go1.25.8 directives; retained go version lines and existing dependency blocks.

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
    alt ORIG_TOOLCHAIN non-empty
        Script->>GoCLI: run `go work edit -toolchain="$ORIG_TOOLCHAIN"`
        GoCLI-->>File: write toolchain entry
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • pflynn-virtru
  • jakedoublev

Poem

"I’m a rabbit in a modular dell,
I nudged the toolchains, all is well.
Workspaces tidy, pinned lines freed,
Go versions follow the work we need. 🐰"

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(ci): Prefer go.work for toolchain info' directly summarizes the main change: updating CI workflows and scripts to use go.work as the single source of toolchain version information instead of hardcoded versions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch DSPX-2565-golang-toolchain-simplify

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 and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

X-Test Failure Report

opentdfplatformV4175V.dockerbuild
govulncheck-failure-2

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 173.001469ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 81.860681ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 386.966061ms
Throughput 258.42 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 40.818983904s
Average Latency 406.289476ms
Throughput 122.49 requests/second

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

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.

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 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.8 directives from module go.mod files.
  • Update CI workflows to use go-version-file: go.work for Go setup / govulncheck execution.
  • Update .github/scripts/work-init.sh to preserve and restore the toolchain directive when regenerating go.work in 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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 188.52227ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 95.266195ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 389.37154ms
Throughput 256.82 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 40.234011666s
Average Latency 401.055646ms
Throughput 124.27 requests/second

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 195.031346ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 97.552842ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 395.129718ms
Throughput 253.08 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 39.783972669s
Average Latency 396.330397ms
Throughput 125.68 requests/second

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between a08a36c and 8e60ad4.

📒 Files selected for processing (1)
  • .github/scripts/work-init.sh

Comment on lines +75 to +76
go work edit -toolchain="$ORIG_TOOLCHAIN"
echo "[INFO] Restored toolchain ${ORIG_TOOLCHAIN} in go.work"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Handle go work edit failures before logging success.

At Line 75, a failed go work edit still prints the success message at Line 76 and returns success from the block. That can silently run CI with the wrong Go version.

Suggested fix
 if [[ -n "${ORIG_TOOLCHAIN:-}" && -f go.work ]]; then
-  go work edit -toolchain="$ORIG_TOOLCHAIN"
-  echo "[INFO] Restored toolchain ${ORIG_TOOLCHAIN} in go.work"
+  if ! go work edit -toolchain="$ORIG_TOOLCHAIN"; then
+    echo "[ERROR] failed to restore toolchain ${ORIG_TOOLCHAIN} in go.work" >&2
+    exit 1
+  fi
+  echo "[INFO] Restored toolchain ${ORIG_TOOLCHAIN} in go.work"
 fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
go work edit -toolchain="$ORIG_TOOLCHAIN"
echo "[INFO] Restored toolchain ${ORIG_TOOLCHAIN} in go.work"
if [[ -n "${ORIG_TOOLCHAIN:-}" && -f go.work ]]; then
if ! go work edit -toolchain="$ORIG_TOOLCHAIN"; then
echo "[ERROR] failed to restore toolchain ${ORIG_TOOLCHAIN} in go.work" >&2
exit 1
fi
echo "[INFO] Restored toolchain ${ORIG_TOOLCHAIN} in go.work"
fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/scripts/work-init.sh around lines 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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 188.329205ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 89.884735ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 411.526229ms
Throughput 243.00 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 41.609398125s
Average Latency 414.235318ms
Throughput 120.17 requests/second

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>
pflynn-virtru
pflynn-virtru previously approved these changes Apr 8, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
.github/scripts/work-init.sh (1)

75-77: ⚠️ Potential issue | 🟠 Major

Handle go work edit failure before logging success.

Line 76 can fail, but Line 77 always logs success. That can silently leave CI using the wrong toolchain state.

Suggested fix
 if [[ -n "${ORIG_TOOLCHAIN:-}" ]]; then
-  go work edit -toolchain="$ORIG_TOOLCHAIN"
+  if ! go work edit -toolchain="$ORIG_TOOLCHAIN"; then
+    echo "[ERROR] failed to restore toolchain ${ORIG_TOOLCHAIN} in go.work" >&2
+    exit 1
+  fi
   echo "[INFO] Restored toolchain ${ORIG_TOOLCHAIN} in go.work"
 fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/scripts/work-init.sh around lines 75 - 77, The script currently runs
go work edit -toolchain="$ORIG_TOOLCHAIN" and immediately echoes a success
message; change it to check the command's exit status (e.g., using if ! go work
edit -toolchain="$ORIG_TOOLCHAIN"; then ...) so that on failure you log an error
describing the failed go work edit (include $ORIG_TOOLCHAIN in the message) and
exit non‑zero, otherwise log the restored-toolchain success; reference the
ORIG_TOOLCHAIN variable and the go work edit invocation when locating the code
to modify.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In @.github/scripts/work-init.sh:
- Around line 75-77: The script currently runs go work edit
-toolchain="$ORIG_TOOLCHAIN" and immediately echoes a success message; change it
to check the command's exit status (e.g., using if ! go work edit
-toolchain="$ORIG_TOOLCHAIN"; then ...) so that on failure you log an error
describing the failed go work edit (include $ORIG_TOOLCHAIN in the message) and
exit non‑zero, otherwise log the restored-toolchain success; reference the
ORIG_TOOLCHAIN variable and the go work edit invocation when locating the code
to modify.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5a47575e-3ac1-4409-91b5-e32c4e2c484c

📥 Commits

Reviewing files that changed from the base of the PR and between 8e60ad4 and 0dffc2d.

📒 Files selected for processing (7)
  • .github/scripts/work-init.sh
  • .github/workflows/checks.yaml
  • .github/workflows/sonarcloud.yml
  • lib/fixtures/go.mod
  • lib/flattening/go.mod
  • lib/identifier/go.mod
  • lib/ocrypto/go.mod
💤 Files with no reviewable changes (4)
  • lib/ocrypto/go.mod
  • lib/flattening/go.mod
  • lib/identifier/go.mod
  • lib/fixtures/go.mod

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 160.005733ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 85.80451ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 398.321262ms
Throughput 251.05 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 39.435697094s
Average Latency 392.741256ms
Throughput 126.79 requests/second

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

⚠️ Govulncheck found vulnerabilities ⚠️

The following modules have known vulnerabilities:

  • service
  • tests-bdd

See the workflow run for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:ci Github Actions Work comp:examples comp:lib:fixtures comp:lib:flattening comp:lib:ocrypto comp:sdk A software development kit, including library, for client applications and inter-service communicati size/s

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants