Repository navigation
Playwright for Cloudflare - Full Test Suite #25
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "Playwright for Cloudflare - Full Test Suite" | |
| permissions: | |
| contents: read | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - '.github/workflows/cf_playwright_*.yml' | |
| - '.npmrc' | |
| - 'package.json' | |
| - 'packages/browser-test-runtime/**' | |
| - 'packages/playwright-cloudflare/**' | |
| - 'patches/playwright.patch' | |
| - 'scripts/**' | |
| - 'submodules/playwright' | |
| - 'submodules/jest' | |
| pull_request: | |
| branches: | |
| - main | |
| paths: | |
| - '.github/workflows/cf_playwright_*.yml' | |
| - '.npmrc' | |
| - 'package.json' | |
| - 'packages/browser-test-runtime/**' | |
| - 'packages/playwright-cloudflare/**' | |
| - 'patches/playwright.patch' | |
| - 'scripts/**' | |
| - 'submodules/playwright' | |
| - 'submodules/jest' | |
| workflow_dispatch: | |
| inputs: | |
| grep: | |
| description: 'Test filter grep' | |
| required: false | |
| type: string | |
| # A newer push to the same pull request cancels its older run. Runs for main, | |
| # other branches, and manual dispatches are never cancelled by this group. | |
| concurrency: | |
| group: cf-playwright-full-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| jobs: | |
| full-tests: | |
| runs-on: ubuntu-latest | |
| # All branches deploy to the same test Worker, so only one job may use it at | |
| # a time. Shared with the smoke workflow, which uses the same group name. | |
| concurrency: | |
| group: cf-playwright-worker-deployment | |
| cancel-in-progress: false | |
| env: | |
| # Credentialed deploy + remote tests run for pushes, manual dispatches, and | |
| # PRs from branches in this repository (only writers can push those). | |
| # Fork and Dependabot PRs have no access to these secrets and only validate. | |
| RUN_REMOTE_TESTS: ${{ github.event_name != 'pull_request' || (github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22.x' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Validate package | |
| run: | | |
| npm ci | |
| git submodule update --init | |
| npm run test:release-validation | |
| npm run check:patch:playwright | |
| npm run build --workspace @cloudflare/playwright | |
| npm run test:bundle --workspace @cloudflare/playwright | |
| npm --prefix packages/playwright-cloudflare/tests run test-types | |
| npm run check:submodules | |
| - name: Deploy test Worker | |
| if: ${{ env.RUN_REMOTE_TESTS == 'true' }} | |
| working-directory: packages/playwright-cloudflare/tests | |
| env: | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| # Proxy tests read the test list from the deployed Worker. Export the | |
| # new version ID so generation waits until that version serves requests. | |
| run: | | |
| set -o pipefail | |
| npx wrangler deploy | tee "$RUNNER_TEMP/wrangler-deploy.log" | |
| version="$(sed -n 's/^Current Version ID: //p' "$RUNNER_TEMP/wrangler-deploy.log" | tail -n 1)" | |
| test -n "$version" | |
| echo "EXPECTED_WORKER_VERSION=$version" >> "$GITHUB_ENV" | |
| - name: Run tests | |
| if: ${{ env.RUN_REMOTE_TESTS == 'true' }} | |
| working-directory: packages/playwright-cloudflare | |
| env: | |
| TESTS_SERVER_URL: https://playwright-test-workers.rendering.cfdata.org | |
| CF_ACCESS_CLIENT_SECRET: ${{ secrets.CF_ACCESS_CLIENT_SECRET }} | |
| CF_ACCESS_CLIENT_ID: ${{ secrets.CF_ACCESS_CLIENT_ID }} | |
| TEST_GREP: ${{ inputs.grep }} | |
| run: | | |
| args=(--reporter=html) | |
| if [[ -n "${TEST_GREP}" ]]; then | |
| args+=(--grep "${TEST_GREP}") | |
| fi | |
| npm run test:full -- "${args[@]}" | |
| - name: Upload HTML report | |
| uses: actions/upload-artifact@v4 | |
| if: ${{ !cancelled() && env.RUN_REMOTE_TESTS == 'true' }} | |
| with: | |
| name: playwright-report--attempt-${{ github.run_attempt }} | |
| path: packages/playwright-cloudflare/tests/playwright-report | |
| retention-days: 14 | |
| - name: Deploy to Cloudflare Pages | |
| if: ${{ !cancelled() && github.event_name == 'push' && github.ref == 'refs/heads/main' }} | |
| env: | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| run: | | |
| cd packages/playwright-cloudflare/tests | |
| npx wrangler pages deploy ./playwright-report --project-name playwright-full-test-report |