test(hosted): isolate package-manager caches in the production e2e suite - #144
Open
John-David Dalton (jdalton) wants to merge 1 commit into
Conversation
e2e_hosted_production.rs drives a real install for every ecosystem it covers — npm, pnpm, yarn, bun, go, pip, gem, bundler, composer, nuget — through one `tool()` helper. That helper pins a private cache per leg for the toolchains each leg names, but everything it does not name still resolves out of the caller's home directory. Corepack is the big one: the first `pnpm`/`yarn` invocation downloads a whole package manager into ~/.cache/node/corepack. `cache_env::isolate()` is the same one-liner the rest of the CLI integration suites use. It goes in before the per-leg `env` entries so those still win, which is what keeps the deliberately-cold reinstall legs cold. Split out of the sibling change that isolates the other suites, because this file's CI leg (`hosted-e2e`) is currently red for an unrelated server-side reason and should not hold that PR up.
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.
e2e_hosted_production.rsis now the one CLI integration suite that still writes package-manager caches into whoever's home directory ran it. #143 fixed every other suite incrates/socket-patch-cli/tests/; this file needs the identical one-liner, and that is the whole diff — acache_env::isolate(&mut cmd)call in the sharedtool()helper, plus themoddeclaration that brings the helper in.It is a separate PR because the CI job that covers this file,
hosted-e2e, is currently red for a reason that has nothing to do with this change. To be straight about what the split does and does not buy: that job is a required check with no path filter, so it runs — and fails — on every open PR right now, #143 included. Splitting this file out does not turn #143 green. What it buys is a clean diff, so #143 stays a pure "isolate the caches" change and the whole argument about a production-registry failure lives here, in the one PR that actually touches the file.What the change does — sandboxes the caches the per-leg
envlist does not already nameThe suite drives a real install for every ecosystem it covers, and every one of those installs goes through a single helper,
tool(). That helper already hands each leg a private cache for the toolchains the leg names by hand. Anything it does not name still comes out of the real home directory.Corepack is the big one. The first
pnpmoryarncall downloads an entire package manager into~/.cache/node/corepack— roughly 900 files from a single invocation.cache_env::isolate()closes that and the rest of the set in one call.Placement matters, and it is the same placement used everywhere else in #143:
cache_env::isolate(&mut cmd)enventries the caller passesCommand's env ops are keyed by name and last-write-wins, so the caller still gets the final sayStep 3 is what keeps the deliberately-cold legs cold. Several legs pass an empty cache directory on purpose, to prove a fresh checkout installs the patched bytes rather than a warm host copy of the pristine one. Those values are applied last, so they still win.
The red check is a server-side change, not this diff — one leg, and it fails the same way with the file untouched
Expect
hosted-e2eto be red on this PR. It was already red before this change existed, and it will stay red until the registry side clears. Please do not read it as a signal about this diff.The failing leg is
gem_bundler_hosted_redirect_and_known_install_defect. Bundler falls back from the compact index to the dependency API against Socket's gem patch-registry, and gets back a body it cannot unmarshal:The test is written to tolerate one specific known server defect —
APIResponseMismatchError— and to report anything else as a new regression. This is a different error, so the test flags it. Thirteen of the suite's fourteen legs pass.Three runs say it is not the code:
mainmain, on a branch that no longer touches the file at allThe last green run of
hosted-e2eonmainwas 31 July. So the code is not the variable — something moved on the server between then and now.Unblocking the check itself is not something this PR can do. It needs either the gem patch-registry fix, or a repo admin setting the documented escape hatch (
HOSTED_E2E_DISABLED = trueunder Settings → Secrets and variables → Actions → Variables, then re-running the failed job, and deleting the variable afterwards to re-arm).Why the job cannot just be skipped for this PR — the workflow rules it out on purpose
Worth knowing before anyone suggests a path filter or an
if:. The job carries explicit invariants inci.yml, and they are there for good reasons:if:needs:hosted-e2eexactlycontinue-on-errorSo the job always runs and always lands on success or failure. The kill switch gates the steps, never the job.
What I checked — it compiles and it is clean; the suite itself is not something to run from a laptop
Ran —
cargo check --workspace --all-targetson this branch. Clean. Themod cache_env;declaration resolves because #143 supplies the file.Ran —
cargo fmt --check. No diff in this file. (Two unrelated pre-existing diffs show up insrc/commands/lock_cli.rsandsrc/lib.rs; both reproduce onmain.)Ran —
cargo clippy --workspace --all-targets. No new warnings from this file.Did not run — the suite itself. It contacts production Socket endpoints and real package registries for every ecosystem. Driving that traffic from a laptop to verify a cache path is not a reasonable trade, so CI is the check here.
Trade-off — the sandbox is a stable directory under the OS temp dir, not a fresh one per run, so the fixture packages are not re-downloaded on every run. That is the same trade-off #143 makes and the same directory it uses; the details are in that PR.