-
Notifications
You must be signed in to change notification settings - Fork 1.4k
github action cache not working #819
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
Comments
Hello @enKODING1 ! Thank you for reporting the issue, we will investigate it :) |
I, too, have tried using I then tried using - uses: actions/cache@v3
with:
path: '~/.npm'
key: ${{ runner.os }}-${{ matrix.node-version }}-9.8.0-npmcache-${{ hashFiles('**/package-lock.json') }} Something I noticed, my successful cache was 510 MB, but the |
I too am not noticing any improvement in build times using the setup-node with cache. It might reduce it maybe ~15 seconds from a 2 minute build time... so nothing significant, and that could just be because of environmental things. |
Hello @enKODING1. Thank you for your report. If you need more information regarding to global cache you can take at this. In the majority cases the global cache gets impact on builds with medium or large amount of dependencies. Hello @laurence-myers. Could you please provide a link to the build ? Do you use hosted or self-hosted runners ? |
Seeing the same thing, this is my step.
What I noticed are 2 entries in Caches with the same name but listing with different refs, one for the PR and one for main after the merge.
When the second build happens after the PR merge into main, This is the main branch build output.
It seems to me in this case, the cache is being pulled based on the ref/branch as well as the yarn.lock file. Not sure if this is the intended behavior, but seems like a miss. Apologies this is a private repo and cannot provide the link. |
Hosted runners. I should have mentioned, we are using a monorepo & lerna. Here's some builds, they're in a private repo. Using just setup-node:
Then, using the cache actions directly:
|
I too have noticed that I have 27 instances of the same cache in management. Each is tied to a specific ref (branches & pull/#/merge). Does anyone know if these are pointers/references to a common object or are they truly duplicates? Also, is it rebuilding the cache for each of these? |
@byron70 @djthornton1212 This is intended behaviour, due to access restrictions: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache
So, if you want to share a cache between branches/refs, you must create the cache on your main branch. Which greatly limits the usefulness of the cache. 🫤 To avoid the restrictions, as a workaround, you could investigate using a different caching action, uploading the cache zip to e.g. S3: https://medium.com/nerd-for-tech/implementing-a-custom-github-actions-cache-375eb844e00a |
It doesn't work for use either. |
my workers are not caching the modules at all.. no matter how many times i run the same build.. it always a cache miss. jobs:
build:
runs-on: ubuntu-latest
permissions: write-all
steps:
- uses: actions/checkout@v4
- uses: fregante/setup-git-user@v2
- uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
cache: 'npm' Not sure exactly what is going wrong 😕 |
Hello everyone, Thank you for the issue. The setup-node uses global cache and please refer to the documentation for reference. For now I am going to close the issue. If you have any concerns feel free to ping us. |
@aparnajyothi-y In a perfect flow a branch or branch PR is merged to master, in this case the cache is built and stored twice, once for the PR and once post merge to master. It would be awesome if there was a "global" cache config option that allowed someone to just store and use all caches at a default branch level and not at a ref level. The above example would then only generate a cache entry once and allow greater reusability, even across PRs and branches. This also would not violate the parent cache access permission structure. I would move we reopen this issue. |
I have the same issue as the OP @enKODING1 and others. I feel I'm missing something here. "caching global packages data" is not clear. If it were indeed caching then when installing modules it wouldn't take several minutes anymore. Has someone figured this one out or is the workaround to use actions/cache directly? |
So I think I get what it's supposed to cache now. However, it don't work at all as you'd expect; enable caching then continue to install your dependencies as usual. Then on the subsequent passes the installs will be much faster since the global cache data would be restored, and not HTTP calls would be made. However that never happens. |
@aparnajyothi-y this is happening to me now too, below my configuration and my list of caches, any insight appreciated jobs:
lint:
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- run: npm i -g @nestjs/cli nx
- run: npm ci
- ... |
I'm having the same issue too. Multiple cached created with the same key, while cache reads always miss. Will abandon global yarn caching and use |
Hello everyone, |
"Workflow runs can restore caches created in either the current branch or the default branch (usually main)." We want an option to store and restore all caches on the default branch only to greatly enhance cache reusability. As is now, in current structure, due to the ephemeral nature of branches, the effective rate of my caches being reused are maybe 10-30%, when they could be at least 50% and likely significantly higher across branches. |
Hello @curtdept, could you please help us by providing the public repro link for reproducing the issue? This will help us investigate further and resolve it more efficiently. |
Hi @curtdept, just checking in to see if you could provide the public repro link needed to reproduce the issue. Thanks! |
Hi @curtdept,Just a friendly reminder to check if you could provide the public repro link needed to reproduce the issue. Thanks! |
Hi @curtdept, I will be closing this issue due to inactivity for the time being. Should you need further assistance or if the issue arises again, please feel free to reopen this issue or reach out to us for any other concerns. |
Description:
When I run the code below, I confirmed that the cache is created in management.
On the second run, cache-hit returns true, but it still takes a long time because it reinstalls dependencies.
The link below says that the machine's global cache is used. How does the machine's global cache work?
global cache
Action version:
Specify the action version
Platform:
Runner type:
Tools version:
The text was updated successfully, but these errors were encountered: