actions / cache

Cache dependencies and build outputs in GitHub Actions
MIT License
4.45k stars 1.18k forks source link

Test for cache-hit without restoring the files #1113

Closed h-mayorquin closed 1 year ago

h-mayorquin commented 1 year ago

Is there a way for checking for cache-hits without restoring (downloading) the files?

My understanding now is that testing for a cache-hit and restoring (downloading) the files are coupled and I can't find in the documentation a way of separating them.

The use case is the following:

I have a centralized workflow operating in the main branch which creates consumption caches to be restored and used for testing on all the other branches. More specifically, the cache creation workflow checks if the dependencies have been updated and creates a new cache if they have and does nothing if they haven't. However, most of the times the dependencies are not updated and the cache ends up restoring the cache for no reason, that is, the restoring operation is wasted in this wokflow. Hence my question above it?

Probably this could be done by listing caches using curl or github-ci in the following way: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#list-github-actions-caches-for-a-repository

But I wanted to know if it could be done with this action.

h-mayorquin commented 1 year ago

Ah, it seems that this could be addressed by: https://github.com/actions/cache/pull/1095

pallavx commented 1 year ago

H @h-mayorquin,

Thanks for surfacing this request. As you mentioned we have a similar request tracked in #1095. You can track the progress for this ask there. Resolving this issue. Please create a new one for further queries.