Add caching for the /gutenberg directory#10971
Add caching for the /gutenberg directory#10971desrosj wants to merge 11 commits intoWordPress:trunkfrom
/gutenberg directory#10971Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Refs are meant to be human readable. The value being pinned for the repository is a commit hash value (SHA). This uses the correct terminology.
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
These are treated as literals instead.
|
Props to @westonruter for the idea to include the |
| with: | ||
| path: | | ||
| gutenberg | ||
| !gutenberg/node_modules/ |
There was a problem hiding this comment.
Why is gutenberg/node_modules excluded?
There was a problem hiding this comment.
I mean, wouldn't we want to cache node_modules?
There was a problem hiding this comment.
I'm experimenting to see what the effect of caching this has on the overall time it takes to run the workflow. The setup-node action already caches npm dependencies in an optimized way, so I'm not certain that it's required to cache the node_modules directory. Just testing an assumption before committing to storing an 800MB cache key (the entire repository is limited to 10GB at any given time).
There was a problem hiding this comment.
I assumed setup-node only caches the root node_modules directory, not the gutenberg/node_modules directory. But apparently it doesn't even cache the root one, per the docs:
Note: The action does not cache
node_modules
There was a problem hiding this comment.
I believe it caches the global npm download cache which has compressed tarballs. This is mainly because the resulting node_modules folder varies for different platforms/operating systems.
My assumption is that the global cache should contain any packages installed on the runner from any package.json file. But to confirm this, we'd have to find a specific dependency found only in the Gutenberg repository and confirm it ends up in the generated cache key (deleting the key manually and then rerunning a workflow that generates a new one with debug mode will output every file included).
If that is the case, then the changes here will actually have no effect at all since the cache already includes the necessary details.
There was a problem hiding this comment.
It looks like jest-jasmine2 is a dependency in gutenberg and is found nowhere in the dependency tree for wordpress-develop. Testing this now.
There was a problem hiding this comment.
With some assistance from Claude, it seems you have to take the sha512 integrity value in the lock file for the package, convert it from base64 to hexadecimal. Then the first 4 digits represent the directory path, and the rest is the name. So for jest-jasmine2 it should be .npm/_cacache/content-v2/sha512/83/c2/05d0c1e40d87834adf69b1e631dc7c7c9e3cba98f9e3d1bbd7e5fd7d4172e09cbe39ba9ccb2eefc45e34bb9b89047afe7b95f9e2791427b1f1ee1e0b7f44ddde0c3c9b5e7c2fc76
I don't see that in the log output, though. So seems it's not the case.
It looks like the reusable Gutenberg build process testing workflow specifies multiple lock files for setup-node. This is probably the best option, but the problem is that the file does not exist until npm install runs. So passing gutenberg/package-lock.json will result in an error.
Any other ideas @westonruter?
There was a problem hiding this comment.
Could the package-lock.json file be pulled down beforehand and written into the gutenberg directory before running npm install at the root? The raw URL for the file should be easy to construct since we have the Gutenberg hash available.
|
Would it make sense to have a new reusable workflow so that the same code doesn't need to be maintained in 9 different places? |
Apparently exclusions do not work for actions/cache and this is a known issue. See actions/cache#1356. Instead, this manually removes the `node_modules` directory to see what effect that has on the cache.
Excluding this from the cache did not speed things up.
|
This did not really warrant the results I was hoping for. @westonruter did have one more idea, but I much prefer the solution I'm working on in #11019. The improvement there is significantly greater than what caching the |
This adds caching for the
/gutenbergdirectory in GitHub Actions workflows in an attempt to avoid every single job from performing a full checkout, install, and build of the Gutenberg plugin at the pinned SHA reference.Trac ticket: Core-64393.
Use of AI Tools
Used Claude code for the
jqone liner.This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.