fix(golang): respect a caller-set GOTOOLCHAIN when installing hook envs#32
Merged
Conversation
InstallEnvironment unconditionally appended GOTOOLCHAIN=local, clobbering any toolchain the caller pinned. In CI (pinpredict pre-commit-advisory) the workflow pins GOTOOLCHAIN=go<repo version> precisely so hooks whose module requires a newer Go than the runner's PATH go can build — e.g. golangci-lint v2.12.2 needs go >= 1.25.0 while ubuntu-latest ships 1.24.13, so every golang hook install failed with 'go.mod requires go >= 1.25.0 (running go 1.24.13; GOTOOLCHAIN=local)'. Default to local only when GOTOOLCHAIN is unset; an explicit caller value now passes through. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
InstallEnvironmentforlanguage: golanghooks unconditionally appendsGOTOOLCHAIN=local, overriding any toolchain the caller pinned in the environment.In pinpredict CI,
pre-commit-advisory.ymlpinsGOTOOLCHAIN=go<max go.mod version>exactly so hook builds can auto-provision a Go newer than the runner's PATH go. The hardcodedlocaldefeats that pin, and every golang hook env install fails on runners whose Go lags the hook module's requirement:(golangci-lint v2.12.2 requires go ≥ 1.25.0; ubuntu-latest currently ships 1.24.13.) This has failed the advisory job in every pinpredict Go repo on cache miss since the standardized hooks landed — including on their main branches.
Fix
Append
GOTOOLCHAIN=localonly when the caller hasn't setGOTOOLCHAIN. The hermetic default is unchanged; an explicit pin now passes through. Env construction extracted togoInstallEnvwith unit tests for both cases.Gate:
make check(76/76 parity) +make lint(0 issues) green.🤖 Generated with Claude Code