Skip to content

Commit

Permalink
ci: add e2e test sharding
Browse files Browse the repository at this point in the history
  • Loading branch information
sgomez committed Mar 28, 2024
1 parent 4171f03 commit 3380f7d
Show file tree
Hide file tree
Showing 2 changed files with 454 additions and 389 deletions.
54 changes: 51 additions & 3 deletions .github/workflows/shard-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env:
AUTH_SECRET: E2E

jobs:
e2e:
run-tests:
runs-on: ubuntu-latest
if: always()
services:
Expand All @@ -40,9 +40,10 @@ jobs:
node-version: [ 20.x ]
shardIndex: [ 1, 2 ]
shardTotal: [ 2 ]
name: Run e2e tests on Node ${{ matrix.node-version }}
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
Expand All @@ -55,12 +56,59 @@ jobs:
run: yarn install --frozen-lockfile
- 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: yarn test:e2e --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
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: Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile
- 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
Loading

0 comments on commit 3380f7d

Please sign in to comment.