Skip to content

ci(deadcode): let the tool install fetch the toolchain it needs - #894

Merged
justaugustus merged 1 commit into
ossf:mainfrom
Eljees:ci-deadcode-toolchain
Sep 19, 2026
Merged

justaugustus merged 1 commit into
ossf:mainfrom
Eljees:ci-deadcode-toolchain

Conversation

@Eljees

@Eljees Eljees commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

What is red

Every pull request whose deadcode job has run since 2026-09-08 fails at the install step, before any analysis happens:

go: golang.org/x/tools/cmd/deadcode@latest: golang.org/x/tools@v0.50.0 requires go >= 1.26.0 (running go 1.25.9; GOTOOLCHAIN=local)

golang.org/x/tools v0.50.0 was published on 2026-09-08 and raised its own go directive to 1.26.0. The job installs the tool with @latest, while actions/setup-go takes the Go version from go.mod (1.25.9) and sets GOTOOLCHAIN=local (the setting that forbids the go command from fetching another toolchain), which turns "this module wants a newer toolchain" into a hard error.

Why this is repo-wide rather than anything in one branch

deadcode conclusions on the most recently updated pull requests, ordered by when the check actually ran:

ran (UTC) PR deadcode go directive on that head
2026-09-19 17:04 #894 (this one) success go 1.25.9
2026-09-18 07:17 #893 failure go 1.25.9
2026-09-14 13:36 #892 failure go 1.25.9
2026-09-14 13:34 #890 success go 1.26.0
2026-09-14 13:33 #891 failure go 1.25.9
2026-09-14 13:33 #879 failure go 1.25.9
2026-09-10 02:13 #888 failure go 1.25.9
2026-09-07 05:06 #885 success go 1.25.9
2026-08-17 01:55 #873 success go 1.25.8
2026-08-13 08:00 #872 success go 1.25.8
2026-07-26 20:14 #864 success go 1.25.8

#889 fails the same way, at 2026-09-10 02:13 UTC.

Every run that happened before the v0.50.0 release is green and every run after it is red. The single exception points at the cause: #890 bumps golang.org/x/sync and raises the go directive to 1.26.0 along the way, and its deadcode job passed one minute after #891 failed. The content of the branches has nothing to do with it; #892 touches only two workflow files.

The change

GOTOOLCHAIN=auto on the install step alone, so the go command may fetch the toolchain that building the tool requires. The analysis step is untouched and still runs under the Go version that go.mod declares. The deadcode check on this pull request is the first green one since the release.

Reproduction, before CI confirmed it

With Go 1.25.9 locally, the same version the job installs:

$ GOTOOLCHAIN=local go install golang.org/x/tools/cmd/deadcode@latest
go: golang.org/x/tools/cmd/deadcode@latest: golang.org/x/tools@v0.50.0 requires go >= 1.26.0 (running go 1.25.9; GOTOOLCHAIN=local)
exit=1

$ GOTOOLCHAIN=auto go install golang.org/x/tools/cmd/deadcode@latest
go: golang.org/x/tools@v0.50.0 requires go >= 1.26.0; switching to go1.26.8
exit=0

$ GOTOOLCHAIN=local deadcode ./cmd/allstar/...    # against current main
exit=0, no findings

Alternative, if you prefer it

Pinning the tool instead, go install golang.org/x/tools/cmd/deadcode@v0.49.0, also clears the failure and keeps every toolchain at the version go.mod declares, at the price of a pin that nothing bumps automatically. Say the word and I will switch this pull request over to that.

golang.org/x/tools v0.50.0, released 2026-09-08, requires Go >= 1.26.0.
go.mod declares go 1.25.9 and actions/setup-go pins GOTOOLCHAIN=local, so
since that release the install step of the deadcode job fails before any
analysis runs:

  go: golang.org/x/tools/cmd/deadcode@latest: golang.org/x/tools@v0.50.0
  requires go >= 1.26.0 (running go 1.25.9; GOTOOLCHAIN=local)

Every pull request opened or updated since then carries a red deadcode
check for this reason alone.

GOTOOLCHAIN=auto on that one step lets the go command fetch the toolchain
the tool needs in order to build. The analysis step is untouched and still
runs under the Go version go.mod declares.

Reproduced locally with Go 1.25.9: the install fails under
GOTOOLCHAIN=local, succeeds under GOTOOLCHAIN=auto (switching to
go1.26.8), and the resulting binary reports no dead code in
./cmd/allstar/...

Signed-off-by: Eljees <57435526+Eljees@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The narrowly scoped CI change resolves installation failures without altering analysis behavior.

Review effort: Lite
Findings: None

What changed in this PR

Updates the deadcode CI installation to support required newer Go toolchains.

Changes:

  • Enables GOTOOLCHAIN=auto during installation.
  • Keeps analysis on the repository’s declared Go version.
File Description
.github/​workflows/​pr.yaml Enables automatic toolchain selection for deadcode installation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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

Thanks @Eljees!

@justaugustus
justaugustus merged commit 0323337 into ossf:main Sep 19, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants