TL-M0-19 · CI end-to-end job
Why: FE pack E's Playwright specs prove what a person sees: each role signs in, lands on its page and gets the menu its v1 role had, and an access change signs a user out on the next request (D19, D37). Until now they run only on a Mac. This step adds an e2e job to CI that runs them on every pull request touching apps/web or the database side, and on every push to main.
The job starts the real local Supabase stack the way the database job does (TL-M0-18), makes the E2E logins, builds apps/web and runs the specs against the built app. It needs no repository secret: the local stack's keys and the logins exist only inside the job. After it has run green once, the ruleset requires it, and Vercel waits for it before a production deployment goes live.
ID TL-M0-19 · Level L0 · Run order row 30 · Issue #20
CI has four jobs: checks, changes, database and e2e. The e2e job runs on pull requests that touch apps/web, supabase, tools/db, packages/db-types, ci.yml, the root package.json or the lockfile, and on every push to main, and it passes. A pull request that touches only docs pages shows e2e as skipped. A failing spec fails the job and attaches Playwright's report. The ruleset on main requires checks, pr-title, database and e2e, and Vercel's Deployment Checks wait for checks and e2e. Since #732, the push to main skips the database and e2e jobs: the pull request into main has already run them.
Before
Section titled “Before”- Row 29, FE pack E (#19), is Done: the specs are in apps/web/e2e, and
pnpm --filter web e2epasses on your Mac against the local stack. - The job uses the names FE pack E gives: the script
e2ein apps/web/package.json, a Playwright config that starts the built app itself, and the report in apps/web/playwright-report. If pack E named any of them differently, stop and ask a CTO session to correct block 2 first. - Row 23, TL-M0-18, is Done: the database job runs and is required.
- You are on main in ~/opleet-v2/opleet, up to date, and
git status --shortprints nothing. Docker Desktop is running.
1 · Run the job's commands on your Mac first
Section titled “1 · Run the job's commands on your Mac first”The same commands the job runs, on a stack started from empty. If a spec fails here, it will fail in CI too, and this block shows why before you push anything. stop --no-backup deletes the local database. It holds only the seed and the E2E logins, which block 1 makes again.
git switch main && git pullpnpm supabase stop --no-backuppnpm supabase startpnpm db:e2e-userseval "$(pnpm supabase status -o env)"printf 'NEXT_PUBLIC_SUPABASE_URL=%s\nNEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=%s\n' "$API_URL" "$PUBLISHABLE_KEY" > apps/web/.env.localpnpm --filter web buildpnpm --filter web exec playwright install chromiumpnpm --filter web e2e2 · A branch with the e2e job
Section titled “2 · A branch with the e2e job”This replaces .github/workflows/ci.yml as a whole. The checks and database jobs are unchanged. The changes job now answers two questions, and e2e is new.
git switch -c ci/e2ecat > .github/workflows/ci.yml <<'EOF'name: CI
on: pull_request: push: branches: [main]
concurrency: group: ci-${{ github.ref }} cancel-in-progress: true
env: NEXT_TELEMETRY_DISABLED: 1 ASTRO_TELEMETRY_DISABLED: 1 TURBO_TELEMETRY_DISABLED: 1
jobs: checks: name: checks runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 with: fetch-depth: 0 - uses: pnpm/action-setup@v6 - uses: actions/setup-node@v7 with: node-version-file: .node-version cache: pnpm - run: pnpm install --frozen-lockfile - run: pnpm biome ci . - run: pnpm docs:rules - run: pnpm turbo run typecheck build ${{ github.event_name == 'pull_request' && '--affected' || '' }}
# Decides whether the database and e2e jobs run: a path filter, not Turborepo's affected # graph, because supabase/ is not a package (D12). The filter lives in a job rather than in # on.paths, so both checks always report: skipped counts as passing in the ruleset. changes: name: changes runs-on: ubuntu-latest outputs: database: ${{ steps.filter.outputs.database }} e2e: ${{ steps.filter.outputs.e2e }} steps: - uses: actions/checkout@v7 with: fetch-depth: 0 - id: filter name: Did this change touch the database side or apps/web? env: EVENT: ${{ github.event_name }} BASE: ${{ github.event.pull_request.base.sha }} HEAD: ${{ github.event.pull_request.head.sha }} run: | if [ "$EVENT" != "pull_request" ]; then echo "database=true" >> "$GITHUB_OUTPUT" echo "e2e=true" >> "$GITHUB_OUTPUT" exit 0 fi changed=$(git diff --name-only "$BASE...$HEAD") database='^(supabase/|tools/db/|packages/db-types/|apps/docs/src/content/docs/reference/|\.github/workflows/ci\.yml$|package\.json$|pnpm-lock\.yaml$)' e2e='^(apps/web/|supabase/|tools/db/|packages/db-types/|\.github/workflows/ci\.yml$|package\.json$|pnpm-lock\.yaml$)' if echo "$changed" | grep -Eq "$database"; then echo "database=true" >> "$GITHUB_OUTPUT" else echo "database=false" >> "$GITHUB_OUTPUT" fi if echo "$changed" | grep -Eq "$e2e"; then echo "e2e=true" >> "$GITHUB_OUTPUT" else echo "e2e=false" >> "$GITHUB_OUTPUT" fi
database: name: database needs: changes if: needs.changes.outputs.database == 'true' runs-on: ubuntu-latest timeout-minutes: 25 steps: - uses: actions/checkout@v7 - uses: pnpm/action-setup@v6 - uses: actions/setup-node@v7 with: node-version-file: .node-version cache: pnpm - run: pnpm install --frozen-lockfile - name: A signing key for this run only (D13) run: pnpm db:signing-key # A fresh runner starts the stack from an empty database, applying every migration and # the seed, so a separate db reset would build the same database a second time. The # rebuild from empty is proved in the M0 exit check (TL-M0-24). - name: Start the local stack (D12) run: pnpm supabase start -x studio,imgproxy,mailpit,edge-runtime,logflare,vector,supavisor,realtime - name: pgTAP (D19) run: pnpm supabase test db - name: Regenerate the types and the reference pages run: | pnpm db:types pnpm docs:reference - name: The generated files match the schema (D12, D27, D33) run: | generated="packages/db-types apps/docs/src/content/docs/reference" if [ -n "$(git status --porcelain -- $generated)" ]; then git status --short -- $generated git --no-pager diff --stat -- $generated echo "::error::Generated files are out of date. Run pnpm db:types and pnpm docs:reference with the stack up, and commit what they change (D33)." exit 1 fi echo "Types and reference pages are current." - if: always() run: pnpm supabase stop --no-backup
# The Playwright specs against the real local stack, with the E2E logins (D19, TL-M0-19). # No repository secret: the stack's keys and the logins exist only inside this job. e2e: name: e2e needs: changes if: needs.changes.outputs.e2e == 'true' runs-on: ubuntu-latest timeout-minutes: 30 steps: - uses: actions/checkout@v7 - uses: pnpm/action-setup@v6 - uses: actions/setup-node@v7 with: node-version-file: .node-version cache: pnpm - run: pnpm install --frozen-lockfile - name: A signing key for this run only (D13) run: pnpm db:signing-key - name: Start the local stack, with every migration and the seed (D12) run: pnpm supabase start -x studio,imgproxy,mailpit,edge-runtime,logflare,vector,supavisor,realtime - name: The E2E logins, into .env.e2e (BE-M0-25, FE-R6) run: pnpm db:e2e-users - name: apps/web's local values (FE-M0-06) run: | eval "$(pnpm supabase status -o env)" printf 'NEXT_PUBLIC_SUPABASE_URL=%s\nNEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=%s\n' "$API_URL" "$PUBLISHABLE_KEY" > apps/web/.env.local - name: Build apps/web run: pnpm --filter web build # The browser download is cached by Playwright's version. A hit skips the download but # still installs the system packages the browser needs. - id: playwright run: echo "version=$(pnpm --filter web exec playwright --version | cut -d' ' -f2)" >> "$GITHUB_OUTPUT" - uses: actions/cache@v5 with: path: ~/.cache/ms-playwright key: playwright-${{ runner.os }}-${{ steps.playwright.outputs.version }} - name: Chromium for Playwright run: pnpm --filter web exec playwright install --with-deps chromium - name: Playwright (D19) run: pnpm --filter web e2e - if: failure() uses: actions/upload-artifact@v7 with: name: playwright-report path: apps/web/playwright-report retention-days: 7 - if: always() run: pnpm supabase stop --no-backupEOFgit add .github/workflows/ci.ymlgit commit -m "ci: run the playwright specs in an e2e job (d19)"3 · Push, open the pull request, and watch the checks
Section titled “3 · Push, open the pull request, and watch the checks”The pull request changes ci.yml, which is on both path filters, so database and e2e both run. The first e2e run downloads Chromium and its system libraries, which adds a few minutes.
git push -u origin ci/e2egh pr create --fillgh pr checks --watch4 · See the job catch a failing spec, then undo it
Section titled “4 · See the job catch a failing spec, then undo it”The canary's title cites no rule ID, so pnpm docs:rules ignores it.
cat > apps/web/e2e/tl-m0-19-canary.spec.ts <<'EOF'import { expect, test } from "@playwright/test";
test("TL-M0-19 canary: a failing spec fails the e2e job", () => { expect(1).toBe(2);});EOFgit add apps/web/e2e/tl-m0-19-canary.spec.tsgit commit -m "test: a failing spec the e2e job must catch"git pushsleep 15 && gh pr checks --watchgit revert --no-edit HEADgit pushsleep 15 && gh pr checks --watch5 · Squash-merge and update main
Section titled “5 · Squash-merge and update main”gh pr merge --squash --delete-branchgit switch maingit pull6 · Make the e2e job required on main
Section titled “6 · Make the e2e job required on main”The job must have run once before the ruleset can require it. A pull request that skips the job still passes, because GitHub counts a skipped job as passing.
id=$(gh api repos/Opleettop/monorepo/rulesets --jq '.[] | select(.name == "main") | .id')gh api repos/Opleettop/monorepo/rulesets/$id \ --jq '{rules: [.rules[] | if .type == "required_status_checks" then .parameters.required_status_checks += [{"context": "e2e"}] else . end]}' \ | gh api -X PUT repos/Opleettop/monorepo/rulesets/$id --input - \ --jq '.rules[] | select(.type == "required_status_checks") | .parameters.required_status_checks | map(.context)'7 · Vercel waits for e2e too
Section titled “7 · Vercel waits for e2e too”In Vercel: the project from TL-M0-21 › Settings › Build and Deployment › Deployment Checks › Add Checks. Choose GitHub, search for e2e, select the check named exactly e2e, and save. A push to main always runs e2e, so a merge that breaks sign-in or a menu never reaches the production address. Since #732, the push to main skips the database and e2e jobs: the pull request into main has already run them. Each production deployment then goes live about ten minutes after its merge.
Expect
Section titled “Expect”- Block 1:
supabase startends with the local URLs and keys.db:e2e-userssays it made or updated 11 logins. The build ends without errors. Playwright ends with "passed" for every spec and no "failed" line. - Block 2: Lefthook shows ✔️ biome and ✔️ commitlint, then one file changed.
- Block 3: checks, changes, database, e2e and pr-title all pass. In the e2e log, "Playwright (D19)" ends with the same number of passed specs as block 1.
- Block 4:
- After the first push, e2e fails, with "TL-M0-19 canary" listed as failed, and the run's summary page lists an artifact named playwright-report.
- After the revert, e2e passes again.
- checks passes both times.
- Block 5: "✓ Squashed and merged pull request".
- Block 6:
["checks", "pr-title", "database", "e2e"]. - Block 7: Deployment Checks lists two GitHub checks, checks and e2e.
gh run list --workflow CI --branch main --limit 1gh run view "$(gh run list --workflow CI --branch main --limit 1 --json databaseId --jq '.[0].databaseId')" --json jobs --jq '.jobs[] | "\(.name) \(.conclusion)"'gh api repos/Opleettop/monorepo/rules/branches/main \ --jq '.[] | select(.type == "required_status_checks") | .parameters.required_status_checks | map(.context)'- The run on main after the merge shows completed and success, and its jobs list checks, changes, database and e2e, each with success.
- The required checks are checks, pr-title, database and e2e.
On the next pull request that touches only apps/docs pages, e2e and database show as skipped and the pull request can still merge. On the next merge to main, Vercel's new production deployment shows its Deployment Checks pending until e2e passes. Log both on #20 when they happen.
If it fails
Section titled “If it fails”- Block 1 fails in a spec: don't start this step. Paste the failing spec's name and its error into #19. The Frontend Engineer fixes it in a pull request first.
- The e2e job fails in "Start the local stack": paste the step's log (
gh run view --log-failed). A pull limit or a registry error usually clears on a re-run:gh run rerun --failed. - The e2e job fails in "The E2E logins": the script refuses any URL that isn't the local stack. Paste the step's log into #20. It means
supabase statusreported something unexpected, so don't work around it. - The e2e job fails in "Playwright (D19)" but block 1 passed: download the report (
gh run download --name playwright-report) and open its index.html. A timeout on the first page usually means the app didn't start: check the "Build apps/web" step's log. Paste the failing spec and its error into #20, and don't merge. playwright install --with-depsfails: the runner image's packages changed. A re-run usually clears it. If it fails twice, paste the log into #20.- Block 4's failing run has no playwright-report artifact: pack E's config writes its report elsewhere. Note the path on #20, and a CTO session corrects the upload step.
- Block 6 prints a list without e2e: the PUT didn't apply. Run block 6 again, then the Check.
- The required check: run block 6 with
-= [{"context": "e2e"}]in place of+= [{"context": "e2e"}]. - Vercel: remove e2e under Deployment Checks.
- The job: revert the merge commit in a pull request:
git revert <MERGE_COMMIT>on a branch, then push and open it. Undo the required check first, or the revert's pull request can't merge without it.
Log each run as a comment on #20: the date, the pull request number, how long the e2e job took, the number of specs that passed, and block 6's output.