chore(e2e): create a test studio for e2e tests #3832
Workflow file for this run
This file contains 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: End-to-End Tests | |
on: | |
# Build on pushes branches that have a PR (including drafts) | |
pull_request: | |
# Build on commits pushed to branches without a PR if it's in the allowlist | |
push: | |
branches: [next] | |
jobs: | |
playwright-test: | |
timeout-minutes: 30 | |
runs-on: ubuntu-latest | |
env: | |
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} | |
TURBO_TEAM: ${{ vars.TURBO_TEAM }} | |
strategy: | |
fail-fast: false | |
matrix: | |
project: [chromium, firefox] | |
# Add more shards here if needed | |
shardIndex: [1, 2] | |
shardTotal: [2] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- name: Cache node modules | |
id: cache-node-modules | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: '**/node_modules' | |
key: ${{ runner.os }}-modules-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-modules-${{ env.cache-name }}- | |
${{ runner.os }}-modules- | |
${{ runner.os }}- | |
- name: Install project dependencies | |
if: steps.cache-node-modules.outputs.cache-hit != 'true' | |
run: yarn install --frozen-lockfile | |
- name: Store Playwright's Version | |
run: | | |
PLAYWRIGHT_VERSION=$(npx playwright --version | sed 's/Version //') | |
echo "Playwright's Version: $PLAYWRIGHT_VERSION" | |
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV | |
- name: Cache Playwright Browsers for Playwright's Version | |
id: cache-playwright-browsers | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/ms-playwright | |
key: playwright-browsers-${{ env.PLAYWRIGHT_VERSION }} | |
- name: Install Playwright Browsers | |
if: steps.cache-playwright-browsers.outputs.cache-hit != 'true' | |
run: npx playwright install --with-deps | |
- name: Build CLI | |
run: yarn build:cli # Needed for CLI tests | |
- name: Build E2E test studio | |
env: | |
# Update the SANITY_E2E_SESSION_TOKEN on github to the new value once this is merged to next | |
# Change the below to `secrets.SANITY_E2E_SESSION_TOKEN` | |
# Delete `SANITY_E2E_SESSION_TOKEN_NEW` from github | |
SANITY_E2E_SESSION_TOKEN: ${{ secrets.SANITY_E2E_SESSION_TOKEN_NEW }} | |
SANITY_E2E_PROJECT_ID: ${{ secrets.SANITY_E2E_PROJECT_ID }} | |
SANITY_E2E_DATASET: ${{ secrets.SANITY_E2E_DATASET }} | |
run: yarn e2e:build | |
- name: Run end-to-end tests | |
env: | |
# Missing in docs but in use | |
# here https://github.com/microsoft/playwright/blob/main/packages/playwright/src/reporters/blob.ts#L108 | |
PWTEST_BLOB_REPORT_NAME: ${{ matrix.project }} | |
# Update the SANITY_E2E_SESSION_TOKEN on github to the new value once this is merged to next | |
# Change the below to `secrets.SANITY_E2E_SESSION_TOKEN` | |
# Delete `SANITY_E2E_SESSION_TOKEN_NEW` from github | |
SANITY_E2E_SESSION_TOKEN: ${{ secrets.SANITY_E2E_SESSION_TOKEN_NEW }} | |
SANITY_E2E_PROJECT_ID: ${{ secrets.SANITY_E2E_PROJECT_ID }} | |
SANITY_E2E_DATASET: ${{ secrets.SANITY_E2E_DATASET }} | |
run: yarn test:e2e --project ${{ matrix.project }} --shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }} | |
- uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: playwright-report | |
path: blob-report | |
retention-days: 30 | |
merge-reports: | |
if: always() | |
needs: [playwright-test] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- name: Cache node modules | |
id: cache-node-modules | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: '**/node_modules' | |
key: ${{ runner.os }}-modules-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-modules-${{ env.cache-name }}- | |
${{ runner.os }}-modules- | |
${{ runner.os }}- | |
- name: Install project dependencies | |
if: steps.cache-node-modules.outputs.cache-hit != 'true' | |
run: yarn install --frozen-lockfile | |
- name: Download blob reports from Github Actions Artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: playwright-report | |
path: playwright-report | |
- name: Merge into HTML Report | |
run: npx playwright merge-reports --reporter html ./playwright-report | |
- name: Upload HTML report | |
uses: actions/upload-artifact@v3 | |
with: | |
name: html-report--attempt-${{ github.run_attempt }} | |
path: playwright-report | |
retention-days: 30 |