runs-on / cache

Shockingly faster GitHub Action cache with S3 backend
https://runs-on.com
MIT License
58 stars 12 forks source link

API access to `runs-on/cache` #18

Open bigdaz opened 3 months ago

bigdaz commented 3 months ago

We received a feature request for the setup-gradle action to support runs-on/cache: https://github.com/gradle/actions/issues/279

The setup-gradle action does not use actions/cache directly, but instead uses the @actions/cache library to save and restore cache entries.

Is there an equivalent API (in a published library) that can be used to save/restore cache entries via runs-on/cache?

crohr commented 2 months ago

@bigdaz thanks for opening the issue. Would be nice to extract the custom S3 backend code into a separate lib indeed. I may have a stab at it, but would need to see how you switch cache backend currently in your grade action. Could you send me some pointers?

Thanks!

bigdaz commented 2 months ago

Thanks. It would be amazing if we could support an S3 cache backend for setup-gradle. I considered implementing support directly in the action, but I think it makes more sense for runs-on/cache to provide a general-purpose implementation if that's possible. I'm happy to help with testing (and possibly implementation), but I have zero experience with publishing an NPM library.

The setup-gradle action doesn't have any ability to switch between different cache backends, since we only currently support the main GitHub Actions cache. However we have a feature request to support @buildjet/cache which would require something similar.

In the end, all of our cache access boils down to these 2 methods for save and restore. It should be relatively straightforward to make this implementation pluggable for different cache backends.

(Note that for reporting purposes we patch the @actions/cache API so that we can access the size of the saved/restored cache entry, as well as any underlying errors that occur. So our requirements go a little beyond what's provided by @actions/cache.)

pavlospt commented 1 week ago

@crohr Is there a way to help on extracting the separate library for this need, or is it already being worked on?