Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to use the cache action locally? #1513

Closed
garyo opened this issue Dec 18, 2022 · 9 comments
Closed

Is it possible to use the cache action locally? #1513

garyo opened this issue Dec 18, 2022 · 9 comments
Labels
kind/feature-request New feature or request

Comments

@garyo
Copy link

garyo commented Dec 18, 2022

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 garyo added the kind/feature-request New feature or request label Dec 18, 2022
@ChristopherHX
Copy link
Contributor

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

I haven't tested it

@brainstorm
Copy link

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 🎉

@molayodecker
Copy link

molayodecker commented Mar 1, 2023

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-

@brainstorm
Copy link

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 :/

@molayodecker
Copy link

@michalcs
Copy link

::***::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 🤷

@MatteoGioioso
Copy link

MatteoGioioso commented Apr 12, 2023

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 }}

@wolfogre
Copy link
Member

wolfogre commented May 5, 2023

Closed by #1770

@wolfogre wolfogre closed this as completed May 5, 2023
@joeygrisafe-RL
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature-request New feature or request
Projects
None yet
Development

No branches or pull requests

8 participants