setup-node icon indicating copy to clipboard operation
setup-node copied to clipboard

feat(cache): change key to match actions/cache documentation

Open mmorel-35 opened this issue 4 years ago • 7 comments

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.

mmorel-35 avatar Aug 26 '21 13:08 mmorel-35

Does it make sense to fallback on a shared prefix without the package manager? They probably even use different cache directories.

oxc avatar Feb 01 '22 10:02 oxc

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.

ThisIsMissEm avatar Mar 02 '22 14:03 ThisIsMissEm

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.

belgattitude avatar Oct 10 '22 21:10 belgattitude

  • 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

oxc avatar Oct 11 '22 05:10 oxc

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.

belgattitude avatar Oct 11 '22 08:10 belgattitude

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 😄

oxc avatar Oct 11 '22 08:10 oxc

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 ☝️

voxpelli avatar Feb 27 '23 18:02 voxpelli