julia-actions / cache

A shortcut action to cache Julia artifacts, packages, and registries.
MIT License
39 stars 9 forks source link

Delete cache entries only on the workflow branch #97

Closed omus closed 8 months ago

omus commented 8 months ago

I've noticed that the post-action step which automatically cleans up old cache entries accidentally cleans up entries created on other branches. This reduces performance with multiple PRs are being developed concurrently especially in the scenario where a PR deletes the cache entry for the main branch resulting in all new PRs having cache misses until a PR has been merged.

This PR updates the handle_caches.jl script to only delete caches which match the restore key using the same git ref as the executing workflow. This should result in workflows run on the main branch only deleting cache entries on main and PRs only deleting cache entries for that PR.

For more details about cache isolation in regards to branches see: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache

omus commented 8 months ago

I'll hold off on merging until I triple check the non-fork version is working. Also, this may be a nicer way to detect a fork: https://github.com/orgs/community/discussions/25217#discussioncomment-3246904

IanButterworth commented 8 months ago

I think this fixes #98.

Probably good to add 1.0 CI as these actions should probably work back to there, if possible.

omus commented 8 months ago

I think this fixes #98.

Probably good to add 1.0 CI as these actions should probably work back to there, if possible.

I'll save this for another PR as there are a few additional changes required to get this to work