Skip to content

feat(review): golangci-lint runs offline in the review sandbox - #2622

Merged
dan-petty merged 2 commits into
mainfrom
feat/2129-golangci-lint-sandbox
Oct 29, 2026
Merged

dan-petty merged 2 commits into
mainfrom
feat/2129-golangci-lint-sandbox

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

golangci-lint loads packages through the go command. The review sandbox (#2096) has no network, a read-only tree and a PATH of system directories, so golangci-lint could not run there.

  • The scan reads go env -json GOROOT GOMODCACHE on the host, outside the tree, with GOTOOLCHAIN=local.
  • The request binds the toolchain and the module cache read-only, puts the bin of the toolchain first on the PATH, and keeps GOCACHE and GOLANGCI_LINT_CACHE outside the tree.
  • GOPROXY=off and GOTOOLCHAIN=local stop all fetches. The request sets no GOFLAGS: the -mod=mod of the issue ignores vendor/ and writes go.mod in the read-only tree.
  • A module whose modules are not in the module cache gives a coverage gap that names go mod download.
  • BaseSecurityScanner gets the hooks tool_env and coverage_gap, and tree_cache_dir, which the Ruff cache uses too.

Closes #2129

@dan-petty

Copy link
Copy Markdown
Owner Author

Test results

Fail-to-pass (uv run devops ci fail-to-pass --base origin/main): 3 tests fail on the base and pass on the branch.

  • test_a_scan_gets_the_go_toolchain_and_the_module_cache_read_only_and_no_network: on the base, the scan starts no go env.
  • test_a_host_whose_go_env_fails_gives_a_failed_scan: on the base, the scan runs (ran).
  • test_a_module_whose_modules_are_not_in_the_cache_is_a_coverage_gap: on the base, the scan fails (failed).

test_golangci_lint_typecheck_failure_records_failed moved from patch and MagicMock to the process fake and ToolExecutorFake. It passes on the base and on the branch.

Local checks on the branch:

Premise checks

  • golangci-lint 1.64.6, which tools.lock pins, runs on this host with no go on the PATH. golangci-lint run --out-format sarif printed failed to load with go/packages: err: go command required, not found: exec: "go": executable file not found in $PATH, and it tried go env -json GOCACHE GOROOT.
  • GOLANGCI_LINT_CACHE=<dir> golangci-lint cache status printed Dir: <dir>.
  • The text module lookup disabled by GOPROXY=off comes from errProxyOff in cmd/go/internal/modfetch/proxy.go.

Live check: not run

This host has no Go toolchain (command -v go finds nothing), so golangci-lint did not run in the sandbox here. The change records this check as "Pending a person":

  1. On a host with Go, bubblewrap and golangci-lint 1.64.6, run go mod download in a small module that requires one module and holds one errcheck finding.
  2. Run devops review path on it, and confirm that golangci-lint gives the finding.
  3. Point GOMODCACHE at an empty directory, review again, and confirm the coverage gap.

The stderr in the coverage-gap test joins two parts:

  • the text of golangci-lint for a failed package load, measured above;
  • the error text of the go command from its source.

It is not a recording of a real run.

@dan-petty
dan-petty marked this pull request as ready for review October 29, 2026 04:16
golangci-lint loads packages through the go command. The review sandbox has no network, a
read-only tree and a PATH of system directories, so the scan now gives golangci-lint the toolchain
and the module cache that `go env` names on the host, read-only, with the toolchain first on the
PATH, and keeps the Go build cache and the golangci-lint cache outside the tree. GOPROXY=off and
GOTOOLCHAIN=local keep the go command from fetching. A module whose modules are not in the module
cache is a coverage gap that tells the person to run `go mod download`.

BaseSecurityScanner gets the hooks tool_env and coverage_gap, and tree_cache_dir, which the Ruff
cache now uses too.

Refs #2129
@dan-petty
dan-petty force-pushed the feat/2129-golangci-lint-sandbox branch from f16b787 to 297f9aa Compare October 29, 2026 04:24
@dan-petty
dan-petty merged commit 20915ce into main Oct 29, 2026
17 checks passed
@dan-petty
dan-petty deleted the feat/2129-golangci-lint-sandbox branch October 29, 2026 04:49
dan-petty pushed a commit that referenced this pull request Oct 29, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.15.0](v0.14.0...v0.15.0)
(2026-10-29)


### Features

* **k8s:** derived push entries, Secret types, one stack list
([#2618](#2618))
([3634c6f](3634c6f)),
closes [#2008](#2008)
* **k8s:** image-pins refuses an image on the latest tag
([#2617](#2617))
([548b3ba](548b3ba)),
closes [#2093](#2093)
* **monitoring:** alert when a noeviction Valkey nears its bound
([#2615](#2615))
([f452644](f452644)),
closes [#2094](#2094)
* **review:** golangci-lint runs offline in the review sandbox
([#2622](#2622))
([20915ce](20915ce)),
closes [#2129](#2129)
* **review:** the SARIF export writes how each tool run ended
([#2620](#2620))
([8f8ef44](8f8ef44)),
closes [#2100](#2100)


### Bug Fixes

* **release:** parse release pull request number safely in urgent merge
([#2621](#2621))
([262244d](262244d))

---
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: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
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.

feat(review): golangci-lint runs in the review sandbox with a pre-fetched module cache and no network

1 participant