Provide a richer API in actions/cache
for sophisticated caching use cases
#1157
Labels
enhancement
New feature or request
The gradle-build-action is effectively a
setup-gradle
action that takes care of caching and other setup for the Gradle build tool. This action is quite sophisticated in it's use of the@actions/cache
library, extracting multiple cache entries out of the Gradle User Home and providing a detailed report of each entry saved/restored (including the entry size). See here for an example (expand the 'cache entry details' section).To provide this functionality we are using a patched version of the
@actons/cache
library, due to some limitations in the main implementation:@actions/cache
library recently started to log and swallow any errors that occur during save/restore, we had to undo this change via a npm patch. While swallowing exceptions might be useful for basic uses of the library, it limits our ability to report to users when a save/restore was successful or failed. In addition, the library logs warnings that lack the context that can be added by our action implementation.Describe the enhancement
I propose that
@actions/cache
provide a parallel API tosaveCache
andrestoreCache
, but that this API be aimed at programmatic users of the cache infrastructure.Features of this API would be:
restoreCache
, at least thekey
and size of downloaded entrysaveCache
, at least thecacheId
and size of uploaded entryCode Snippet
Here is an example calling a modified
restoreCache
function, reporting on the size of the entry and any errors: https://github.com/gradle/gradle-build-action/blob/main/src/cache-utils.ts#L155-L167Here is an example calling a modified
saveCache
function, reporting on the size of the upload and contextualizing any errors: https://github.com/gradle/gradle-build-action/blob/main/src/cache-utils.ts#L171-L181Additional information
@kotewar @tiwarishub I'd be happy to work on a PR to provide this functionality if it's likely to be accepted.
The text was updated successfully, but these errors were encountered: