feat(cache): change key to match actions/cache documentation
This PR change the cache key construction to fit those examples. It also add the use of restoreKeys and a more verbose log when retrieving fails.
Does it make sense to fallback on a shared prefix without the package manager? They probably even use different cache directories.
Does it make sense to fallback on a shared prefix without the package manager? They probably even use different cache directories.
I would agree, falling back to a prefix without package manager probably isn't useful — they definitely use separate cache paths.
Hey just saw a link to this PR. I'd like to mention few discoveries I did recently
- Yarn 3+ cache is automatically pruned when deps changes (it does not grow over time on the github cache).
- Yarn 3+ cache is OS/arch independent (no need to prefix with OS)
- Pnpm 7 is not pruned automatically,. There's a specific command https://pnpm.io/cli/store#prune. It's sometimes buggy.
You can see two examples based on @action/cache:
- yarn: https://gist.github.com/belgattitude/042f9caf10d029badbde6cf9d43e400a
- pnpm: https://gist.github.com/belgattitude/838b2eba30c324f1f0033a797bab2e31
It might be helpful.
- Yarn 3+ cache is automatically pruned when deps changes (it does not grow over time on the github cache).
I believe this is only true if you're not using the global cache in your project. From $(yarn config get cacheFolder) alone there is no way to distinguish the two.
See also https://yarnpkg.com/features/offline-cache#sharing-the-cache
True, if you look at the yarn gist you'll see that on ci the global cache is disabled YARN_ENABLE_GLOBAL_CACHE=false through an env. That makes it work independently of config.
True, if you look at the yarn gist you'll see that on ci the global cache is disabled YARN_ENABLE_GLOBAL_CACHE=false through an env. That makes it work independently of config.
I see. For the record, I would hate it if the node action overrode my yarn config 😄
Added an up to date evolution of this PR over here: https://github.com/actions/setup-node/pull/702
falling back to a prefix without package manager probably isn't useful
That PR fixes this ☝️
npm will not remove data by itself: the cache will grow as new packages are installed.
And it also fixes the infinitely growing cache problem that comes with this ☝️