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

[FEATURE] Skip saving a cache restored via `restore-prefixes-first-match` #42

Closed deemp closed 1 month ago

deemp commented 1 month ago

Description of a problem the feature solves

A job creates an individual cache (link).

Next, this cache is merged with another individual cache (link) and a common cache is produced (link).

Then, individual caches are purged (link).

During the next run, a job restores a common cache via restore-prefixes-first-match (link).

Next, this job checks whether there is a caches with the primary-key (link) and doesn't find because it was purged.

This job saves a new individual cache that is a copy of a common cache.

Describe the solution you'd like

Have an option to not save a cache when a cache was restored via restore-prefixes-first-match.

Describe alternatives you've considered

Use separate restore and save actions. Don't save a cache when restore outputs hit: true .

deemp commented 1 month ago

Separate restore and save actions indeed already cover this use case (link).