Skip to content

Add cache fallback with rolling timed expiration - #702

Open
voxpelli wants to merge 1 commit into
actions:mainfrom
voxpelli:cache-fallback
Open

Add cache fallback with rolling timed expiration#702
voxpelli wants to merge 1 commit into
actions:mainfrom
voxpelli:cache-fallback

Conversation

@voxpelli

Copy link
Copy Markdown

This PR builds on #323 by @mmorel-35 but with two changes:

  1. It adds a new cache-invalidate-after-days option that defaults to 120 days and which sets a rollable prefix between 0 and 9 to all of the cache keys, making it so that a cache key will change after 120 days. Can be set to 0 to deactivate. Reason for this is that npm will not remove data by itself: the cache will grow as new packages are installed.
  2. Removes the fallback to a package manager independent cache key, only falling back to a cache from the same package manager.

This fixes #328 without creating an ever expanding cache size.

This also helps the cache be much more useful with a Dependabot / Renovatebot setup as a project that is dominated by PR:s from such sources will with the current cache setup in actions/setup-node pretty much only get cache misses and thus only ever set caches, rarely ever use them.

This adds a simple mechanism of falling back to a recent cache while avoiding the ever growing cache problem.

Feedback wanted:

  • The rolling prefix might be a premature optimization on my part. Maybe one should just leave it out)
@voxpelli
voxpelli requested a review from a team as a code owner February 27, 2023 18:27
@voxpelli

Copy link
Copy Markdown
Author

Will rebase

voxpelli pushed a commit to SocketDev/workflows that referenced this pull request Feb 28, 2023
Similar to what is added in actions/setup-node#702, prevents the npm cache from growing indefinitely while still providing a general fallback
@nwalters512

Copy link
Copy Markdown

@voxpelli thanks for opening this! I think you'll need to run npm build/yarn build to update the files in dist/ for this to pass CI.

@voxpelli

Copy link
Copy Markdown
Author

@nwalters512 Did so now, waiting for workflow runs to be approved again :)

@nwalters512

Copy link
Copy Markdown

@dmitry-shibanov any chance you could take a look at this PR? The introduction of fallback restore keys matches documented best practices and should allow the cache to be used in many more scenarios.

@voxpelli

Copy link
Copy Markdown
Author

This has conflicts after #744 was merged, I'm on it

@voxpelli

Copy link
Copy Markdown
Author

Ping @dsame, I adapted this to the changes made in #744, does it look like its in the spirit of what you did there?

@Mikhai56 Mikhai56 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

of

@voxpelli

voxpelli commented Jul 1, 2024

Copy link
Copy Markdown
Author

Anything I can do to help out on getting this reviewed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants