From 76099572f6b5f1f0c7d3119c4d70a31c461450f3 Mon Sep 17 00:00:00 2001 From: Andy Ford Date: Wed, 8 Apr 2026 23:36:53 +0100 Subject: [PATCH] Cache Playwright browsers in CI to avoid redundant downloads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Playwright browser binaries were being downloaded fresh on every CI run — 5 times in the parallel web CLI workflow alone. This adds actions/cache@v4 keyed on the Playwright version and OS. On cache hit, only system-level apt dependencies are installed (skipping the ~30-60s browser download). Co-Authored-By: Claude Opus 4.6 --- .github/workflows/e2e-tests.yml | 18 ++++- .github/workflows/e2e-web-cli-parallel.yml | 90 ++++++++++++++++++++-- 2 files changed, 102 insertions(+), 6 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 7c7557b7..31ca8889 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -46,9 +46,25 @@ jobs: - name: Lint check run: pnpm run lint - - name: Install Playwright Browsers + - name: Get Playwright version + id: playwright-version + run: echo "version=$(pnpm exec playwright --version)" >> $GITHUB_OUTPUT + + - name: Cache Playwright browsers + id: playwright-cache + uses: actions/cache@v4 + with: + path: ~/.cache/ms-playwright + key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }} + + - name: Install Playwright browsers + if: steps.playwright-cache.outputs.cache-hit != 'true' run: pnpm exec playwright install --with-deps + - name: Install Playwright system deps + if: steps.playwright-cache.outputs.cache-hit == 'true' + run: pnpm exec playwright install-deps + - name: Set up test environment run: | echo "ABLY_API_KEY=${{ secrets.E2E_ABLY_API_KEY }}" > .env.test diff --git a/.github/workflows/e2e-web-cli-parallel.yml b/.github/workflows/e2e-web-cli-parallel.yml index b8602d26..d03c8ce0 100644 --- a/.github/workflows/e2e-web-cli-parallel.yml +++ b/.github/workflows/e2e-web-cli-parallel.yml @@ -47,9 +47,25 @@ jobs: cd examples/web-cli pnpm build - - name: Install Playwright + - name: Get Playwright version + id: playwright-version + run: echo "version=$(pnpm exec playwright --version)" >> $GITHUB_OUTPUT + + - name: Cache Playwright browsers + id: playwright-cache + uses: actions/cache@v4 + with: + path: ~/.cache/ms-playwright + key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }} + + - name: Install Playwright browsers + if: steps.playwright-cache.outputs.cache-hit != 'true' run: pnpm exec playwright install --with-deps chromium + - name: Install Playwright system deps + if: steps.playwright-cache.outputs.cache-hit == 'true' + run: pnpm exec playwright install-deps chromium + - name: Upload build artifacts uses: actions/upload-artifact@v7 with: @@ -93,9 +109,25 @@ jobs: - name: Install dependencies run: pnpm install --frozen-lockfile - - name: Install Playwright + - name: Get Playwright version + id: playwright-version + run: echo "version=$(pnpm exec playwright --version)" >> $GITHUB_OUTPUT + + - name: Cache Playwright browsers + id: playwright-cache + uses: actions/cache@v4 + with: + path: ~/.cache/ms-playwright + key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }} + + - name: Install Playwright browsers + if: steps.playwright-cache.outputs.cache-hit != 'true' run: pnpm exec playwright install --with-deps chromium + - name: Install Playwright system deps + if: steps.playwright-cache.outputs.cache-hit == 'true' + run: pnpm exec playwright install-deps chromium + - name: Download build artifacts uses: actions/download-artifact@v8 with: @@ -142,9 +174,25 @@ jobs: - name: Install dependencies run: pnpm install --frozen-lockfile - - name: Install Playwright + - name: Get Playwright version + id: playwright-version + run: echo "version=$(pnpm exec playwright --version)" >> $GITHUB_OUTPUT + + - name: Cache Playwright browsers + id: playwright-cache + uses: actions/cache@v4 + with: + path: ~/.cache/ms-playwright + key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }} + + - name: Install Playwright browsers + if: steps.playwright-cache.outputs.cache-hit != 'true' run: pnpm exec playwright install --with-deps chromium + - name: Install Playwright system deps + if: steps.playwright-cache.outputs.cache-hit == 'true' + run: pnpm exec playwright install-deps chromium + - name: Download build artifacts uses: actions/download-artifact@v8 with: @@ -192,9 +240,25 @@ jobs: - name: Install dependencies run: pnpm install --frozen-lockfile - - name: Install Playwright + - name: Get Playwright version + id: playwright-version + run: echo "version=$(pnpm exec playwright --version)" >> $GITHUB_OUTPUT + + - name: Cache Playwright browsers + id: playwright-cache + uses: actions/cache@v4 + with: + path: ~/.cache/ms-playwright + key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }} + + - name: Install Playwright browsers + if: steps.playwright-cache.outputs.cache-hit != 'true' run: pnpm exec playwright install --with-deps chromium + - name: Install Playwright system deps + if: steps.playwright-cache.outputs.cache-hit == 'true' + run: pnpm exec playwright install-deps chromium + - name: Download build artifacts uses: actions/download-artifact@v8 with: @@ -243,9 +307,25 @@ jobs: - name: Install dependencies run: pnpm install --frozen-lockfile - - name: Install Playwright + - name: Get Playwright version + id: playwright-version + run: echo "version=$(pnpm exec playwright --version)" >> $GITHUB_OUTPUT + + - name: Cache Playwright browsers + id: playwright-cache + uses: actions/cache@v4 + with: + path: ~/.cache/ms-playwright + key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }} + + - name: Install Playwright browsers + if: steps.playwright-cache.outputs.cache-hit != 'true' run: pnpm exec playwright install --with-deps chromium + - name: Install Playwright system deps + if: steps.playwright-cache.outputs.cache-hit == 'true' + run: pnpm exec playwright install-deps chromium + - name: Download build artifacts uses: actions/download-artifact@v8 with: