You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature branch cannot restore cache made in main branch #1011
Goal
create snapshots cache in main branch -> restore cache in feature branch to compare snapshots
Issue
Cache hit doesn't happen in the feature branch when trying to restore the main branch's cache.
Instead, it creates a new cache with the exactly same cache key(version).
Would this be a bug?
The feature branch is based off of main branch so the scope shouldn't be an issue here I believe.
(git checkout -b cache-test on main)
The What am I missing here and how can i make this work?
Also noticing searching cache for branch "main" is not returning anything, which seems odd.
Cache should have been restored from main and created a new cache in feature branch from those files. Can you check the logs if that is the case. Can you also check if the path in both cache steps in main and feature-branch same, that is given in debug log
I resolved this issue by creating the cache on push event on the main branch. It was previously triggered on pr close action. It would be great and save much time of other developers who wanna use actions/cache if it's mentioned in the documentation that only the cache that's generated by push can be accessible to its feature branches as nowhere in the documentation mentions this.
Hi @axionos , when the pull_request trigger is used and if there is no cache to be restored i.e there is no matching cache in parent branch or default branch, the cache is created against the refs/pull/<PR_number>/merge( which is a merge branch created by GitHub by merging the PR target branch and the PR branch, check this ). The caches created against ``refs/pull/<PR_number>/merge` can only be used by this PR branch since this is a temp branch created for merging the PR.
In your case, for trigger type:
on:
pull_request:
branches:
- main
types: [closed]
Since there is no cache with key: Linux-snapshots-350c... in main ref, the cache is created against refs/pull/<PR_number>/merge'. If there would have been cache for main` ref, then that cache would have been restored.
Goal
create snapshots cache in main branch -> restore cache in feature branch to compare snapshots
Issue
Cache hit doesn't happen in the feature branch when trying to restore the main branch's cache.
Instead, it creates a new cache with the exactly same cache key(version).
Would this be a bug?
The feature branch is based off of main branch so the scope shouldn't be an issue here I believe.
(git checkout -b cache-test on main)
The What am I missing here and how can i make this work?
Also noticing searching cache for branch "main" is not returning anything, which seems odd.
I experience the same issue. The exact cache key exists on the default branch, but it is not used by runs for pull requests.
In my case, the master's cache was created in another workflow than the one that tries to retrieve the cache. However, it concerns the same composite action.
Activity
Phantsure commentedon Dec 2, 2022
Cache should have been restored from
mainand created a new cache in feature branch from those files. Can you check the logs if that is the case. Can you also check if the path in both cache steps inmainandfeature-branchsame, that is given in debug logaxionos commentedon Dec 2, 2022
I resolved this issue by creating the cache on
pushevent on the main branch. It was previously triggered onpr closeaction. It would be great and save much time of other developers who wanna use actions/cache if it's mentioned in the documentation that only the cache that's generated bypushcan be accessible to its feature branches as nowhere in the documentation mentions this.kotewar commentedon Dec 3, 2022
@axionos, can you please share the trigger condition present in your workflow file (both before and after)? Example-
axionos commentedon Dec 6, 2022
@kotewar this will trigger the workflow on pull request push.
Before:
After:
anuragc617 commentedon Dec 12, 2022
Hi @axionos , when the
pull_requesttrigger is used and if there is no cache to be restored i.e there is no matching cache in parent branch or default branch, the cache is created against therefs/pull/<PR_number>/merge( which is a merge branch created by GitHub by merging the PR target branch and the PR branch, check this ). The caches created against ``refs/pull/<PR_number>/merge` can only be used by this PR branch since this is a temp branch created for merging the PR.In your case, for trigger type:
Since there is no cache with key:
Linux-snapshots-350c...inmainref, the cache is created againstrefs/pull/<PR_number>/merge'. If there would have been cache formain` ref, then that cache would have been restored.cklim483 commentedon Dec 21, 2022
ivard commentedon Feb 24, 2023
I experience the same issue. The exact cache key exists on the default branch, but it is not used by runs for pull requests.

In my case, the
master's cache was created in another workflow than the one that tries to retrieve the cache. However, it concerns the same composite action.https://github.com/privacybydesign/irmamobile/blob/6a684d3a82de5e06371c02fa2e2f9e356a7d4bb4/.github/actions/setup-build-environment/action.yml#L46
github-actions commentedon Sep 13, 2023
This issue is stale because it has been open for 200 days with no activity. Leave a comment to avoid closing this issue in 5 days.
github-actions commentedon Sep 18, 2023
This issue was closed because it has been inactive for 5 days since being marked as stale.