gradle-build-action
gradle-build-action copied to clipboard
Allow precise cache keys for each artifact bundle
The gradle-build-action does not attempt to determine which source files control the contents of the different cached "bundles" in Gradle User Home. Instead, a cache key is calculated based on the actual files that are present following the build invocation.
This setup allows the Gradle User Home cache to work with minimal configuration, without making assumptions about the actual Gradle build involved. However, it is less efficient when there is a clear set of inputs that control the set of cached artifacts: for example a dependency lockfile that controls which dependency versions should be downloaded for the build.
To allow power-users to optimize their caching, we could permit users to specify a precise cache key for a particular artifact or artifact bundle:
- By default use a "discovered" cache key based on the actual artifacts within Gradle User Home. This is basically stating that we don't know what source/workflow values can cause these to change.
- Allow users to override this by providing a specific cache key for a particular bundle. In your case, you'd provide a key based on the dependency lock files.
- Where possible, extend the action to detect cases where a precise cache key can be determined from the sources.
This should allow things to mostly work out of the box, but allow caching to be optimized when users know a precise way to determine the cache key.
This scenario would make also it possible to:
- Restore certain artifact bundles even if the Gradle User Home cache entry wasn't found. The precise cache key would be known even without a Gradle User Home from a previous invocation.
- If the Gradle User Home is restored and no entry is found for the user-provided bundle key, we could still restore the previous bundle entry. This way if you add a single dependency we could start with the previous set, and only add what's missing.
Thanks to @tbroyer for inspiration.