tespkg / actions-cache

Cache to S3 storage with official actions/cache@v2 fallback
MIT License
75 stars 31 forks source link

💡 - Options to skip downloading assets if cache already exist #27

Closed alienxp03 closed 8 months ago

alienxp03 commented 1 year ago

Would be good if we could get this option.

jackieli-tes commented 1 year ago

I'm not sure this is possible. How do you know the local assets are consistent with the remote?

alienxp03 commented 1 year ago

One possible option is to check based on previous cache hit. Or any kind of cache key maybe? Some cache are very big and without this option, we have to pay quite a lot for S3 data transfer. And we could save few seconds/minutes too for each cache download.

From another repo: https://github.com/whywaita/actions-cache-s3#skipping-steps-based-on-cache-hit

jackieli-tes commented 1 year ago

Ah, yes, good point. We can check the previous downloaded compressed file. I think I'll implement this one. Thanks for the suggestion.

jackieli-tes commented 8 months ago

Revisiting this, I think the https://github.com/whywaita/actions-cache-s3#skipping-steps-based-on-cache-hit options is for the later steps to skip re-downloading dependencies that's already in the cache.

If you want to skip downloading the cache, you should probably have a step before the cache step to see if a good cache item already exists. For example (pseudo code):

- name: cache-exists
     run: if cache exists then set-output skip-cache = true
- name: tespkg/actions-cache
   if: ${{skip-cache != 'true'}}
   ...