actions / cache

Cache dependencies and build outputs in GitHub Actions
MIT License
4.39k stars 1.17k forks source link

The cache is created on but action does not find it next time #1197

Closed budarin closed 1 year ago

budarin commented 1 year ago

Here is the repo

wf:

            - name: Cache Node modules
              id: npm_cache
              uses: actions/cache@v3
              with:
                  key: nm-pw-${{ hashFiles('yarn.lock') }}
                  path: |
                      node_modules
                      ~/.cache/ms-playwright

            - if: ${{ steps.npm_cache.outputs.cache-hit != 'true' }}
              run: yarn install --frozen-lockfile

            - if: ${{ steps.npm_cache.outputs.cache-hit != 'true' }}
              run: npx playwright install --with-deps

cache is create in post action

image

But the next time the action is launched, it does not find this cache for some unknown reasons, although it is there!

image
RDhar commented 5 months ago

Appreciate you sharing that snippet, @budarin: exactly what I was looking for use in a GitHub Action workflow. Thanks!

- name: Set up Node
  uses: actions/setup-node@v4.0.2
  with:
    node-version: "20"

- name: Cache Node modules
  id: cache_node_modules
  uses: actions/cache@v4.0.0
  with:
    path: |
      ~/.cache/ms-playwright
      node_modules
    key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}

- name: Install Node dependencies
  if: steps.cache_node_modules.outputs.cache-hit != 'true'
  run: npm ci

- name: Install Playwright dependencies
  if: steps.cache_node_modules.outputs.cache-hit != 'true'
  run: npx playwright install --with-deps

- name: Run Playwright tests
  run: npx playwright test