cache icon indicating copy to clipboard operation
cache copied to clipboard

Cache miss when restoring within a reusable workflow

Open Sickday opened this issue 9 months ago • 3 comments

Greetings!

Our organization uses a reusable workflow to build our docker images. We recently attempted to add caching to this workflow to speed up the build process. While we already use the cache action for our separate CI workflow, we've noticed the build workflow always fails to hit the cache and it's unclear why.

Here's the current reusable build workflow

build.yml

We verified multiple times that Cache exists in the default branch (main)

image

Based on the documentation we should be able to restore this cache in our feature branches, but we're getting cache misses on the restore steps

image

Is there documentation related to this particular scenario or are we missing a key step to make this work? Any help would be appreciated.

Sickday avatar Oct 31 '23 16:10 Sickday

Did you find a solution? It is happening on our project as well.

cesarvarela avatar Dec 14 '23 20:12 cesarvarela

If they keys are identical, it's likely the version. Make sure that the paths are identical. I see that you're using a relative path.

Remember that if you have a workflow in myorg/repo1 that caches the folder folder the path is actually /home/runner/work/repo1/repo1/folder.

When you try to restore the path folder in repo2, it resolves to /home/runner/work/repo2/repo2/folder, which isn't a match.

mheguy-flo avatar Dec 16 '23 01:12 mheguy-flo

If they keys are identical, it's likely the version. Make sure that the paths are identical. I see that you're using a relative path.

Remember that if you have a workflow in myorg/repo1 that caches the folder folder the path is actually /home/runner/work/repo1/repo1/folder.

When you try to restore the path folder in repo2, it resolves to /home/runner/work/repo2/repo2/folder, which isn't a match.

Thanks! This resolved my issue. One CI used ./my_folder relative path. Another CI used my_folder relative path. They pointed to exactly same absolute path but strings were different and I was getting cache miss.

vavsab avatar Jan 25 '24 12:01 vavsab