cache icon indicating copy to clipboard operation
cache copied to clipboard

Mention empty possibility for `outputs.cache-hit`

Open rikhuijzer opened this issue 2 years ago • 1 comments

The outputs.cache-hit used to indicate that the value is a boolean, which means true or false. However, outputs.cache-hit is not set when there is no cache restored. I discovered this the hard way and also @aparna-ravindra mentioned it in https://github.com/github/docs/pull/18524#issuecomment-1161626882:

However, if no cache was restored (either on the primary key or the restore-keys), then the cache-hit output value is not set.

rikhuijzer avatar Apr 24 '23 07:04 rikhuijzer

I also discovered this the hard way :rofl: It looks like there's https://github.com/actions/cache/pull/876 to correct the issue ?

Although it's true the documentation at https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#using-the-output-of-the-cache-action speaks only about true, a consumer of the action might easily interpret that as just because that's the example that was chosen. Using true brings along the implicit assumption that the negation of the precondition (no cache hit) will be false. If it's not the case, then that probably deserves a special note in the documentation.

rgrunber avatar Sep 22 '23 16:09 rgrunber