-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CI] Refactor yarn-install composite action #9613
Conversation
da20cbd
to
dfb3e89
Compare
e48f54d
to
2d19265
Compare
e47644c
to
58b792c
Compare
58b792c
to
0cb9c5b
Compare
TODO: Centralize PATH to cache within a multiline outputs of the globals step |
ef36dd8
to
adb7bab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This PR refactors the yarn-install composite action to improve dependency caching efficiency by eliminating redundant caching mechanisms and implementing a more robust caching strategy.
- Added cache key builder step in
/.github/workflows/actions/yarn-install/action.yaml
that includes node version and lockfile hash for better cache invalidation - Replaced
actions/cache
with separateactions/cache/restore
andactions/cache/save
actions for more granular control - Enabled hardened mode and immutable cache flags for stricter dependency management
- Fixed critical issue where cache key mismatch between restore and save operations could cause cache inconsistencies
1 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile
82ad3c2
to
2867680
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really interesting work! I don't understand everything but I wrote a small question.
Introduction
Unless I'm mistaken in the existing
yarn-install
composite actiondependencies
are cached twice.Cached through
setup-node
As we're providing
yarn
value to cache inputs.Setup node will cache the global
.yarn
Programmatic
node_modules
cachingWe even manually still cache
node_modules
folder using:By the way it seems like that the
yarn.lock
file is useless as the restore-key pattern omits itThis could, unless I'm mistaken, leads to invalid cache restore
Runtime
The current infra results in the following install deps logs:
Where we can see in details that a cache is hit twice.
Suggestion
We should stick to only one deps caching mechanism.
Also caching the node_modules folder is not recommended.
That's why I would factorize our caching to the
setup-node
scope only.The cache-primary-key crafting
Within the cache-primary-key we will inject the following metrics:
node_modules
directly in this way to avoid cache desync in case we upgrade node.changed-files
on thepackage.json
and thelockfile
check-cache
andenableHardenedMode
to true and obviously the--immutable
flag ( note adding the--immutable-cache
by principle even if on paper is overkill as a cache restoration and install should never occurs )