Cache never hits between 2 tags even when the key is the same
See original GitHub issueI’m trying to apply 2 type of caches,
- cache for yarn on my build step.
- cache for my 3 next apps
The project is uses yarn workspaces which has 3 projects under /packages/renderers/
My build is triggered by tag creation.
name: Build & Deploy
on:
push:
tags:
- 'v1.*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- uses: actions/cache@v2
with:
path: |
${{ github.workspace }}/packages/renderers/*/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('yarn.lock') }}
- name: Install Packages
run: yarn install --frozen-lockfile
env:
CI: true
- name: Build artifacts
run: yarn build
env:
CI: true
I’ve tried to debug, found out that the recommended doc config for yarn cache which uses hashFiles('**/yarn.lock')
is wrong cause it picks yarn.lock files from node_module
(as part of the key) at the end of the build, but tries to restore with empty node_modules
which produced different hash.
I’ve changed this and now the restore key is the same but it still claims that cache not found
.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:9
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Actions/cache: Cache not being hit despite of being present
It never seems to get a hit even on the same branch. This is pretty silly.
Read more >Advanced topics on caching in Apollo Client
This article describes special cases and considerations when using the Apollo Client cache. Bypassing the cache. Sometimes you shouldn't use the cache for...
Read more >Laravel Cache: Multiple Redis drivers hit the same key and it ...
As you can see in the image here, I am calling the same key multiple times in the same request. In each case,...
Read more >Storage 5: Putting the Wrap on Caching - CS 61
Conflict: These are misses that occur because two or more data items you are accessing need to reside in the same place in...
Read more >Understanding The Vary Header - Smashing Magazine
With the coming of the Client Hints, Variants and Key specifications, ... Google Analytics), they might share the same cache hit. HTTP/2 ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, but, you’ll have to cache it before creating your tag (which triggers off your workflow). In my case, I created a separated workflow
update-cache.yml
which is triggered off when some PR is merged in the main, that is before the tag is created. So when my tag is created, the cache is available for it.Any help pls 🙏🏼