nix-community / cache-nix-action

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

[BUG] Nothing is cached when CI is red #37

Closed hissssst closed 2 months ago

hissssst commented 2 months ago

Describe the bug

    - name: Restore and cache Nix store
      uses: nix-community/cache-nix-action@v5
      continue-on-error: true
      with:
        # restore and save a cache using this key
        primary-key: nix-${{ runner.os }}-${{  hashFiles('flake.nix', 'flake.lock', 'nix/ci-shell.nix') }}
        # if there's no cache hit, restore a cache by this prefix
        restore-prefixes-first-match: nix-${{ runner.os }}-
        # collect garbage until Nix store size (in bytes) is at most this number
        # before trying to save a new cache
        gc-max-store-size-linux: 1073741824
        # do purge caches
        purge: true
        # purge all versions of the cache
        purge-prefixes: cache-${{ runner.os }}-
        # created more than this number of seconds ago relative to the start of the `Post Restore` phase
        purge-created: 0
        # except the version with the `primary-key`, if it exists
        purge-primary-key: never

Continue on error is set, but post actions is ignored when some consecutive action fails, what essentially makes this action useless, since nobody reruns green CI.

I can't provide a real work-example, since the project is closed-source

hissssst commented 2 months ago

Sorry, I've missed your comment about save-always. I'll try it then

hissssst commented 2 months ago

No, the issue is still preset

Cache saving fails with

Post job cleanup.
Trying to save a new cache with the key "nix-Linux-65aed009112cf5da263cf5702c9580bbd4914442ff172eded037a31a1daa35bb".
Purging cache(s) created before 2024-04-19T13:46:47.139Z, scoped to "refs/pull/721/merge", and with the key "nix-Linux-65aed009112cf5da263cf5702c9580bbd4914442ff172eded037a31a1daa35bb".
Error: Resource not accessible by integration
hissssst commented 2 months ago

Setting permissions as stated in the #13 fixed the issue