首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在github操作ubuntu上接收“未找到输入键的缓存:缓存-剧作家-linux-1.20.0”-最新消息

在github操作ubuntu上接收“未找到输入键的缓存:缓存-剧作家-linux-1.20.0”-最新消息
EN

Stack Overflow用户
提问于 2022-03-18 12:39:13
回答 2查看 657关注 0票数 3

我遵循https://playwrightsolutions.com/playwright-github-action-to-cache-the/中提供的示例

在我的yml文件中,有以下代码

代码语言:javascript
复制
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
  with:
    node-version: '16.x

然后,我只编辑了这里的版本,以匹配当前的版本。

代码语言:javascript
复制
- name: Cache playwright binaries
  uses: actions/cache@v2
  id: playwright-cache
  with:
    path: |
      ~/.cache/ms-playwright
    key: cache-playwright-linux-1.20.0

在那之后我跑

代码语言:javascript
复制
- 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”。

EN

回答 2

Stack Overflow用户

发布于 2022-09-24 06:26:27

您可以通过使用os和package-lock.json文件来改进缓存密钥。键的后半部分可能会发生更多的变化,但适用于许多构建。

代码语言:javascript
复制
- 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/

票数 2
EN

Stack Overflow用户

发布于 2022-10-27 05:53:25

这个策略适用于我(对铬的依赖):

代码语言:javascript
复制
      - 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 discussion https://github.com/microsoft/playwright/issues/7249

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71527147

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档