Build: Persist root node_modules to the CI workspace#34886
Conversation
CircleCI downstream jobs received the workspace-root node_modules -- where Yarn hoists shared/singleton deps like oxc-parser, vitest and type-fest -- only via the shared save_cache, which is gated on isTrustedAuthor(). Community/fork PRs therefore ran with freshly-built dist output but no root node_modules, causing failures unrelated to their diff (e.g. "Cannot find package 'oxc-parser'", "command not found: vitest", stale type-fest typecheck errors). Persist node_modules, code/node_modules and scripts/node_modules to the pipeline-scoped workspace in build_linux, and attach the workspace after restoring the cache so the fresh build output is authoritative. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughThe PR coordinates CI cache handling by reordering when shared caches are attached relative to workspace restoration, implementing that pattern in the Linux build job with expanded node_modules persistence for downstream jobs, and removing redundant cache logic from the chromatic job. ChangesCI Cache Ordering and Workspace Updates
Possibly Related PRs
🎯 2 (Simple) | ⏱️ ~10 minutes ✨ Finishing Touches📝 Generate docstrings
Comment |
|
@copilot I have the following requirements for data flows in CI:
Your task is:
|
…f needed Agent-Logs-Url: https://github.com/storybookjs/storybook/sessions/261ad771-2035-454b-b268-561ccbdd8c2c Co-authored-by: Sidnioulz <5108577+Sidnioulz@users.noreply.github.com>
Agent-Logs-Url: https://github.com/storybookjs/storybook/sessions/261ad771-2035-454b-b268-561ccbdd8c2c Co-authored-by: Sidnioulz <5108577+Sidnioulz@users.noreply.github.com>
I validated your requirements and they’re directionally correct. Security nuance: workspace data is pipeline-scoped (good for same-pipeline handoff), while shared cache is cross-pipeline and should stay trust-gated for writes; downstream PR jobs should not rely on that cache for correctness. I checked the flow and found gaps: downstream Linux jobs still restored shared cache via Fixed in
Validation after changes passed:
|
What I'm changing
The CircleCI
Build (linux)job persists per-packagecode/<pkg>/distandcode/<pkg>/node_modulesto the pipeline workspace, but the workspace-rootnode_modules(pluscode/node_modulesandscripts/node_modules) reaches downstream jobs only through the sharedsave_cache— which is gated onisTrustedAuthor().Yarn's
node-moduleslinker hoists shared/singleton dependencies —oxc-parser,vitest,type-fest, … — into the rootnode_modules, not the per-package folders. So for community/fork PRs (untrusted authors)build_linuxnever writes that cache, and whenrestore_cachefinds nothing the downstream jobs run with a freshly-builtdistbut no rootnode_modules.That produces failures unrelated to the PR's diff, e.g.:
Cannot find package 'oxc-parser'— every sandbox*--createjobcommand not found: vitest—tests--linux/tests-stories--linuxtype-fest has no exported member 'OmitIndexSignature'—typescript-validationCI is currently red across community PRs (e.g. #34534, #34883) for exactly this reason.
How I'm changing it
build_linuxnow also persistsnode_modules,code/node_modulesandscripts/node_modulesto the pipeline workspace.persist_to_workspaceis pipeline-scoped and not trust-gated, so every PR — community/fork PRs included — receives the exactnode_modulesthe build produced.workflow.restoreLinuxnow attaches the workspace after restoring the shared cache, so the freshly-built output is authoritative and a stale cache entry can't shadow it.The shared
save_cache/restore_cacheis left in place as a (now largely redundant) optimization; removing it could be a follow-up.Manual testing
scripts/ci/main.ts --workflow=normal --gh-trusted-author=false) and confirmed theBuild (linux)job'spersist_to_workspacenow listsproject/node_modules,project/code/node_modulesandproject/scripts/node_modules, and that downstream jobsrestore_cachebeforeattach_workspace.scriptstypecheck (yarn check) andoxfmt --checkpass on the changed files.Unblocks #34534.
Summary by CodeRabbit