接收到“未找到输入键的缓存:Linux-1.20.0”在github上的动作ubuntu-latest

s4n0splo  于 2022-11-02  发布在  Linux
关注(0)|答案(2)|浏览(319)

我遵循https://playwrightsolutions.com/playwright-github-action-to-cache-the/中提供的示例
在我的yml文件中,我有以下代码

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

然后我只在这里编辑版本以匹配当前版本

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

之后我跑

- 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

我收到“未找到输入键的缓存:高速缓存-剧作家-Linux-1.20.0”

0vvn1miw

0vvn1miw1#

你可以通过使用os和package-lock.json文件来改进你的缓存键。键的后一部分可能会比你喜欢的修改得更多,但是对很多构建都有效。

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

dldeef67

dldeef672#

这个策略对我很有效(有铬依赖):

- name: Install dependencies
        run: npm ci

      - name: Get installed Playwright version
        id: playwright-version
        run: echo "version=$(npm ls @playwright/test | grep @playwright | sed 's/.*@//')" >> $GITHUB_OUTPUT

      - name: Cache Playwright
        uses: actions/cache@v3
        id: playwright-cache
        with:
          path: ~/.cache/ms-playwright
          key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}
          restore-keys: |
            ${{ runner.os }}-playwright-

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

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

结果:



的数据。
要查找更多信息,请参阅GitHub讨论https://github.com/microsoft/playwright/issues/7249

相关问题