Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
⚡️ Shard integration tests across four CI jobs
Luke Vellac9b150a66482
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex a531fa58d..7ec776439 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -140,10 +140,48 @@ jobs:echo "version=$version" >> "$GITHUB_OUTPUT"echo "Resolved Playwright version: $version"- integration-tests:- name: Integration tests+ # Builds once so each shard only installs and starts the server.+ integration-build:+ name: Integration buildruns-on: ubuntu-latestneeds: playwright-version+ # Same image as the shards, so the absolute paths baked into .next match.+ container:+ image: mcr.microsoft.com/playwright:v${{ needs.playwright-version.outputs.version }}-noble+ env:+ DATABASE_URL: postgresql://postgres:postgres@postgres:5432/rallly+ DIRECT_DATABASE_URL: postgresql://postgres:postgres@postgres:5432/rallly+ CI: true+ steps:+ - uses: actions/checkout@v4+ - uses: ./.github/actions/setup-node+ - uses: ./.github/actions/pnpm-install++ - name: Generate Prisma Client+ run: pnpm db:generate++ - name: Create production build+ run: pnpm turbo build:test --filter=@rallly/web++ # A tarball keeps the hidden .next directory (upload-artifact skips+ # hidden paths) and uploads as one file instead of thousands.+ - name: Pack build+ run: tar --exclude=apps/web/.next/cache -cf next-build.tar apps/web/.next++ - uses: actions/upload-artifact@v4+ with:+ name: next-build+ path: next-build.tar+ retention-days: 1++ integration-shard:+ name: Integration tests (${{ matrix.shard }}/4)+ runs-on: ubuntu-latest+ needs: [playwright-version, integration-build]+ strategy:+ fail-fast: false+ matrix:+ shard: [1, 2, 3, 4]# Uses the Playwright image (browsers preinstalled); tag must stay v<version>-noble.container:image: mcr.microsoft.com/playwright:v${{ needs.playwright-version.outputs.version }}-noble@@ -157,6 +195,8 @@ jobs:# Point Playwright at the image's preinstalled browsers (HOME is /github/home in-container).PLAYWRIGHT_BROWSERS_PATH: /ms-playwrightCI: true+ # Each shard gets its own database and mailbox, so the suite's+ # single-tenant assumptions hold within a shard.services:postgres:image: postgres:18-alpine@@ -183,19 +223,55 @@ jobs:- name: Generate Prisma Clientrun: pnpm db:generate- - name: Create production build- run: pnpm turbo build:test --filter=@rallly/web+ - uses: actions/download-artifact@v4+ with:+ name: next-build++ - name: Unpack build+ run: tar -xf next-build.tar && rm next-build.tar- name: Setup databaserun: pnpm db:deploy- name: Run tests# Run directly, not via turbo, so the job env reaches the test process.- run: pnpm --filter @rallly/web test:integration+ run: pnpm --filter @rallly/web test:integration --shard=${{ matrix.shard }}/4++ - name: Upload blob report+ if: ${{ !cancelled() }}+ uses: actions/upload-artifact@v4+ with:+ name: blob-report-${{ matrix.shard }}+ path: ./apps/web/blob-report+ retention-days: 1++ # Keeps the required "Integration tests" check: it passes only when every+ # shard passed, and merges the shard reports into one HTML report.+ integration-tests:+ name: Integration tests+ runs-on: ubuntu-latest+ needs: [playwright-version, integration-shard]+ if: ${{ !cancelled() }}+ container:+ image: mcr.microsoft.com/playwright:v${{ needs.playwright-version.outputs.version }}-noble+ steps:+ - uses: actions/download-artifact@v4+ with:+ path: all-blob-reports+ pattern: blob-report-*+ merge-multiple: true++ - name: Merge reports+ if: ${{ hashFiles('all-blob-reports/*') != '' }}+ run: npx --yes playwright@${{ needs.playwright-version.outputs.version }} merge-reports --reporter html ./all-blob-reports- name: Upload artifact playwright-report- if: ${{ success() || failure() }}+ if: ${{ hashFiles('playwright-report/*') != '' }}uses: actions/upload-artifact@v4with:name: playwright-report- path: ./apps/web/playwright-report+ path: playwright-report++ - name: Fail unless every shard passed+ if: ${{ needs.integration-shard.result != 'success' }}+ run: exit 1diff --git a/apps/web/.gitignore b/apps/web/.gitignoreindex c2b89819e..8d6301b14 100644--- a/apps/web/.gitignore+++ b/apps/web/.gitignore@@ -5,6 +5,7 @@ node_modules# playwright/playwright-report+/blob-report/test-results# Sentry Config File.env.sentry-build-plugindiff --git a/apps/web/playwright.config.ts b/apps/web/playwright.config.tsindex e0afec133..318e6a80d 100644--- a/apps/web/playwright.config.ts+++ b/apps/web/playwright.config.ts@@ -49,9 +49,10 @@ export default defineConfig({__NEXT_PROCESSED_ENV: "true",},},- reporter: [- [ci ? "github" : "list"],- ["html", { open: !ci ? "on-failure" : "never" }],- ],+ // CI runs sharded; the integration-tests job merges the blob reports+ // into one HTML report.+ reporter: ci+ ? [["github"], ["blob"]]+ : [["list"], ["html", { open: "on-failure" }]],workers: 1,});