Skip to content

Commit

Permalink
ci: #373 cache playwright browser to speed up ci
Browse files Browse the repository at this point in the history
  • Loading branch information
sdorra committed Nov 2, 2024
1 parent 94b675f commit 9f11122
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
CC_OS: ${{ matrix.os }}
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1"

steps:
- name: Check out code
Expand Down Expand Up @@ -48,8 +49,35 @@ jobs:
- name: Build
run: pnpm build

- name: Install Playwright Browsers
run: pnpm playwright install --with-deps
- name: (non-windows) Set Playwright path and Get playwright version
if: runner.os != 'Windows'
run: |
echo "PLAYWRIGHT_BROWSERS_PATH=$HOME/.cache/playwright-bin" >> $GITHUB_ENV
PLAYWRIGHT_VERSION="$(pnpm ls --depth 0 --json -w @playwright/test | jq --raw-output '.[0].devDependencies["@playwright/test"].version')"
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV
- name: (windows) Set Playwright path and Get playwright version
if: runner.os == 'Windows'
run: |
echo "PLAYWRIGHT_BROWSERS_PATH=$HOME\.cache\playwright-bin" >> $env:GITHUB_ENV
$env:PLAYWRIGHT_VERSION="$(pnpm ls --depth 0 --json -w @playwright/test | jq --raw-output '.[0].devDependencies["@playwright/test"].version')"
echo "PLAYWRIGHT_VERSION=$env:PLAYWRIGHT_VERSION" >> $env:GITHUB_ENV
- name: Cache Playwright's binary
uses: actions/cache@v4
id: playwright-cache
with:
key: ${{ runner.os }}-playwright-bin-v1-${{ env.PLAYWRIGHT_VERSION }}
path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }}
restore-keys: |
${{ runner.os }}-playwright-bin-v1-
- name: Install Chromium for Playwright with deps
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: pnpm playwright install chromium --with-deps

- name: Install Chromium for Playwright with deps
if: steps.playwright-cache.outputs.cache-hit == 'true'
run: pnpm playwright install install-deps

- name: Test
run: pnpm test

0 comments on commit 9f11122

Please sign in to comment.