cache
cache copied to clipboard
`cache-hit` undefined on cache miss?
The README says:
Note
cache-hit
will only be set totrue
when a cache hit occurs for the exactkey
match. For a partial key match viarestore-keys
or a cache miss, it will be set tofalse
.
but outputs.cache-hit == 'false'
doesn't seem to be true when I get a cache miss, and I noticed that the examples all use != 'true'
, not == 'false'
.
I think here we can see restoreImpl
return early on a miss, without setting any value for cache-hit
at all. I'm not a TypeScript or Actions expert though.
In the meantime, I'll switch my == 'false'
to != 'true'
but I feel dirty. :)
This problem does not seem to occur in v3, only in v4. In fact, the repositories that had been delayed updating to v4 were working fine.
In workflows that saving the cache when outputs.cache-hit == 'false'
, the cache was no longer being saved. I recognized this too late because it simply skips a step and does not result in an error.
Is this a bug? Or is it a breaking change?
I'm seeing a potentially related problem, where our steps that have if: ${{ steps.cache.outputs.cache-hit != 'true' }}
now always get executed since the switch to v4. With v3, they used to be properly skipped on a cache hit, but I have not seen them skipped a single time since then.
EDIT: Never mind, I was just not patient enough and caches don't seem to always propagate instantly.
@RalfJung: I was going to say don't use if: ${{ steps.cache.outputs.cache-hit != 'true' }}
because that's a string that will always evaluate to true
, not a boolean expression, and that you should use if: steps.cache.outputs.cache-hit != 'true'
instead.
But if it eventually worked for you, then I have no idea how anything works.
It looks like there are document revisions in progress related to this issue. https://github.com/actions/cache/pull/1263