Skip to content

Include Yarn install state when restoring cache#66

Merged
HowardBraham merged 2 commits into
mainfrom
include-yarn-install-state
Apr 29, 2026
Merged

Include Yarn install state when restoring cache#66
HowardBraham merged 2 commits into
mainfrom
include-yarn-install-state

Conversation

@mcmire

@mcmire mcmire commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Description

Both clients use a bespoke Yarn plugin for installing preview builds, which are prerelease versions of libraries that engineers can generate and use. This plugin works by modifying Yarn resolutions in memory in order to map packages from the @metamask NPM scope to a special version within the @metamask-previews scope.

In the extension, we have found that this plugin does not seem to work in CI. More specifically, if one job runs this workflow and caches node_modules, when another job runs this workflow again to restore node_modules from cache, attempting to run a Yarn command fails (the preview build is not found). Caching node_modules does not seem to be sufficient to restore the mapping of resolutions that the plugin needs to work correctly. We need to also cache and restore .yarn/install-state.gz.

References

See this Slack thread for more information: https://consensys.slack.com/archives/C094GV3E7SB/p1777056238889789


Note

Medium Risk
Touches the shared composite GitHub Action used for dependency setup/caching, so any mistake can impact CI reliability and cache behavior across repos. Change is straightforward (adds one file to cache paths) with low security/data risk.

Overview
Ensures Yarn’s install metadata is preserved across CI runs by caching/restoring .yarn/install-state.gz alongside **/node_modules in all workspace cache restore/save steps (including the fast “skip setup” lookup).

Updates the related step name/comment to reflect that both node_modules and Yarn install state are now restored, improving reliability for workflows that depend on Yarn’s internal resolution state.

Reviewed by Cursor Bugbot for commit c4346cc. Bugbot is set up for automated code reviews on this repo. Configure here.

@mcmire mcmire force-pushed the include-yarn-install-state branch 2 times, most recently from f534848 to 895b452 Compare April 29, 2026 15:41
Both clients use a bespoke Yarn plugin for installing preview builds,
which are prerelease versions of libraries that engineers can generate
and use. This plugin works by modifying internal resolutions in order
to map packages from the `@metamask` NPM scope to the
`@metamask-previews` scope (along with a special preview version).

In the extension, we have found that this plugin does not seem to work
in CI. More specifically, if one job runs this workflow and caches
`node_modules`, when another job runs this workflow again to restore
`node_modules` from cache, attempting to run a Yarn command fails (the
preview build is not found). Caching `node_modules` does not seem to be
sufficient to restore the mapping of resolutions that the plugin needs
to work correctly. We need to also cache and restore
`.yarn/install-state.gz`.
@mcmire mcmire force-pushed the include-yarn-install-state branch from 895b452 to 3585ea0 Compare April 29, 2026 15:42
Comment thread action.yml Outdated

@Gudahtt Gudahtt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@mcmire mcmire marked this pull request as ready for review April 29, 2026 17:57
@mcmire mcmire requested a review from a team as a code owner April 29, 2026 17:57
@HowardBraham HowardBraham merged commit 53b1675 into main Apr 29, 2026
35 checks passed
@HowardBraham HowardBraham deleted the include-yarn-install-state branch April 29, 2026 20:06
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.

3 participants