act icon indicating copy to clipboard operation
act copied to clipboard

Is it possible to use the cache action locally?

Open garyo opened this issue 3 years ago • 2 comments

Act version

act version 0.2.34

Feature description

I'd like to debug a github actions problem that only happens when using a cache. Is it possible to use the github actions-cache@v3 action locally somehow? When I use it with default settings, I get "[warning]An internal error has occurred in cache backend." and there is no cache hit. I assume this is because it wants to connect to the github cache server?

garyo avatar Dec 18 '22 14:12 garyo

Maybe use this extra software https://github.com/sp-ricard-valverde/github-act-cache-server with act.

I haven't tested it

ChristopherHX avatar Dec 18 '22 21:12 ChristopherHX

Maybe use this extra software https://github.com/sp-ricard-valverde/github-act-cache-server with act.

I haven't tested it

Tested and works, thanks for sharing!:

(...)
[tests/test]   💬  ::debug::Resolved Keys:
[tests/test]   💬  ::debug::["Linux-cargo-cache3-3f42a65b8420df9ab86628f1233b7523c41b76a723b68f452be28c551ca29fad","Linux-cargo-cache3-"]
[tests/test]   💬  ::debug::Checking zstd --version
[tests/test]   💬  ::debug::*** zstd command line interface 64-bits v1.4.8, by Yann Collet ***
[tests/test]   💬  ::debug::Resource Url: http://localhost:8080/_apis/artifactcache/cache?keys=Linux-cargo-cache3-3f42a65b8420df9ab86628f1233b7523c41b76a723b68f452be28c551ca29fad%252CLinux-cargo-cache3-&version=2409070636ec2f8ce3c0c0ad575284d61fcf980b1ef2bb600a95071e5a8efdff
[tests/test]   💬  ::debug::Failed to delete archive: Error: ENOENT: no such file or directory, unlink ''
| Cache not found for input keys: Linux-cargo-cache3-3f42a65b8420df9ab86628f1233b7523c41b76a723b68f452be28c551ca29fad, Linux-cargo-cache3-
[tests/test]   ✅  Success - Main Cargo cache

And on the cache-server-docker log:

Attaching to github-act-cache-server-app-1
github-act-cache-server-app-1  | Cleaning up uncompleted transfers
github-act-cache-server-app-1  | Purging DB
github-act-cache-server-app-1  | Done
github-act-cache-server-app-1  | Listening on port 8080
github-act-cache-server-app-1  | Missing key Linux-cargo-cache3-3f42a65b8420df9ab86628f1233b7523c41b76a723b68f452be28c551ca29fadgithub-act-cache-server-app-1  | Missing key cargo-install-444a40cde2d505c82053

Granted, it doesn't find the cache keys because it is a first run and/or I have the keys misconfigured, but this third party cache daemon allows me to run my Rust CI workflow locally 🎉

brainstorm avatar Dec 19 '22 01:12 brainstorm

Maybe use this extra software https://github.com/sp-ricard-valverde/github-act-cache-server with act. I haven't tested it

Tested and works, thanks for sharing!:

(...)
[tests/test]   💬  ::debug::Resolved Keys:
[tests/test]   💬  ::debug::["Linux-cargo-cache3-3f42a65b8420df9ab86628f1233b7523c41b76a723b68f452be28c551ca29fad","Linux-cargo-cache3-"]
[tests/test]   💬  ::debug::Checking zstd --version
[tests/test]   💬  ::debug::*** zstd command line interface 64-bits v1.4.8, by Yann Collet ***
[tests/test]   💬  ::debug::Resource Url: http://localhost:8080/_apis/artifactcache/cache?keys=Linux-cargo-cache3-3f42a65b8420df9ab86628f1233b7523c41b76a723b68f452be28c551ca29fad%252CLinux-cargo-cache3-&version=2409070636ec2f8ce3c0c0ad575284d61fcf980b1ef2bb600a95071e5a8efdff
[tests/test]   💬  ::debug::Failed to delete archive: Error: ENOENT: no such file or directory, unlink ''
| Cache not found for input keys: Linux-cargo-cache3-3f42a65b8420df9ab86628f1233b7523c41b76a723b68f452be28c551ca29fad, Linux-cargo-cache3-
[tests/test]   ✅  Success - Main Cargo cache

And on the cache-server-docker log:

Attaching to github-act-cache-server-app-1
github-act-cache-server-app-1  | Cleaning up uncompleted transfers
github-act-cache-server-app-1  | Purging DB
github-act-cache-server-app-1  | Done
github-act-cache-server-app-1  | Listening on port 8080
github-act-cache-server-app-1  | Missing key Linux-cargo-cache3-3f42a65b8420df9ab86628f1233b7523c41b76a723b68f452be28c551ca29fadgithub-act-cache-server-app-1  | Missing key cargo-install-444a40cde2d505c82053

Granted, it doesn't find the cache keys because it is a first run and/or I have the keys misconfigured, but this third party cache daemon allows me to run my Rust CI workflow locally 🎉

Hi @brainstorm, Can you please share your cache workflow. This is what I have and it doesn't work Looks like the Authorization key is missing

::***::Resource Url: http://***:8080/_apis/artifactcache/cache?keys=Linux-yarn-e8943332524d13b75456a47ad703d0a691233a8b9b4b9a8f7146be54228fb5a2%252CLinux-yarn-&version=84d7b02a61d0b31f347fcddab445d98204dc22e7f42a4366ff8a82ec6de1ae78
[ci/test]   ❓  ::***::getCacheEntry - Attempt 1 of 2 failed with error: connect ECONNREFUSED ::1:8080
[ci/test]   💬  ::***::Resource Url: http://***:8080/_apis/artifactcache/cache?keys=Linux-yarn-e8943332524d13b75456a47ad703d0a691233a8b9b4b9a8f7146be54228fb5a2%252CLinux-yarn-&version=84d7b02a61d0b31f347fcddab445d98204dc22e7f42a4366ff8a82ec6de1ae78
[ci/test]   ❓  ::***::getCacheEntry - Attempt 2 of 2 failed with error: connect ECONNREFUSED ::1:8080
[ci/test]   ❓  ::warning::Failed to restore: getCacheEntry failed: connect ECONNREFUSED ::1:8080
- name: Get yarn cache directory path
  id: yarn-cache-dir-path
  run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- name: Setup yarn cache
  uses: actions/cache@v3
  id: cache-yarn-cache
  with:
      path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
      key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
      restore-keys: |
          ${{ runner.os }}-yarn-

molayodecker avatar Mar 01 '23 18:03 molayodecker

I don't use this anymore, but my workflows are here: https://github.com/umccr/htsget-rs/

By the error messages, it seems that the cache docker container thing is not up and/or reachable? Sorry I cannot help further :/

brainstorm avatar Mar 01 '23 20:03 brainstorm

https://github.com/umccr/htsget-rs/

It's reachable but looks like i'm not sending a Authorization token https://github.com/sp-ricard-valverde/github-act-cache-server/blob/a9f979f43bc2a7a6d233ea6690686bcb25352fe9/src/index.js#L44

Thanks for the feedback

molayodecker avatar Mar 01 '23 20:03 molayodecker

::***::Resource Url: http://***:8080/_apis/artifactcache/cache?keys=Linux-yarn-e8943332524d13b75456a47ad703d0a691233a8b9b4b9a8f7146be54228fb5a2%252CLinux-yarn-&version=84d7b02a61d0b31f347fcddab445d98204dc22e7f42a4366ff8a82ec6de1ae78
[ci/test]   ❓  ::***::getCacheEntry - Attempt 1 of 2 failed with error: connect ECONNREFUSED ::1:8080
[ci/test]   💬  ::***::Resource Url: http://***:8080/_apis/artifactcache/cache?keys=Linux-yarn-e8943332524d13b75456a47ad703d0a691233a8b9b4b9a8f7146be54228fb5a2%252CLinux-yarn-&version=84d7b02a61d0b31f347fcddab445d98204dc22e7f42a4366ff8a82ec6de1ae78
[ci/test]   ❓  ::***::getCacheEntry - Attempt 2 of 2 failed with error: connect ECONNREFUSED ::1:8080
[ci/test]   ❓  ::warning::Failed to restore: getCacheEntry failed: connect ECONNREFUSED ::1:8080

Same issue here. Can't get the authorisation working , failing on ECONNREFUSED ::1:8080

It's reachable but looks like i'm not sending a Authorization token https://github.com/sp-ricard-valverde/github-act-cache-server/blob/a9f979f43bc2a7a6d233ea6690686bcb25352fe9/src/index.js#L44

I've tried to comment out that if condition and the localhost:8080 now responds with success. But act still throws the same error when running the workflow 🤷

michalcs avatar Mar 19 '23 02:03 michalcs

Has anyone managed to make this work? I always have: Cache not found for input keys: mykey, so effectively is not caching

UPDATE: ok, it was not clear from the cache action docs that I have to explicitly save the dependencies:

      - name: Restore cached go deps
        id: cache-godeps-restore
        uses: actions/cache/restore@v3
        with:
          path: ~/go
          key: ${{ runner.os }}-godeps

       # install and build go and do other stuff

      - name: Save go deps
        id: cache-godeps-save
        uses: actions/cache/save@v3
        with:
          path: ~/go
          key: ${{ steps.cache-godeps-restore.outputs.cache-primary-key }}

MatteoGioioso avatar Apr 12 '23 06:04 MatteoGioioso

Closed by #1770

wolfogre avatar May 05 '23 06:05 wolfogre

Is this working for anyone using setup-python or setup-node actions?

joeygrisafe-RL avatar Sep 26 '23 18:09 joeygrisafe-RL