actions / cache

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

Cache miss when restoring within a reusable workflow #1271

Open Sickday opened 11 months ago

Sickday commented 11 months ago

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.

cesarvarela commented 9 months ago

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

ghost commented 9 months ago

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.

vavsab commented 8 months ago

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.