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

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

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

  1. jobs:
  2. test:
  3. timeout-minutes: 60
  4. runs-on: ubuntu-latest
  5. steps:
  6. - uses: actions/checkout@v2
  7. - uses: actions/setup-node@v2
  8. with:
  9. node-version: '16.x

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

  1. - name: Cache playwright binaries
  2. uses: actions/cache@v2
  3. id: playwright-cache
  4. with:
  5. path: |
  6. ~/.cache/ms-playwright
  7. key: cache-playwright-linux-1.20.0

之后我跑

  1. - name: Install dependencies
  2. run: npm ci
  3. - name: Install Playwright
  4. if: steps.playwright-cache.outputs.cache-hit != 'true'
  5. run: npx playwright install --with-deps
  6. - name: Run Playwright tests
  7. run: npm run test

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

0vvn1miw

0vvn1miw1#

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

  1. - uses: actions/cache@v2
  2. id: playwright-cache
  3. with:
  4. path: |
  5. ~/.cache/ms-playwright
  6. key: ${{ runner.os }}-playwright-${{ hashFiles('**/package-lock.json') }}
  7. - run: npm ci
  8. - run: npx playwright install --with-deps
  9. if: steps.playwright-cache.outputs.cache-hit != 'true'
  10. - run: npx playwright install-deps
  11. if: steps.playwright-cache.outputs.cache-hit == 'true'

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

dldeef67

dldeef672#

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

  1. - name: Install dependencies
  2. run: npm ci
  3. - name: Get installed Playwright version
  4. id: playwright-version
  5. run: echo "version=$(npm ls @playwright/test | grep @playwright | sed 's/.*@//')" >> $GITHUB_OUTPUT
  6. - name: Cache Playwright
  7. uses: actions/cache@v3
  8. id: playwright-cache
  9. with:
  10. path: ~/.cache/ms-playwright
  11. key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}
  12. restore-keys: |
  13. ${{ runner.os }}-playwright-
  14. - name: Install Playwright and dependencies
  15. run: npx playwright install --with-deps chromium
  16. if: steps.playwright-cache.outputs.cache-hit != 'true'
  17. - name: Install only Playwright dependencies
  18. run: npx playwright install-deps chromium
  19. if: steps.playwright-cache.outputs.cache-hit == 'true'

结果:



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

展开查看全部

相关问题