Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions .github/actions/install-playwright/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -29,35 +34,46 @@ 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
# Bump the iteration when bumping runner images to use a new cache
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
Expand Down
5 changes: 5 additions & 0 deletions .github/actions/restore-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down
202 changes: 130 additions & 72 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -671,22 +671,42 @@ 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
with:
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'
Comment thread
cursor[bot] marked this conversation as resolved.

- wait: [install-playwright-browsers, install-playwright-deps]

- name: Run Playwright tests
env:
Expand Down Expand Up @@ -734,22 +754,42 @@ 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
with:
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:
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand Down
Loading