Bug: Only rely on Cache key for hit/misses regardless of Path
See original GitHub issueBackground
It appears that even though the Cache key being used to store and retrieve the cache is the same, a cache hit never occurs because the path
string is different.
Here’s a screenshot of two jobs on main
in a row with the same cache key…we get a cache miss but successful cache upload in both jobs:
The only thing different here is the path
. This leads me to believe that the string to the path is influencing the caching which caught me by surprise and isn’t mentioned anywhere in the docs.
I saw this being mentioned in a couple other issues: https://github.com/actions/cache/issues/735#issuecomment-1036402013 https://github.com/actions/cache/issues/638#issuecomment-1002972310
This is a bummer because we currently isolate all builds by commit SHA so our path
will always be different even though our key
based on hashing yarn.lock
doesn’t change which makes this module unusable in our current workflow, ie:
path: ${{ github.sha }}/**/node_modules
will always return a cache miss for any new commit even on the same branch.
Proposal
- Make it clear in the docs that path influences how cache hits/misses
- Allow option to strictly look at the Cache
key
ONLY for hits/misses, otherwise this is unusable for anyone using dynamic paths for their cache workflows
Issue Analytics
- State:
- Created a year ago
- Reactions:5
- Comments:5
Top GitHub Comments
It would be REALLY helpful to have the action print out when it fails due to the path. Right now it says:
and I just spent a day trying to figure out how that happens but I was also seeing:
when it turns out that (somehow) the cache was saved with a path of
~
instead of~/local
. Trying to debug that without a UI to look at cache details (or even an API to list the active caches) was terrible. (Not to mention trying to delete the bad one now is going to be fun…)Hi @BaseInfinity, we have recently updated our docs to indicate that the caching depends on cache-version, which in turn is based on
path
.Hope this makes it clear.