question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cache never hits between 2 tags even when the key is the same

See original GitHub issue

I’m trying to apply 2 type of caches,

  1. cache for yarn on my build step.
  2. 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

image image

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:closed
  • Created 3 years ago
  • Reactions:9
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
affonso-rafaelcommented, Sep 24, 2021

Can somebody clarify if this action is supposed to work from tag push? The documentation says “you can access the cache in workflows triggered by any event that has a GITHUB_REF”, which would imply that it should in fact work.

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.

1reaction
felixmoshcommented, Jun 8, 2020

Any help pls 🙏🏼

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found