ci: add e2e test sharding #7
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: Run e2e tests | |
#on: | |
# workflow_call: | |
on: | |
push: | |
branches: | |
- 'test-ci' | |
pull_request: | |
branches: | |
- 'test-ci' | |
env: | |
MAILER_SECRET: E2E | |
AUTH_SECRET: E2E | |
jobs: | |
run-tests: | |
runs-on: ubuntu-latest | |
if: always() | |
services: | |
smtp: | |
image: "inbucket/inbucket" | |
ports: | |
- 1025:2500 | |
- 8025:9000 | |
db: | |
image: "postgres:12" | |
env: | |
POSTGRES_HOST_AUTH_METHOD: trust | |
POSTGRES_DB: codex_test | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
strategy: | |
fail-fast: false | |
matrix: | |
node-version: [ 20.x ] | |
shardIndex: [ 1, 2 ] | |
shardTotal: [ 2 ] | |
name: Run e2e shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }} | |
env: | |
DATABASE_URL: postgres://postgres@localhost/codex_test_${{ matrix.shardIndex}} | |
NODE_ENV: test | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Enable Corepack | |
run: corepack enable | |
- name: Setup node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'pnpm' | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile --prefer-offline | |
- name: Run database migrations | |
run: npx prisma migrate reset --force | |
- name: Store Playwright's Version | |
run: | | |
PLAYWRIGHT_VERSION=$(npm ls @playwright/test | grep @playwright | sed 's/.*@//') | |
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: Setup Playwright | |
if: steps.cache-playwright-browsers.outputs.cache-hit != 'true' | |
run: npx playwright install chromium --with-deps | |
- name: Run e2e tests | |
run: npx playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} | |
- name: Upload test report | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: blob-report-${{ matrix.shardIndex }} | |
path: blob-report/ | |
retention-days: 1 | |
merge-reports: | |
if: always() | |
needs: [run-tests] | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
node-version: [ 20.x ] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Download blob reports from GitHub Actions Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: all-blob-reports | |
pattern: blob-report-* | |
merge-multiple: true | |
- name: Merge into HTML Report | |
run: npx playwright merge-reports --reporter html ./all-blob-reports | |
- name: Upload HTML report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: html-report--attempt-${{ github.run_attempt }} | |
path: playwright-report | |
retention-days: 7 |