wordpress-mobile / gutenberg-mobile

Mobile version of Gutenberg - native iOS and Android
GNU General Public License v2.0
241 stars 55 forks source link

Cache `~/.npm` and `pnpm`'s store in CI #6707

Closed mokagio closed 5 months ago

mokagio commented 6 months ago

Part of our attempt to improve the CI performance. See also #6695.

Currently, we run npm ci (clean install), which always builds node_modules from scratch. Under this setup, the only cache-able folder is the ~/.npm global cache.

This PR caches ~/.npm, as well as the pnpm equivalent, which the Jetpack submodule uses.

image

I'd love to say that this makes a visible difference to the runtime, but it doesn't. Look at the time it takes to run npm ci in this PR build and you'll see variability between steps. Compare it with how long the non-cached steps take on trunk, and you'll find that some can be even faster.

The only reason I can think of for this variability is the network speed at which npm accesses the packages... but that is surprising because the whole premise of having an already accessible ~/.npm folder would be to get most of the packages from there.

Regardless, this change should not make the setup worse and gives us a centralized location to further invest in caching.

Testing

Ensure CI is green.

Next steps

Consider caching the i18n cache folders. However, I'm not sure how to control rebuilding them. I need to look into it / ask questions.


PR submission checklist:

geriux commented 5 months ago

I noticed an error in this job in trunk after these changes were merged:

npm ERR! EEXIST: file already exists, open

During the npm install step mentioning a cache folder, have you seen that error before @mokagio ?