{{ message }}
[go] Add test CLI setup helper - #2478
Draft
qmuntal wants to merge 3 commits into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The temporary-directory fallback permits cache poisoning, and the primary installation workflow lacks coverage.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review tier: Balanced
Findings: 1
New issues introduced by this change (2)
What changed in this PR
Adds a Go test helper that provisions and caches a compatible Copilot CLI runtime while sharing secure npm package handling with the bundler.
Changes:
- Adds
testcli.Setupwith runtime discovery, integrity verification, and caching. - Introduces shared npm download and extraction utilities.
- Updates Go CLI setup documentation and tests.
| File | Description |
|---|---|
go/testcli/setup.go |
Implements test CLI provisioning and caching. |
go/testcli/setup_test.go |
Tests metadata parsing and cache validation. |
go/testcli/setup_external_test.go |
Tests configured-path handling. |
go/internal/npmregistry/package.go |
Adds npm download and extraction helpers. |
go/internal/npmregistry/package_test.go |
Tests integrity checks and safe extraction. |
go/cmd/bundler/main.go |
Reuses npm registry helpers. |
go/README.md |
Documents testcli.Setup. |
docs/setup/local-cli.md |
Corrects Go CLI path resolution guidance. |
docs/setup/bundled-cli.md |
Clarifies Go runtime precedence. |
Suppressed comments (1)
go/testcli/setup.go:59
- When
UserCacheDiris unavailable on a Unix host, this falls back to a predictable directory beneath shared/tmp. Another local user can pre-create the public version/platform path with a matchingpackage.jsonand.integrity; the pre-lock cache check then trusts and exposes their executable throughCOPILOT_CLI_PATH. Fail setup instead of using a shared cache root, or create a private per-user directory with mode 0700.
cacheDir = os.TempDir()
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
SteveSandersonMS
marked this pull request as draft
September 2, 2026 12:50
Contributor
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
Downstream Go modules need a compatible Copilot CLI to run integration tests, but the Go SDK does not install one as a module dependency. Tests otherwise have to provision and version the CLI themselves or depend on this repository's Node workspace and its installed
node_modules. That makes a normalgo testworkflow harder to reproduce outside the SDK monorepo.Summary
testcli.Setupfor downstream integration tests to resolve and cache the platform CLI package compatible with the Go SDKruntime.nodelibrary used by in-process testsUsage
Call
testcli.Setupfrom the downstream test package'sTestMainbefore running tests:Setuphonors an existingCOPILOT_CLI_PATH. Otherwise, it resolves the CLI package pinned by the SDK version, verifies and caches it, and setsCOPILOT_CLI_PATHfor the test process.Testing
go test ./testcli ./internal/npmregistry ./cmd/bundler -count=1go vet ./testcli ./internal/npmregistry ./cmd/bundlerE2E and replay-harness tests were not run.