CI Integration
Run Playwright in GitHub Actions against Alpha and Beta.
Playwright runs automatically in CI at two points: against Alpha preview URLs on every PR, and against Beta after merge.
CI testing flow
GitHub Actions — PR (Alpha)
# .github/workflows/e2e-alpha.yml
name: E2E — Alpha Preview
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
deploy-preview:
runs-on: ubuntu-latest
outputs:
preview-url: ${{ steps.deploy.outputs.url }}
steps:
- uses: actions/checkout@v4
- name: Deploy Alpha preview
id: deploy
run: echo "url=https://alpha-${{ github.event.pull_request.number }}.preview.company.com" >> "$GITHUB_OUTPUT"
e2e:
needs: deploy-preview
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: corepack enable
- run: pnpm install --frozen-lockfile
- name: Install Playwright browsers
run: pnpm exec playwright install --with-deps chromium
- name: Run Playwright (smoke + auth)
run: pnpm exec playwright test --grep-invert "@beta"
env:
PLAYWRIGHT_BASE_URL: ${{ needs.deploy-preview.outputs.preview-url }}
E2E_TEST_EMAIL: ${{ secrets.E2E_TEST_EMAIL }}
E2E_TEST_PASSWORD: ${{ secrets.E2E_TEST_PASSWORD }}
- name: Upload Playwright report
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-report-pr-${{ github.event.pull_request.number }}
path: playwright-report/
retention-days: 7GitHub Actions — Beta (post-merge)
# .github/workflows/e2e-beta.yml
name: E2E — Beta
on:
push:
branches: [main]
jobs:
e2e-beta:
runs-on: ubuntu-latest
timeout-minutes: 30
environment: beta
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: corepack enable
- run: pnpm install --frozen-lockfile
- run: pnpm exec playwright install --with-deps
- name: Wait for Beta deploy
run: |
for i in $(seq 1 30); do
curl -sf https://beta.company.com/api/health && break
sleep 10
done
- name: Run full Playwright suite
run: pnpm exec playwright test
env:
PLAYWRIGHT_BASE_URL: https://beta.company.com
E2E_TEST_EMAIL: ${{ secrets.E2E_TEST_EMAIL }}
E2E_TEST_PASSWORD: ${{ secrets.E2E_TEST_PASSWORD }}
- name: Upload Playwright report
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-report-beta
path: playwright-report/
retention-days: 14Required GitHub secrets
| Secret | Description |
|---|---|
E2E_TEST_EMAIL | Dedicated test account email |
E2E_TEST_PASSWORD | Test account password (vault) |
Store secrets at the repository or environment level. Beta secrets must differ from Production credentials.
PR comment with report link
Post the Playwright report URL as a PR comment after the Alpha run:
- name: Comment PR with report
if: always()
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `🎭 Playwright E2E: ${{ job.status }}\n\n[View report](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})`
})Parallel sharding (large suites)
Split tests across multiple CI runners:
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4]
- run: pnpm exec playwright test --shard=${{ matrix.shard }}/4Merge reports with playwright merge-reports.
Failure policy
| Result | Action |
|---|---|
| Alpha E2E fails on PR | Block merge — author fixes or updates tests |
| Beta E2E fails on merge | Alert #engineering, revert if P1 |
| Flaky test (passes on retry) | Create ticket to fix, do not ignore |
Related guides
- Testing Overview — full testing strategy
- Environments — Alpha, Beta, Prod definitions
- Release Process — Beta → Prod gate