From 55774604fc71a235ee9f91d1a248522f6f610387 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Thu, 15 Oct 2026 09:42:01 +0200 Subject: [PATCH] ci: Install Playwright in the background in more places The install-playwright action gets a `part` input, so the system dependencies and the browsers can install as two parallel background steps. Browser integration and loader tests now install Playwright while the dependency cache restores, and E2E jobs start the install right after the artifact downloads, before setting up pnpm, Node and other runtimes. Co-Authored-By: Claude Opus 5.5 --- .github/actions/install-playwright/action.yml | 32 ++- .github/actions/restore-cache/action.yml | 5 + .github/workflows/build.yml | 202 +++++++++++------- 3 files changed, 159 insertions(+), 80 deletions(-) diff --git a/.github/actions/install-playwright/action.yml b/.github/actions/install-playwright/action.yml index 30815292dea2..0c1d2702b759 100644 --- a/.github/actions/install-playwright/action.yml +++ b/.github/actions/install-playwright/action.yml @@ -9,6 +9,11 @@ inputs: 'The directory whose package.json declares the `@playwright/test` version to install. Nothing is installed if it does not depend on `@playwright/test`.' required: true + part: + description: + 'What to install: `all`, `browsers` or `system-deps`. `browsers` and `system-deps` together install the same as + `all`, and can run as two background steps in parallel.' + default: 'all' runs: using: 'composite' @@ -29,7 +34,7 @@ runs: - name: Restore cached playwright binaries uses: actions/cache/restore@v6.1.0 id: playwright-cache - if: steps.playwright-version.outputs.version != '' + if: steps.playwright-version.outputs.version != '' && inputs.part != 'system-deps' with: path: | ~/.cache/ms-playwright @@ -37,27 +42,38 @@ runs: key: playwright-${{ runner.os }}-iteration-1-${{ steps.playwright-version.outputs.version }} # We always install all browsers, if uncached - - name: Install Playwright dependencies (uncached) + - name: Install Playwright browsers (uncached) env: + PART: ${{ inputs.part }} PLAYWRIGHT_VERSION: ${{ steps.playwright-version.outputs.version }} - run: npx -y "playwright@$PLAYWRIGHT_VERSION" install chromium webkit firefox --with-deps - if: steps.playwright-version.outputs.version != '' && steps.playwright-cache.outputs.cache-hit != 'true' + run: | + if [ "$PART" = all ]; then + npx -y "playwright@$PLAYWRIGHT_VERSION" install chromium webkit firefox --with-deps + else + # A separate npm cache, so this `npx` doesn't race the one installing the system deps in parallel. + npm_config_cache="$RUNNER_TEMP/playwright-npm-cache" npx -y "playwright@$PLAYWRIGHT_VERSION" install chromium webkit firefox + fi + if: + steps.playwright-version.outputs.version != '' && inputs.part != 'system-deps' && + steps.playwright-cache.outputs.cache-hit != 'true' shell: bash - - name: Install Playwright system dependencies only (cached) + - name: Install Playwright system dependencies env: PLAYWRIGHT_BROWSERS: ${{ inputs.browsers || 'chromium webkit firefox' }} PLAYWRIGHT_VERSION: ${{ steps.playwright-version.outputs.version }} run: npx -y "playwright@$PLAYWRIGHT_VERSION" install-deps "$PLAYWRIGHT_BROWSERS" - if: steps.playwright-version.outputs.version != '' && steps.playwright-cache.outputs.cache-hit == 'true' + if: + steps.playwright-version.outputs.version != '' && (inputs.part == 'system-deps' || (inputs.part == 'all' && + steps.playwright-cache.outputs.cache-hit == 'true')) shell: bash # Only store cache on develop branch - name: Store cached playwright binaries uses: actions/cache/save@v6.1.0 if: - steps.playwright-version.outputs.version != '' && github.event_name == 'push' && github.ref == - 'refs/heads/develop' + steps.playwright-version.outputs.version != '' && inputs.part != 'system-deps' && github.event_name == 'push' && + github.ref == 'refs/heads/develop' with: path: | ~/.cache/ms-playwright diff --git a/.github/actions/restore-cache/action.yml b/.github/actions/restore-cache/action.yml index ce5c2abd676e..5f826594962e 100644 --- a/.github/actions/restore-cache/action.yml +++ b/.github/actions/restore-cache/action.yml @@ -5,6 +5,10 @@ inputs: dependency_cache_key: description: 'The dependency cache key' required: true + restore-build-output: + description: + 'Whether to download the build output artifact. Disable it to download the artifact in a separate step.' + default: 'true' runs: using: 'composite' @@ -17,6 +21,7 @@ runs: key: ${{ inputs.dependency_cache_key }} - name: Restore build artifacts + if: inputs.restore-build-output == 'true' uses: actions/download-artifact@v7 with: name: build-output diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 143a6144852d..24df658f3a8a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -671,10 +671,10 @@ jobs: uses: actions/setup-node@v7 with: node-version-file: 'package.json' - - name: Restore caches - uses: ./.github/actions/restore-cache + - name: Restore build artifacts + uses: actions/download-artifact@v8 with: - dependency_cache_key: ${{ needs.job_build.outputs.dependency_cache_key }} + name: build-output - name: Restore build bundle artifacts uses: actions/download-artifact@v8 @@ -682,11 +682,31 @@ jobs: name: build-bundle-output path: ${{ env.BUNDLE_ARTIFACT_DOWNLOAD_PATH }} - - name: Install Playwright + # Started after the artifact downloads: starting next to them made `download-artifact` fail to read the event file. + - name: Install Playwright browsers + id: install-playwright-browsers + background: true + uses: ./.github/actions/install-playwright + with: + cwd: dev-packages/browser-integration-tests + part: browsers + + - name: Install Playwright system dependencies + id: install-playwright-deps + background: true uses: ./.github/actions/install-playwright with: browsers: ${{ matrix.project }} cwd: dev-packages/browser-integration-tests + part: system-deps + + - name: Restore caches + uses: ./.github/actions/restore-cache + with: + dependency_cache_key: ${{ needs.job_build.outputs.dependency_cache_key }} + restore-build-output: 'false' + + - wait: [install-playwright-browsers, install-playwright-deps] - name: Run Playwright tests env: @@ -734,10 +754,10 @@ jobs: uses: actions/setup-node@v7 with: node-version-file: 'package.json' - - name: Restore caches - uses: ./.github/actions/restore-cache + - name: Restore build artifacts + uses: actions/download-artifact@v8 with: - dependency_cache_key: ${{ needs.job_build.outputs.dependency_cache_key }} + name: build-output - name: Restore build bundle artifacts uses: actions/download-artifact@v8 @@ -745,11 +765,31 @@ jobs: name: build-bundle-output path: ${{ env.BUNDLE_ARTIFACT_DOWNLOAD_PATH }} - - name: Install Playwright + # Started after the artifact downloads: starting next to them made `download-artifact` fail to read the event file. + - name: Install Playwright browsers + id: install-playwright-browsers + background: true + uses: ./.github/actions/install-playwright + with: + cwd: dev-packages/browser-integration-tests + part: browsers + + - name: Install Playwright system dependencies + id: install-playwright-deps + background: true uses: ./.github/actions/install-playwright with: browsers: chromium cwd: dev-packages/browser-integration-tests + part: system-deps + + - name: Restore caches + uses: ./.github/actions/restore-cache + with: + dependency_cache_key: ${{ needs.job_build.outputs.dependency_cache_key }} + restore-build-output: 'false' + + - wait: [install-playwright-browsers, install-playwright-deps] - name: Run Playwright Loader tests env: @@ -1068,37 +1108,6 @@ jobs: uses: actions/checkout@v7 with: ref: ${{ env.HEAD_COMMIT }} - - name: Set up Node - uses: actions/setup-node@v7 - with: - node-version-file: 'dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}/package.json' - - name: Set up Bun - if: - matrix.test-application == 'node-exports-test-app' || contains(matrix.test-application, 'bun') || - matrix.runtime == 'bun' - uses: oven-sh/setup-bun@v2 - with: - bun-version: '1.3.14' - - name: Set up AWS SAM - if: matrix.test-application == 'aws-serverless' || matrix.test-application == 'aws-serverless-layer' - uses: aws-actions/setup-sam@v3 - with: - use-installer: true - token: ${{ secrets.GITHUB_TOKEN }} - - name: Set up Deno - if: contains(matrix.test-application, 'deno') || matrix.runtime == 'deno' - uses: denoland/setup-deno@v2.0.5 - with: - deno-version: ${{ matrix.deno-version || 'v2.8.3' }} - # Not `install-pnpm`: it takes pnpm from the root node_modules, which this job doesn't restore. - - name: Resolve pnpm version - id: pnpm-version - run: echo "version=$(jq -er '.devDependencies.pnpm' package.json)" >> "$GITHUB_OUTPUT" - - name: Install pnpm - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 - with: - version: ${{ steps.pnpm-version.outputs.version }} - - name: Restore tarball artifacts uses: actions/download-artifact@v8 with: @@ -1125,15 +1134,55 @@ jobs: with: name: build-output - # Installs Playwright while the app builds. + # Installs Playwright while the job sets up and the app builds. # Started after the artifact downloads: starting next to them made `download-artifact` fail to read the event file. - - name: Install Playwright - id: install-playwright + - name: Install Playwright browsers + id: install-playwright-browsers + background: true + uses: ./.github/actions/install-playwright + with: + cwd: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }} + part: browsers + + - name: Install Playwright system dependencies + id: install-playwright-deps background: true uses: ./.github/actions/install-playwright with: browsers: chromium cwd: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }} + part: system-deps + + # Not `install-pnpm`: it takes pnpm from the root node_modules, which this job doesn't restore. + - name: Resolve pnpm version + id: pnpm-version + run: echo "version=$(jq -er '.devDependencies.pnpm' package.json)" >> "$GITHUB_OUTPUT" + - name: Install pnpm + uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 + with: + version: ${{ steps.pnpm-version.outputs.version }} + - name: Set up Node + uses: actions/setup-node@v7 + with: + node-version-file: 'dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}/package.json' + - name: Set up Bun + if: + matrix.test-application == 'node-exports-test-app' || contains(matrix.test-application, 'bun') || + matrix.runtime == 'bun' + uses: oven-sh/setup-bun@v2 + with: + bun-version: '1.3.14' + - name: Set up AWS SAM + if: matrix.test-application == 'aws-serverless' || matrix.test-application == 'aws-serverless-layer' + uses: aws-actions/setup-sam@v3 + with: + use-installer: true + token: ${{ secrets.GITHUB_TOKEN }} + - name: Set up Deno + if: contains(matrix.test-application, 'deno') || matrix.runtime == 'deno' + uses: denoland/setup-deno@v2.0.5 + with: + deno-version: ${{ matrix.deno-version || 'v2.8.3' }} - name: Prepare e2e tests run: yarn test:prepare @@ -1160,7 +1209,7 @@ jobs: env: SENTRY_E2E_WORKSPACE_ROOT: ${{ github.workspace }} - - wait: [install-playwright] + - wait: [install-playwright-browsers, install-playwright-deps] - name: Run E2E test working-directory: ${{ runner.temp }}/test-application @@ -1219,31 +1268,6 @@ jobs: uses: actions/checkout@v7 with: ref: ${{ env.HEAD_COMMIT }} - - name: Set up Node - uses: actions/setup-node@v7 - with: - node-version-file: 'dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}/package.json' - - name: Set up Bun - if: - matrix.test-application == 'node-exports-test-app' || contains(matrix.test-application, 'bun') || - matrix.runtime == 'bun' - uses: oven-sh/setup-bun@v2 - with: - bun-version: '1.3.14' - - name: Set up Deno - if: contains(matrix.test-application, 'deno') || matrix.runtime == 'deno' - uses: denoland/setup-deno@v2.0.5 - with: - deno-version: ${{ matrix.deno-version || 'v2.8.3' }} - # Not `install-pnpm`: it takes pnpm from the root node_modules, which this job doesn't restore. - - name: Resolve pnpm version - id: pnpm-version - run: echo "version=$(jq -er '.devDependencies.pnpm' package.json)" >> "$GITHUB_OUTPUT" - - name: Install pnpm - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 - with: - version: ${{ steps.pnpm-version.outputs.version }} - - name: Restore tarball artifacts uses: actions/download-artifact@v8 with: @@ -1256,15 +1280,49 @@ jobs: name: build-test-utils-tarball-output path: dev-packages/test-utils - # Installs Playwright while the app builds. + # Installs Playwright while the job sets up and the app builds. # Started after the artifact downloads: starting next to them made `download-artifact` fail to read the event file. - - name: Install Playwright - id: install-playwright + - name: Install Playwright browsers + id: install-playwright-browsers + background: true + uses: ./.github/actions/install-playwright + with: + cwd: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }} + part: browsers + + - name: Install Playwright system dependencies + id: install-playwright-deps background: true uses: ./.github/actions/install-playwright with: browsers: chromium cwd: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }} + part: system-deps + + # Not `install-pnpm`: it takes pnpm from the root node_modules, which this job doesn't restore. + - name: Resolve pnpm version + id: pnpm-version + run: echo "version=$(jq -er '.devDependencies.pnpm' package.json)" >> "$GITHUB_OUTPUT" + - name: Install pnpm + uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 + with: + version: ${{ steps.pnpm-version.outputs.version }} + - name: Set up Node + uses: actions/setup-node@v7 + with: + node-version-file: 'dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}/package.json' + - name: Set up Bun + if: + matrix.test-application == 'node-exports-test-app' || contains(matrix.test-application, 'bun') || + matrix.runtime == 'bun' + uses: oven-sh/setup-bun@v2 + with: + bun-version: '1.3.14' + - name: Set up Deno + if: contains(matrix.test-application, 'deno') || matrix.runtime == 'deno' + uses: denoland/setup-deno@v2.0.5 + with: + deno-version: ${{ matrix.deno-version || 'v2.8.3' }} - name: Prepare E2E tests run: yarn test:prepare @@ -1289,7 +1347,7 @@ jobs: timeout-minutes: 7 run: ${{ matrix.build-command || 'pnpm test:build' }} - - wait: [install-playwright] + - wait: [install-playwright-browsers, install-playwright-deps] - name: Run E2E test working-directory: ${{ runner.temp }}/test-application