nix-community / cache-nix-action

Cache Nix store in GitHub Actions to speed up workflows [maintainer=@deemp]
MIT License
28 stars 6 forks source link

"Cache merge" job fails to overwrite existing cache in the same scope #17

Open develop7 opened 6 months ago

develop7 commented 6 months ago

Hi.

I've been adopting the cache-nix-action back there at us in PostgREST, and it's working really great — cuts Nix & stuff deployment times by 50-70%; unless the relevant cache doesn't get evicted first. So, I've decided to adopt cache merging as well. The job itself is at https://github.com/PostgREST/postgrest/pull/3071/files#diff-944291df2c9c06359d37cc8833d182d705c9e8c3108e7cfe132d61a06e9133dd, heavily sprinkled with comments (because the technique isn't exactly straightforward). It looks like it should work, but there's this warning at the end of the cache save job log, right after the "okay, compressing and saving the cache" line:

Unable to reserve cache with key cache-nix-Linux-common-4949da85e72a9fd6af5a40b4ebaa1b14efe92d5e08807060bcb4414b681ac378, another job may be creating this cache. More details: Cache already exists. Scope: refs/pull/3077/merge, Key: cache-nix-Linux-common-4949da85e72a9fd6af5a40b4ebaa1b14efe92d5e08807060bcb4414b681ac378, Version: 4a1056d7529b065dc12b48db2d96984e8a91066b17ff25b040385973ff1a7e1e

Here's the link: https://github.com/PostgREST/postgrest/actions/runs/7035767110/job/19147207413#step:12:15

Do you maybe have any insights/suggestions on this? I'm kind of out of ideas, TBH

deemp commented 6 months ago

Hi, @develop7! Sorry, I was busy recently. I don't see anything wrong with your workflow file for now. I think this behavior is because you run on PR. So, it doesn't have a permission to overwrite existing caches.

Additionally, thank you for comments in your workflow file. I think I should adopt them in the example workflow.