-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Write caches on main branch only by default #143
Comments
I'm more and more convinced that this is a good idea, but I'm not sure how to model it. Option 1: keep
Option 2: Add a 'cache-write-branches' parameter (or something with a better name). Only builds on these branches (or matching a pattern) would write to the cache.
Option 2 is really just a more convenient way of specifying option 1. So I think I'd start with Option 1 and leave Option 2 open for later. |
Cache entries _written_ from jobs run on a non-default branch will be private to other jobs for that branch. When development flow involves working on a feature branch and then merging into 'main', these branch-private cache entries can result in eviction of other (shared) cache entries generated for the default branch. With this change, we make the recommended setup the default, by running with `cache-read-only: true` for any jobs run on a non-default branch. These jobs will be able to read cache entries written from the main branch, but will not write any cache entries. Fixes #143
This was surprisingly easy to implement: e1f5f66 However, I'm a little wary since this would have a negative impact on projects that do their primary development on a non-default branch. For instance, a project that uses 'main' for their latest stable release and some other branch for active development. |
For reference, here is the documentation where we recommend this pattern: https://github.com/gradle/gradle-build-action#only-write-to-the-cache-from-the-default-branch |
I think we should add this in |
In #120 (comment) it was stated that there was consideration of changing the config default so the cache is only written from main branch, thus preventing many PR builds from exhausting available cache and evicting the main branch's cache.
Just creating this issue for tracking (or rejection). I think it makes sense to change the default.
The text was updated successfully, but these errors were encountered: