cache icon indicating copy to clipboard operation
cache copied to clipboard

Failure in absolute path resolution

Open pramodka-revefi opened this issue 3 years ago • 3 comments

While using the cache action, I noticed that we are seeing the following warning in the Post Cache phase:

Warning: Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.

Due to this, our cache never actually gets saved. However, upon debugging further, I realized that the path does in fact exist on the runner. Workflow.yml steps used for debugging:

- name: Mount bazel cache
   uses: actions/cache@v3
   with:
     path: |
       "~/.cache/bazel"
       "/home/runner/.cache/bazel"
     key: bazel-cache-${{ hashFiles('**/BUILD.bazel', '**/*.bzl', 'WORKSPACE') }}
     restore-keys: |
       bazel-cache-
 # Build all bazel targets in the repository
 - name: Bazel build
   run: bazel build //...

 - name: bazel info
   run: |
     bazel info
 - name: ls check 1
   run: |
     cd /home/runner/.cache/bazel
     ls -R | head -15
 - name: ls check 2
   run: |
     cd ~/.cache/bazel
     ls -R | head -15

Full workflow yml file

The job output in the Github UI: image

The ls commands generate outputs, but the cache action is unable to find the same paths.

Further, I enabled debug logging on the actions and I think the issue in the file dist/save/index.js. And based on the debug logs the issue is in the globGenerator() method. I'm not familiar with JS, so I was unable to investigate further.

Debug logs: image

Full debug logs for workflow

Looking at the cache examples, many examples are using absolute paths. Unless I'm missing something (very likely 😄) this should be affecting them as well.

pramodka-revefi avatar Jul 26 '22 17:07 pramodka-revefi

I think the issue here is that the cache paths are quoted. This seems to break the path resolution, thinking it's a relative path

devversion avatar Jul 26 '22 22:07 devversion

Lovely 🤦 . Removing the quotes was sufficient and fixed the issue for me. Thanks @devversion.

In the course of trying to debug this issue I came across multiple examples from other folks who had also used quotes and didn't even know that their CI cache isn't working.

Examples: https://github.com/bazel-contrib/rules-template/blob/main/.github/workflows/ci.yaml#L45 https://github.com/AcademySoftwareFoundation/openexr/actions/runs/829321602/workflow

Any chance we could update the path resolution method to trim the quotes and make this idiot-proof 😄

pramodka-revefi avatar Jul 27 '22 17:07 pramodka-revefi

Thank you @devversion for answering this. @pramodka-revefi Yes, we can explore the enhancement to remove quotes during path resolution. I'll take a look.

vsvipul avatar Jul 27 '22 18:07 vsvipul

Please add the path to the log message!

pamolloy avatar Oct 19 '22 07:10 pamolloy

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[bot] avatar Oct 18 '23 08:10 github-actions[bot]

This issue was closed because it has been inactive for 5 days since being marked as stale.

github-actions[bot] avatar Oct 23 '23 08:10 github-actions[bot]