3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Github Actions – Playwright で利用する ブラウザ Chromium をキャッシュ利用する

Last updated at Posted at 2024-04-26

概要

キャッシュするディレクトリ

runner で Chromium がインストールされるディレクトリをそのままキャッシュ・リストアする

キャッシュのキー

ハッシュ生成元として利用できるファイル ( npm で言うところの package.json 的なファイル ) がないので、playwrightのバージョンをキャッシュのキーとする

Playwrightのバージョンに対して各ブラウザのバージョンは固定のようなので

STEP

RestoreとCacheを1個のSTEPで実現せず、Restore / Cache のステップに分けている

参考

Workflowの例 (一部)

- name: Get Playwright Version For Browser Cache Key
  id: get-playwright-version
  run: |
    echo "playwright-version=$(npx playwright --version | sed 's/ //g')" >> $GITHUB_OUTPUT
  shell: bash

- name: Restore Cache Playwright Browser
  id: restore-cache-playwright-chromium
  uses: actions/cache/restore@v4
  with:
    path: /home/runner/.cache/ms-playwright
    key: playwright-chromium-${{ steps.get-playwright-version.outputs.playwright-version }}

- name: Install Playwright Browsers
  run: npx playwright install chromium
  if: ${{ steps.restore-cache-playwright-chromium.outputs.cache-hit != 'true' }}

- name: Save Cache – Playwright Browser
  uses: actions/cache@v4
  id: save-cache-playwright-chromium
  with:
    path: /home/runner/.cache/ms-playwright
    key: ${{ steps.restore-cache-playwright-chromium.outputs.cache-primary-key }}

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

プロフィール・経歴

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?