receiving "Cache not found for input keys: cache-playwright-linux-1.20.0" on github actions ubuntu-latest

Viewed 454

I follow the example provided in https://playwrightsolutions.com/playwright-github-action-to-cache-the/

in my yml file i have the following code

jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
  with:
    node-version: '16.x

then i editted only the version here to match the current one

- name: Cache playwright binaries
  uses: actions/cache@v2
  id: playwright-cache
  with:
    path: |
      ~/.cache/ms-playwright
    key: cache-playwright-linux-1.20.0

after that i run

- name: Install dependencies
  run: npm ci
- name: Install Playwright
  if: steps.playwright-cache.outputs.cache-hit != 'true'
  run: npx playwright install --with-deps
- name: Run Playwright tests
  run: npm run test

i receive "Cache not found for input keys: cache-playwright-linux-1.20.0"

1 Answers

You can improve your cache key by using the os and package-lock.json file. The latter part of the key probably changes more than preferred, but works for many builds.

- uses: actions/cache@v2
  id: playwright-cache
  with:
    path: |
      ~/.cache/ms-playwright
    key: ${{ runner.os }}-playwright-${{ hashFiles('**/package-lock.json') }}
- run: npm ci
- run: npx playwright install --with-deps
  if: steps.playwright-cache.outputs.cache-hit != 'true'
- run: npx playwright install-deps
  if: steps.playwright-cache.outputs.cache-hit == 'true'

https://justin.poehnelt.com/posts/caching-playwright-in-github-actions/

Related