Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass additional restore-keys to cache action #366

Closed
gustavovnicius opened this issue Aug 12, 2022 · 8 comments
Closed

Pass additional restore-keys to cache action #366

gustavovnicius opened this issue Aug 12, 2022 · 8 comments
Assignees
Labels
feature request New feature or request to improve the current logic

Comments

@gustavovnicius
Copy link

gustavovnicius commented Aug 12, 2022

As can be seen in their examples: https://github.com/actions/cache/blob/main/examples.md#java---gradle

It is recommended that additional restore-keys are passed when using actions/cache. https://github.com/actions/cache#inputs

https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key

const matchedKey = await cache.restoreCache(packageManager.path, primaryKey);
could be changed to something like:

const restoreKey = `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${packageManager.id}`;
const matchedKey = await cache.restoreCache(packageManager.path, primaryKey, [restoreKey]); 
@gustavovnicius
Copy link
Author

gustavovnicius commented Aug 12, 2022

I see that this: #285 was recently merged, but the cost doesn't outweigh the gains.

It is not realistic to bust the cache completely whenever a version changes. Many projects nowadays rely on automated dependency updates, not using restore-keys makes the performance of setup-java unacceptably bad in those cases.

A better way to handle this would be to expose an input to let people decide how often they want to expire their caches.

@dsame dsame self-assigned this Aug 15, 2022
@dsame
Copy link
Contributor

dsame commented Aug 15, 2022

Hello @gustavovnicius
Thanks for your input, i am starting to investigate the problem.

@dsame
Copy link
Contributor

dsame commented Aug 15, 2022

@gustavovnicius the cache should be updated whenever the dependencies changed. It is expected behaviour and actually it is not realistic the update of dependencies happens too often.

Nevertheless for some specific use cases it is natural to use full-featured https://github.com/actions/cache actions instead of its simplified implementation built-in into setup-java action.

@dsame dsame added feature request New feature or request to improve the current logic and removed feature request New feature or request to improve the current logic needs triage labels Aug 15, 2022
@paramaggarwal
Copy link

The PR #285 should be reverted. It makes caching useless unless the code is exactly the same.

@gustavovnicius
Copy link
Author

What I'm proposing on #367 is a solution that works both ways.
Having a customizable cache key prefix gives it enough flexibility to be used in many different setups.

@dsame
Copy link
Contributor

dsame commented Aug 22, 2022

The PR #285 should be reverted. It makes caching useless unless the code is exactly the same.

The cache must be renewed if any dependency has changed. In the other case the cache keeps obsolete dependencies and grows infinitely.

@dsame
Copy link
Contributor

dsame commented Aug 22, 2022

What I'm proposing on #367 is a solution that works both ways. Having a customisable cache key prefix gives it enough flexibility to be used in many different setups.

Built-in cache is not intended to be flexible, it is intended to work out of box in the most cases. For the specific complex caching that requires flexibility and customisation there's https://github.com/actions/cache action

@dsame
Copy link
Contributor

dsame commented Aug 22, 2022

The feature request is declined because the requested functionality exist in the other action https://github.com/actions/cache

@dsame dsame closed this as not planned Won't fix, can't repro, duplicate, stale Aug 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request to improve the current logic
Projects
None yet
Development

No branches or pull requests

3 participants