Skip to content

fix(ci): build workspace per job instead of sharing dist via cache#192

Closed
merencia wants to merge 1 commit into
masterfrom
fix/ci-cache-key
Closed

fix(ci): build workspace per job instead of sharing dist via cache#192
merencia wants to merge 1 commit into
masterfrom
fix/ci-cache-key

Conversation

@merencia

@merencia merencia commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

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 build job passed, but lint, test, and integration-test failed with missing build outputs (unresolved types; Cannot find module .../sidequest/dist/index.cjs).

Root cause

The setup action cached build outputs (**/dist) under a key, and the downstream jobs (which do not build) restored them via actions/cache. That cross-job handoff is unreliable: in the investigation, the build job saved the cache successfully (Cache saved with key: ...), yet the lint job starting ~8s later got Cache not found for 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 no dist, breaking type-aware lint and the tests.

Fix

Stop sharing dist across jobs:

  • Cache dependencies only, keyed on the lockfile (stable, reused across commits).
  • setup now always runs yarn build, so every job has a freshly built workspace. Turbo keeps this fast.
  • Switch deprecated --frozen-lockfile to --immutable.

No job depends on another job's cached dist anymore, 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.

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).
@merencia merencia requested a review from GiovaniGuizzo as a code owner June 22, 2026 14:56
@merencia merencia closed this Jun 22, 2026
@merencia merencia changed the title fix(ci): scope build cache to run attempt, not commit SHA fix(ci): build workspace per job instead of sharing dist via cache Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant