gradle-build-action
gradle-build-action copied to clipboard
Remove unused files from Gradle User Home before saving to Actions cache
The Gradle User Home directory is not cleaned up in an efficient manner by Gradle, and this action doesn't do anything special to cleanup unused files in the Gradle User Home before saving it to the GitHub Actions cache. As such, no-longer-used wrapper distributions, dependencies and local cache entries will remain in Gradle User Home, causing the GitHub Actions cache entries to grow over time.
Pending a fix in Gradle itself, the action should attempt to limit the growth of the Gradle User Home over time, by removing files that were not used in the current workflow invocation.
Experimental support for Gradle User Home cleanup has been released in v2.3.0-beta.1
. Please try this version (with cache-cleanup enabled) and let us know how it works for you.
- uses: gradle/[email protected]
with:
gradle-home-cache-cleanup: true
@bigdaz is there also a way to influence the age of cache entries to be retained? We currently do this as a work-around:
val buildCacheRetentionDays: String by settings
buildCache {
local {
removeUnusedEntriesAfterDays = buildCacheRetentionDays.toInt()
}
}
@bigdaz is there also a way to influence the age of cache entries to be retained?
I guess this could be seen as being a part of https://github.com/gradle/actions/issues/24.
@bigdaz is there also a way to influence the age of cache entries to be retained?
@sschuberth Can you explain why you'd want to do that? The present functionality should remove all cache entries that weren't directly used in the current workflow. This should ensure that the local build cache that is saved/restored doesn't contain any stale entries.
I'm trying to limit the cache size by pruning entries for builds that happened in CI several days ago, as we're constantly running out of the 10 GB GitHub action cache limit (not due to the Gradle cache alone, though). But if you're saying that the current implementation of gradle-home-cache-cleanup: true
already does not keep (or save / restore) any cache entries from previous days / builds, I believe we're good.
But if you're saying that the current implementation of gradle-home-cache-cleanup: true already does not keep (or save / restore) any cache entries from previous days / builds, I believe we're good.
Yes, it should. You can see the implementation here, where we "age" all of the files before any Gradle executions, and then force the cache cleanup to run before saving the Gradle User Home.
This is a bit of a hack, but I've seen it working and have limited test coverage. Let me know if you experience otherwise.