Shard playwright tests in CI #17
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: Lint, Build, and Test Bitauth IDE | |
on: [push, pull_request] | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Restore .yarn if cached | |
id: cache-yarn | |
uses: actions/cache@v4 | |
with: | |
path: .yarn | |
key: yarn-${{ hashFiles('yarn.lock') }} | |
- name: Get Libauth version hash | |
id: libauth-version | |
run: echo "HASH=$(git submodule status libauth | cut -c -40)" >> $GITHUB_OUTPUT | |
- name: Restore libauth if cached | |
id: cache-libauth | |
uses: actions/cache@v4 | |
with: | |
path: libauth | |
key: libauth-${{ steps.libauth-version.outputs.HASH }} | |
- name: Install dependencies | |
# The "preinstall" script runs "git submodule update --init --recursive" | |
# to avoid requiring users to understand this project's submodules | |
# configuration. Since the files are owned by a different user than the | |
# GitHub Action runner (a quirk of GitHub Actions), updating the | |
# submodules again would error: `fatal: detected dubious ownership in repository at '/__w/bitauth-ide/bitauth-ide'` | |
# We can safely disable this check for CI. | |
run: git config --global --add safe.directory '*' && yarn install --immutable --immutable-cache | |
- run: yarn test:lint | |
e2e-tests: | |
# Only run e2e-tests if lint passes; this also saves running time by reusing cached submodules/dependencies | |
needs: [lint] | |
runs-on: ubuntu-latest | |
container: | |
image: mcr.microsoft.com/playwright:v1.41.0-jammy | |
strategy: | |
fail-fast: false | |
matrix: | |
environment: ['dev', 'prod'] | |
shardIndex: [1, 2, 3, 4] | |
shardTotal: [4] | |
name: e2e-tests (${{ matrix.environment }}, ${{ matrix.shardIndex }}/${{ matrix.shardTotal }}) | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Restore Yarn cache | |
id: restore-yarn | |
uses: actions/cache/restore@v4 | |
with: | |
path: .yarn | |
key: yarn-${{ hashFiles('yarn.lock') }} | |
- name: Get Libauth version hash | |
id: libauth-version | |
run: echo "HASH=$(git submodule status libauth | cut -c -40)" >> $GITHUB_OUTPUT | |
- name: Restore Libauth build | |
id: restore-libauth | |
uses: actions/cache/restore@v4 | |
with: | |
path: libauth | |
key: libauth-${{ steps.libauth-version.outputs.HASH }} | |
- name: Check cache hits | |
if: steps.restore-yarn.outputs.cache-hit == 'false' || steps.restore-libauth.outputs.cache-hit == 'false' | |
run: exit 1 | |
- name: Test development build | |
run: yarn test:e2e --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} --reporter blob,github | |
if: ${{ matrix.environment == 'dev' }} | |
env: | |
HOME: /root # https://github.com/microsoft/playwright/issues/6500 | |
- name: Test production build | |
run: yarn build && yarn test:e2e:prod --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} --reporter blob,github | |
if: ${{ matrix.environment == 'prod' }} | |
env: | |
HOME: /root # https://github.com/microsoft/playwright/issues/6500 | |
- uses: actions/upload-artifact@v4 | |
if: ${{ matrix.environment == 'prod' && matrix.shardIndex == 1 }} | |
with: | |
name: dist | |
path: dist/ | |
retention-days: 90 | |
- uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: blob-report-${{ matrix.environment }}-${{ matrix.shardIndex }} | |
path: blob-report | |
retention-days: 1 | |
- uses: codecov/codecov-action@v3 | |
merge-reports: | |
# Merge reports after playwright-tests, even if some shards have failed | |
if: always() | |
needs: [e2e-tests] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Restore Yarn cache | |
id: restore-yarn | |
uses: actions/cache/restore@v4 | |
with: | |
path: .yarn | |
key: yarn-${{ hashFiles('yarn.lock') }} | |
- name: Check cache hit | |
if: steps.restore-yarn.outputs.cache-hit == 'false' | |
run: exit 1 | |
- run: ls -lah | |
- name: Download blob reports from GitHub Actions Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: all-blob-reports | |
pattern: blob-report-* | |
merge-multiple: true | |
- run: ls -lah | |
- name: Merge into HTML Report | |
run: yarn playwright merge-reports --reporter html,github ./all-blob-reports | |
- run: ls -lah | |
- name: Upload HTML report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: html-report--run-${{ github.run_attempt }} | |
path: playwright-report | |
retention-days: 90 |