Skip to content

Share one dependency cache across CI jobs - #1497

Closed
cristianrgreco wants to merge 1 commit into
claude/compile-whole-repofrom
claude/share-dependency-cache
Closed

cristianrgreco wants to merge 1 commit into
claude/compile-whole-repofrom
claude/share-dependency-cache

Conversation

@cristianrgreco

@cristianrgreco cristianrgreco commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

Folded into #1495.


Stacked on #1496, which is stacked on #1495. Review and merge those first.

Summary

Every job that installs dependencies now restores one shared cache per Node version, instead of one cache per package.

  • npm-setup loses its workspace input and workspace_path output. It always runs npm ci for every workspace, with one cache key per runner, Node version and lockfile.
  • test-template.yml works out the path of the package under test itself.
  • The Lint job and the smoke tests use the shared cache too. Their steps are otherwise unchanged.

Why

Per-package caches (now) Shared cache (this PR)
Entries 97 2 (Node 22.x and 24.x)
Storage 6.4 GB about 0.9 GB
Size restored per job 56 MB median, 344 MB largest 449 MB

The repository is over GitHub's 10 GB Actions cache limit (10.8 GB), so caches are being evicted and jobs fall back to npm ci. On a recent all-green run, the install step in the 176 test jobs took 7s at the median and up to 32s.

Trade-offs

  • About 4s more per job on a cache hit. Restoring the shared cache took 11s on CI, against the 7s median today. Across 176 test jobs that's roughly 12 more runner-minutes per full run, on top of about 190.
  • Test jobs no longer run with only their own module's dependencies installed. That isolation could catch a module importing a package that only another module declares. Biome's noUndeclaredDependencies rule now reports undeclared imports statically.
  • The smoke tests' prune step sees more installed packages. npm prune --omit=dev --workspace packages/testcontainers removes the same 11 packages after either install (336 to 325 with a testcontainers-only install, 1126 to 1115 with a full one). The one case that's weaker: a package testcontainers needs at runtime but lists only as a dev dependency now goes unnoticed if any module also depends on it, where before only the root counted. The step never gave a production-only environment: vitest, TypeScript and Biome stay installed after it either way.
  • First run after a lockfile change: the jobs for a Node version all miss at once and each runs npm ci (35s on CI) until one saves the cache. Today every job also misses on a lockfile change, since each per-package key includes the lockfile hash.

Verification

  • The cache key and path list are the ones the install-everything mode already used on CI in Detect unused code and dependencies with knip #1492, where the first run missed and saved the cache and the next run restored it.
  • The smoke tests' prune step was run locally after both kinds of install, with the results above.
  • action.yml, checks.yml and test-template.yml parse. npm run format: no fixes applied.
  • Checks runs on this PR as part of the stack. An earlier revision of this change passed it in full: all 176 test jobs (which use the new TEST_PATH expression and the shared cache), the three smoke-test jobs, Lint and Compile.

Why this isn't breaking

CI-only. No package source, dependency or published file changes.

@cristianrgreco cristianrgreco added maintenance Improvements that do not change functionality patch Backward compatible bug fix labels Oct 10, 2026
@cristianrgreco
cristianrgreco added this pull request to stack #1498 October 10, 2026 20:35
Make npm-setup always install every workspace, so every job restores the
same cache per Node version instead of one per package. The test jobs
resolve the path of the package under test themselves.
@cristianrgreco
cristianrgreco removed this pull request from stack #1498 October 11, 2026 18:15
@cristianrgreco
cristianrgreco force-pushed the claude/compile-whole-repo branch from 26288f4 to a93d924 Compare October 11, 2026 18:15
@cristianrgreco
cristianrgreco force-pushed the claude/share-dependency-cache branch from 890d4c3 to 534d2ed Compare October 11, 2026 18:15
@cristianrgreco
cristianrgreco added this pull request to stack #1501 October 11, 2026 18:15
@cristianrgreco
cristianrgreco removed this pull request from stack #1501 October 11, 2026 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Improvements that do not change functionality patch Backward compatible bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant