Skip to content

E2E Test Workflow

E2E Test Workflow #90

Workflow file for this run

name: E2E Test
on:
- deployment_status
jobs:
e2e-test:
name: E2E Test
if: github.event_name == 'deployment_status' && github.event.deployment_status.state == 'success'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16
- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 7
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
# Figures out the version of playwright that's installed.
# 1. Because we don't know what version yarn will resolve it to, we have
# to use `yarn why` to get the actually installed version.
# 2. Because we're in a workspace, we need to make sure we get the version
# for the root and not any children, hence the `grep`. If not using
# workspaces, this can be skipped.
# 3. jq comes pre-installed in the Ubuntu runner, so we use that to get
# the correct version string.
# 4. Finally, we use sed to extract just the version number (eg; '1.22.0')
# The result is stored in steps.playwright-version.outputs.version
- name: Get installed Playwright version
id: playwright-version
run: echo "::set-output name=version::$(pnpm list @playwright/test --depth 0 --json | jq --raw-output '.[].devDependencies["@playwright/test"].version')"
# Attempt to restore the correct Playwright browser binaries based on the
# currently installed version of Playwright (The browser binary versions
# may change with Playwright versions).
# Note: Playwright's cache directory is hard coded because that's what it
# says to do in the docs. There doesn't appear to be a command that prints
# it out for us.
- uses: actions/cache@v3
id: playwright-cache
with:
path: '~/.cache/ms-playwright'
key: '${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}'
# As a fallback, if the Playwright version has changed, try use the
# most recently cached version. There's a good chance that at least one
# of the browser binary versions haven't been updated, so Playwright can
# skip installing that in the next step.
# Note: When falling back to an old cache, `cache-hit` (used below)
# will be `false`. This allows us to restore the potentially out of
# date cache, but still let Playwright decide if it needs to download
# new binaries or not.
restore-keys: |
${{ runner.os }}-playwright-
# If the Playwright browser binaries weren't able to be restored, we tell
# paywright to install everything for us.
- name: Initialize Playwright
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: pnpm exec playwright install --with-deps
- name: Run E2E tests
run: pnpm e2e
env:
BASE_URL: ${{ github.event.deployment_status.target_url }}
- name: Upload test report
if: always()
uses: actions/upload-artifact@v3
with:
name: playwright-report
path: e2e/report
retention-days: 5