Basic e2e tests #766
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: ci | |
on: pull_request | |
jobs: | |
commitlint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3 | |
with: | |
fetch-depth: 0 | |
- uses: wagoid/commitlint-github-action@6319f54d83768b60acd6fd60e61007ccc583e62f # v5 | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3 | |
- uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3 | |
with: | |
node-version-file: .nvmrc | |
- run: npm ci | |
- run: npm run check-types | |
- run: npm run check-pretty | |
if: always() # get formatting errors even if there are errors above | |
- run: npm run lint | |
if: always() # get lint errors even if there are errors above | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3 | |
- uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3 | |
with: | |
node-version-file: .nvmrc | |
- run: npm ci | |
- run: npm run test | |
e2e: # modified from example: https://playwright.dev/docs/ci-intro#setting-up-github-actions | |
runs-on: ubuntu-latest | |
permissions: | |
# Give the default GITHUB_TOKEN write permission to commit and push updated snapshots | |
contents: write | |
defaults: | |
run: | |
working-directory: ./e2e | |
container: | |
image: mcr.microsoft.com/playwright:v1.49.1-noble | |
# not sure why, but it seems that the git-auto-commit-action has permission issues without this | |
options: --user 1001 | |
steps: | |
# confirmed that the open-sourced v1.0.1 code does not do anything abusive with the GITHUB_TOKEN | |
- uses: autotelic/[email protected] | |
name: Wait for Preview Deploy | |
id: wait-for-status | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
statusName: "netlify/velvety-vacherin-4193fb/deploy-preview" | |
# So that tests don't run if the preview failed | |
- name: Fail workflow if Preview Failed | |
if: steps.wait-for-status.outputs.state == 'failure' | |
run: exit 1 | |
- name: Begin e2e setup - checkout | |
uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version-file: e2e/.nvmrc | |
- name: Install dependencies | |
run: npm ci | |
# assume that if snapshots fail, that we want to update & commit them (to be reviewed in the PR) | |
- run: npm run test | |
# - run: npm run update-snapshots | |
env: | |
DEPLOY_PRIME_URL: ${{ steps.wait-for-status.outputs.target_url }} | |
# - uses: stefanzweifel/git-auto-commit-action@v5 | |
# if: ${{ !cancelled() }} | |
# with: | |
# # skip ci in commit message to prevent triggering GHA or Netlify, since we can trust the previous triggers | |
# commit_message: "chore: automated snapshot updates [skip ci]" | |
# file_pattern: "e2e/**/*-snapshots/*.png" | |
# tests can still fail for non-snapshot assertions - keep the test-report around in this case | |
- uses: actions/upload-artifact@v4 | |
if: ${{ !cancelled() }} | |
with: | |
name: playwright-report | |
# `uses` isn't affected by the `defaults.run.working-directory`, so we still need to prepend `e2e` https://stackoverflow.com/a/63122434/8409296 | |
path: e2e/playwright-report/ | |
retention-days: 5 |