ci: cache bun store instead of node_modules#2049
Merged
Merged
Conversation
Caching node_modules with a restore-keys fallback caused CI to restore a stale tree from a different lockfile and then run an incremental 'bun install --frozen-lockfile' on top of it. That incremental install could leave hoisted packages in a broken layout (e.g. @cacheable/memory resolving to the top-level keyv@4 instead of its nested keyv@5), making stylelint crash with 'does not provide an export named Keyv'. Cache bun's content-addressed install store (~/.bun/install/cache) instead and always run 'bun install --frozen-lockfile', so node_modules is rebuilt cleanly from the lockfile on every run while installs stay fast from the warm store.
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
CI's
Test (Demo)→lint:stylestep crashes on dependency/lockfile PRs (first observed on #1974):Root cause
The workflows cached
node_modulesdirectly with arestore-keys:fallback and only ranbun install --frozen-lockfileon a cache miss. When a lockfile changed:restore-keysrestored a stalenode_modulesbuilt from a different lockfile (e.g. develop's@cacheable/memory@2.0.8).cache-hit != 'true', sobun install --frozen-lockfileran incrementally on top of the stale tree.@cacheable/memory(ESM,import { Keyv } from "keyv", needskeyv@5) resolving up to the top-level hoistedkeyv@4.5.4(pulled in by eslint'sflat-cache@3.2.0, no namedKeyvexport) instead of its nestedkeyv@5.6.0→ stylelint crashes before linting anything.A clean
bun install --frozen-lockfileof the same lockfile produces the correct tree and passes — the failure only happens via the cached/incremental path. Cachingnode_moduleswithrestore-keysis the anti-pattern here.Fix
Cache bun's content-addressed install store (
~/.bun/install/cache) instead ofnode_modules, and always runbun install --frozen-lockfile:node_modulesis rebuilt cleanly from the lockfile on every run → correct hoisting, no stale-tree carryover.restore-keysis safe on a package store (it's just tarballs, not a hoisted layout).demo/bun.lockandbun.lock, feeding both the demo and Backpex installs.Applied to both
ci.yml(Backpex + Demo jobs) andelixir-main.yml.Notes
node_modulesvia hardlinks in ~1s.develop, re-running Lock file maintenance #1974's CI (rebased) should go green.