actions / cache

Cache dependencies and build outputs in GitHub Actions
MIT License
4.51k stars 1.2k forks source link

`if: always()` with `cache/save` may lead to errors (fix README!) #1154

Closed andreasabel closed 1 week ago

andreasabel commented 1 year ago

https://github.com/actions/cache/blob/04f198bf0b2a39f7230a4304bf07747a0bddf146/save/README.md?plain=1#L83-L84

In my experience, if we had an exact cache hit, the attempt to save the cache (under the same key) will produce an error. So, the docs should be updated to something like

if: always() && !steps.<cache-restore-step>.outputs.cache-hit

at least in cases where we did a restore.

As cache-hit will only be true if the cache-primary-key equals the cache-matched-key this will always save the cache when it is possible.

github-actions[bot] commented 11 months ago

This issue is stale because it has been open for 200 days with no activity. Leave a comment to avoid closing this issue in 5 days.

andreasabel commented 11 months ago

Issue is still unfixed: https://github.com/actions/cache/blob/704facf57e6136b1bc63b828d79edcd491f0ee84/save/README.md?plain=1#L83-L84

andreasabel commented 11 months ago

ATTN: @bethanyj28 Please triage/fix.

github-actions[bot] commented 4 months ago

This issue is stale because it has been open for 200 days with no activity. Leave a comment to avoid closing this issue in 5 days.

andreasabel commented 4 months ago

Rather

if: always() && steps.<cache-restore-step>.outputs.cache-hit != 'true'
joshmgross commented 2 months ago

Fixing in https://github.com/actions/cache/pull/1452

andreasabel commented 2 months ago

Finally!

Maybe fixing this one line shouldn't have taken 16 months, meanwhile leading thousands of users astray...

joshmgross commented 1 week ago

Fixed in #1452