actions / cache

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

Mention empty possibility for `outputs.cache-hit` #1160

Open rikhuijzer opened 1 year ago

rikhuijzer commented 1 year ago

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.

rgrunber commented 1 year ago

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.