-
Notifications
You must be signed in to change notification settings - Fork 47k
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: try to make caching more reliable #25259
Conversation
# all jobs run on this branch with the same lockfile. | ||
name: Save node_modules cache | ||
# This cache key is per branch, a yarn install in setup is required. | ||
key: v2-node-{{ arch }}-{{ .Branch }}-{{ checksum "yarn.lock" }}-{{ checksum "workspace_info.txt" }}-node-modules |
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.
I don't know why we would include the branch name in the caching. This seems to just needlessly split the cache keys (wastes cache storage and more cache misses)
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.
What if you add a new dependency in a branch? Doesn't the cache need to break so you install the dependency?
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.
Answer: In that case the yarn.lock
would change for that branch.
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.
But that doesn't have anything todo with the branch (name?) right? We might install a new dependency on the main
branch or re-use a branch name across multiple PRs.
My thinking is that yarn.lock + workspace_info should capture everything relevant.
If we're feeling unsure about re-using the node_modules cache across PRs, we could also use the git revision for the key (I saw that's available in the docs)
name: Save node_modules cache | ||
key: v1-node_modules-{{ arch }}-{{ checksum "yarn.lock" }}-{{ checksum "workspace_info.txt" }} | ||
paths: | ||
- node_modules |
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.
Just node_modules
is actually insufficient as yarn workspaces create node_modules directories in each project.
This feels tricky to get stable. Maybe we should include the yarn install
, but restore the yarn cache so the yarn install can make use of that.
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.
I thought that that was what we do?
So something is still missing here. I'll keep investigating. |
91c2884
to
41333e2
Compare
I have 2 working configurations now:
|
I'd prefer option 2 as 30s increases the feedback loop by 50% for most of the tests. |
@kassens An additional thing we could try is to retry the We could also try to see if caching is working with running the subsequent |
@poteto if we remove the |
I think this is finally ready for review! |
- `~/.yarn/cache` is now restored from an hierarchical cache key, if no precise match is found, we fallback to less precise ones. - The yarn install in `fixtures/dom` is also cached. Notably, is utilizes the cache from root, but stores into its more precise key. - Steps running in root no longer have a `yarn install` and rely on the cache from the setup step. - Retry `yarn install` once on failure.
~/.yarn/cache
is now restored from an hierarchical cache key, if no precise match is found, we fallback to less precise ones.fixtures/dom
is also cached. Notably, is utilizes the cache from root, but stores into its more precise key.yarn install
and rely on the cache from the setup step.yarn install
once on failure.