Skip to content
Merged
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
35 changes: 14 additions & 21 deletions .github/actions/install-playwright/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,25 @@ inputs:
description: 'What browsers to install.'
default: 'chromium webkit firefox'
cwd:
description: 'The working directory to run Playwright in.'
default: '.'
installed-version:
description:
'A Playwright version that an earlier run of this action already installed. Skips the install if it matches.'
default: ''

outputs:
version:
description: 'The resolved Playwright version, empty if Playwright is not installed or the install was skipped.'
value: ${{ steps.playwright-version.outputs.version }}
'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

runs:
using: 'composite'
steps:
# Resolve the app's @playwright/test version. Some apps (e.g. the node bundler apps) assert via a
# plain node script and don't depend on Playwright — emit an empty version instead of failing, so
# the steps below skip the (wasted) browser install rather than erroring on the missing package.
# Read from package.json rather than node_modules, so this can run before dependencies are installed.
- name: Get Playwright version
id: playwright-version
run: |
version=$(node -e "let v = ''; try { v = require('@playwright/test/package.json').version; } catch {} process.stdout.write(String(v));")
if [ "$version" = "$INSTALLED_VERSION" ]; then version=''; fi
version=$(node -e "
const { dependencies, devDependencies } = require('./package.json');
const range = devDependencies?.['@playwright/test'] ?? dependencies?.['@playwright/test'] ?? '';
process.stdout.write(range.replace(/^[~^=]/, ''));
")
echo "version=$version" >> "$GITHUB_OUTPUT"
shell: bash
env:
INSTALLED_VERSION: ${{ inputs.installed-version }}
working-directory: ${{ inputs.cwd }}

- name: Restore cached playwright binaries
Expand All @@ -46,18 +38,19 @@ runs:

# We always install all browsers, if uncached
- name: Install Playwright dependencies (uncached)
run: npx playwright install chromium webkit firefox --with-deps
env:
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'
shell: bash
working-directory: ${{ inputs.cwd }}

- name: Install Playwright system dependencies only (cached)
env:
PLAYWRIGHT_BROWSERS: ${{ inputs.browsers || 'chromium webkit firefox' }}
run: npx playwright install-deps "$PLAYWRIGHT_BROWSERS"
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'
shell: bash
working-directory: ${{ inputs.cwd }}

# Only store cache on develop branch
- name: Store cached playwright binaries
Expand Down
24 changes: 6 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,7 @@ jobs:
uses: ./.github/actions/install-playwright
with:
browsers: ${{ matrix.project }}
cwd: dev-packages/browser-integration-tests

- name: Run Playwright tests
env:
Expand Down Expand Up @@ -746,6 +747,7 @@ jobs:
uses: ./.github/actions/install-playwright
with:
browsers: chromium
cwd: dev-packages/browser-integration-tests

- name: Run Playwright Loader tests
env:
Expand Down Expand Up @@ -1101,15 +1103,15 @@ jobs:
name: build-layer-output
path: ${{ env.BUILD_LAYER_PATH }}

# Installs the root workspace's Playwright version while the app builds. Most apps use the same version.
# The app's own version is only known after its build, so it gets installed then if it differs.
# Installs Playwright while 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
background: true
uses: ./.github/actions/install-playwright
with:
browsers: chromium
cwd: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}

- name: Prepare e2e tests
run: yarn test:prepare
Expand Down Expand Up @@ -1138,13 +1140,6 @@ jobs:

- wait: [install-playwright]

- name: Install Playwright for the app's version
uses: ./.github/actions/install-playwright
with:
browsers: chromium
cwd: ${{ runner.temp }}/test-application
installed-version: ${{ steps.install-playwright.outputs.version }}

- name: Run E2E test
working-directory: ${{ runner.temp }}/test-application
timeout-minutes: 10
Expand Down Expand Up @@ -1248,15 +1243,15 @@ jobs:
name: build-tarball-output
path: ${{ env.TARBALL_ARTIFACT_DOWNLOAD_PATH }}

# Installs the root workspace's Playwright version while the app builds. Most apps use the same version.
# The app's own version is only known after its build, so it gets installed then if it differs.
# Installs Playwright while 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
background: true
uses: ./.github/actions/install-playwright
with:
browsers: chromium
cwd: dev-packages/e2e-tests/test-applications/${{ matrix.test-application }}

- name: Prepare E2E tests
run: yarn test:prepare
Expand All @@ -1283,13 +1278,6 @@ jobs:

- wait: [install-playwright]

- name: Install Playwright for the app's version
uses: ./.github/actions/install-playwright
with:
browsers: chromium
cwd: ${{ runner.temp }}/test-application
installed-version: ${{ steps.install-playwright.outputs.version }}

- name: Run E2E test
working-directory: ${{ runner.temp }}/test-application
timeout-minutes: 10
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/flaky-test-detector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
uses: ./.github/actions/install-playwright
with:
browsers: 'chromium'
cwd: dev-packages/browser-integration-tests

- name: Determine changed tests
uses: dorny/paths-filter@v4.0.3
Expand Down
Loading