Leafwing-Studios / cargo-cache

Cache your Cargo build files
Apache License 2.0
8 stars 2 forks source link

Duplicate caches with same name #31

Closed mnmaita closed 3 weeks ago

mnmaita commented 3 weeks ago

I'm using this action to cache my dev builds and then reuse them whenever someone pushes a new pull request.

Using cache-groups so the same job/s use the same cache. But whenever I'm pushing a new ref and opening a new PR, the action will create a new cache with the exact same name and report there was no cache hit.

Is this intended because it's being triggered from different runs even though it's the same workflow and job doing it?

BD103 commented 3 weeks ago

Hi! Unfortunately that is a restriction of Github, not something on our end. Caches created on branches can only be used by their direct children. Please see this article for more details.

I'm recommend making cached jobs run on push to the main branch. Then, that cache can be used by all pull requests.

mnmaita commented 3 weeks ago

Thanks, this is exactly what I needed to know!