fix(ci): build workspace per job instead of sharing dist via cache#192
Closed
merencia wants to merge 1 commit into
Closed
fix(ci): build workspace per job instead of sharing dist via cache#192merencia wants to merge 1 commit into
merencia wants to merge 1 commit into
Conversation
The setup action cached build outputs (**/dist, node_modules) under a key scoped to github.sha. The downstream lint/test/integration jobs do not build; they rely on restoring that cache. Because actions/cache never overwrites an existing key, a corrupted or partial upload (e.g. a job cancelled mid-upload by cancel-in-progress during a merge train) stuck permanently: every re-run of that SHA restored the broken cache, so build passed while lint/test/integration failed with missing dist (unresolved types, 'Cannot find module .../dist'). Scope the key to github.run_id + github.run_attempt instead. Jobs within one run still share build outputs, but each run/re-run gets a fresh key, so a bad cache can never block a re-run. No cross-commit reuse is lost (the SHA key already prevented that).
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
Master CI went red after merging #189/#190/#191, although each PR was green and the changes were docs/metadata only (no TS). The
buildjob passed, butlint,test, andintegration-testfailed with missing build outputs (unresolved types;Cannot find module .../sidequest/dist/index.cjs).Root cause
The
setupaction cached build outputs (**/dist) under a key, and the downstream jobs (which do not build) restored them viaactions/cache. That cross-job handoff is unreliable: in the investigation, thebuildjob saved the cache successfully (Cache saved with key: ...), yet thelintjob starting ~8s later gotCache not foundfor the same key. This is GitHub Actions cache read-after-write inconsistency, surfacing now that runners were force-migrated to Node 24 (note the new deprecation warnings). A cache miss left the downstream job with nodist, breaking type-aware lint and the tests.Fix
Stop sharing
distacross jobs:setupnow always runsyarn build, so every job has a freshly built workspace. Turbo keeps this fast.--frozen-lockfileto--immutable.No job depends on another job's cached
distanymore, removing the flaky failure mode entirely.Validation
This PR's own CI exercises the change. Merging it produces a new master commit whose CI uses the fix, turning master green.