Same cache key not shared between different pull requests
See original GitHub issueHi, I’m not sure if this is a feature or a bug, but when we use the same cache key for different PRs (sequentially without a race condition), the second PR doesn’t find the cache even though the keys are the same and the first PR completes the workflow successfully (including cache upload).
I looked through the actions/cache
code and I think it may be related to the scope
attribute of the ArtifactCacheEntry
object. I weren’t able to hack around the code to ignore this attribute, so I’m not 100% sure. The attribute does contain values that would point to the caches being scoped
to different PRs, though (refs/pull/1660/merge
and refs/pull/1661/merge
on the two test pull requests I tried).
This is the setup we use:
- uses: actions/cache@v1
id: cache
with:
path: .github/vendor/bundle
key: github-gems-${{ hashFiles('**/.github/Gemfile.lock') }}
restore-keys: |
github-gems-
The bundle is installing gems to the correct folder, since the cache is successfully fetched starting from the second commit on each pull request.
Let me know if I can provide more info. Thanks!
Issue Analytics
- State:
- Created 4 years ago
- Reactions:9
- Comments:22 (7 by maintainers)
Top GitHub Comments
@chrispat
My assumption (before finding this thread) was that caches would be shared between branches in a single repository. I kept wondering why my merge commits were not using cache even though the cache key was identical to the parent commit’s build.
I would definitely love to see caches be shared between branches. I can understand wanting to avoid fork PRs from “poisoning the cache”, but I think it should be safe for all branches in a given repository to use a shared cache.
EDIT: A compromise might be that when a feature branch is merged into the default branch it’s cache could be merged into the default branch’s cache, and then the least recently used of this cache can be purged to bring it down under the limit. Worst case this is no worse than now, but best case we can use the same cache as the final commit in the feature branch.
This cache miss across different branches is creating anti-patterns in the way people work. It has been my experience that people do not create different branches or smaller pull requests because the build would start from scratch!
This should be fixed. It is not just a miss-documentation.