diff --git a/.github/actions/install-playwright/action.yml b/.github/actions/install-playwright/action.yml index d2f1fd723b1a..6c8ea05d3c91 100644 --- a/.github/actions/install-playwright/action.yml +++ b/.github/actions/install-playwright/action.yml @@ -7,6 +7,15 @@ inputs: 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 }} runs: using: 'composite' @@ -18,8 +27,11 @@ runs: 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 echo "version=$version" >> "$GITHUB_OUTPUT" shell: bash + env: + INSTALLED_VERSION: ${{ inputs.installed-version }} working-directory: ${{ inputs.cwd }} - name: Restore cached playwright binaries diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a37d3618311f..606383ac002d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1091,6 +1091,16 @@ 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. + # 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 + - name: Prepare e2e tests run: yarn test:prepare working-directory: dev-packages/e2e-tests @@ -1116,11 +1126,14 @@ jobs: env: SENTRY_E2E_WORKSPACE_ROOT: ${{ github.workspace }} - - name: Install Playwright + - 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 @@ -1220,6 +1233,16 @@ 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. + # 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 + - name: Prepare E2E tests run: yarn test:prepare working-directory: dev-packages/e2e-tests @@ -1243,11 +1266,14 @@ jobs: timeout-minutes: 7 run: ${{ matrix.build-command || 'pnpm test:build' }} - - name: Install Playwright + - 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