## Problem Since #54339, the docs alert in `docs-master-alert.yml` names only the workflow, the run type, and the run link. That stopped it from blaming whoever merged last, but nothing says which change broke things. A failure needs to trace back to the commit that introduced it, for push, scheduled, and manual runs alike. Nobody needs to be pinged. ## Solution Each docs workflow that runs on `master` keeps a list of open failures. The alert posts to Slack only when a failure is added or fixed. Each new failure names the commit that introduced it, or lists the possible commits as unconfirmed. It never names the latest commit by default. - **What counts as a failure.** - Accessibility scan: a page and axe rule pair, from a new Playwright reporter (`e2e/docs/utils/a11y-failures-reporter.ts`). A guide that returns a status of 400 or higher fails as `<page>: http-<status>`. - Production smoke tests: one Vitest test, keyed as `<file> › <test>`, from Vitest's JSON reporter. A run where no test passed and some timed out counts as one failure, `every test timed out`. - Every other workflow: a failed job or step, from the Actions API. - Both test workflows upload their results as a `docs-failures-<attempt>` artifact for the alert to read, so a re-run never picks up an earlier attempt's results. - A Vitest file that fails to load, such as an import error, counts as one failure for that file, and its tests keep their earlier results. - **Which commit.** - Accessibility scan: the commits deployed to production since the last run, narrowed to the ones that touched the failing page's MDX file or a partial it includes. - Smoke tests: the deployed commits, not narrowed further. - Push runs: the run's own commit, plus the commits of every earlier run since the baseline whose alert didn't run, such as one that was cancelled or dropped. A run among them that passed still counts, since it may have skipped the failing step. - Other scheduled or manual runs: the commits since the last run without that failure. - One commit left is named. Several, or none on the failing page, are listed as unconfirmed. - **Deployed commits.** One GraphQL query reads the `Vercel – docs` status on recent `master` commits. A commit counts as deployed once its build finished before the run ended, so the range includes a commit that deploys partway through a scan. Builds Vercel skipped as not affected count too, because they leave the docs unchanged. The `Production – docs` GitHub deployments stopped updating, so they can't be used. No new secrets. - **Flaky results.** A page or smoke test that times out keeps its earlier result, so it doesn't count as a new failure or a fix. The same goes for a page whose scan is missing, empty, or skipped, for a skipped smoke test, and for a job or step that neither passed nor failed, such as one skipped after a failed step, cancelled, or with no conclusion. A job that timed out counts as failed. A step keeps its result when its whole job was skipped or failed without listing its steps, or when a passing run's condition skipped it. A guide that returns an error status keeps its earlier axe failures until a scan runs, and a new status replaces the earlier one. A step skipped in one run and then under a skipped job in the next keeps the baseline from the run that last ran it. When one of these later fails, its range starts at the last run that actually checked it. If no run has checked it since tracking started, the alert names no commit. - **Saving the list.** The list is saved as a run artifact for each workflow, kept for 90 days. The next alert downloads it. A failure that's still open keeps the commit from when it first failed. The alert only accepts a saved list from a `master` run in this repo, and ignores one without the expected shape and version. - **Pure logic and orchestration.** `e2e/docs/utils/open-failures.ts` holds the logic and the Slack message, with unit tests. `e2e/docs/scripts/docs-alert.ts` handles the API calls and posting. `pageSourceFiles` in `resolve-docs-scope.ts` lists a guide's MDX file and every partial it includes. `failure-sequences.test.ts` runs every sequence of four runs, for a job's steps, a smoke test file's tests, and a guide's status and scan, plus sequences that start with no saved list. It checks the open list and each new failure's baseline against a model of what each run observed. The axe rules and result checks the reporter needs moved to `utils/axe-rules.ts`, so the unit tests still run before CI installs packages. ### Behavior changes to review 1. **The alert also runs on passing runs.** It needs them to clear fixed failures, and it posts only when the list changes. A workflow that keeps failing no longer posts on every run. 2. **Smoke tests aren't narrowed to a page.** They test API routes, not guides, so the alert lists every deployed commit since the last passing run. 3. **First run.** With no saved list, the alert compares against the previous run if that run passed. The jobs and steps that run skipped count as never checked. Otherwise, current failures show as "already failing when tracking started", with no commit. 4. **Fewer workflows trigger the alert.** Docs Navigation Checks, Docs removed anchors, and Docs Tests run only on `pull_request`, so they never matched `branches: [master]`. They're removed from the trigger list. 5. **Runs from forks are ignored.** The `branches: [master]` filter also matches a fork branch named `master`, and the alert now reads artifacts from the run that triggered it. For the same reason, a saved list that a fork or another branch uploaded is never used. 6. **Missing results.** If the scan or smoke tests have no readable results, the list stays as it was. A scan whose spec fails to load and a smoke run with no test files count as no results too. When the run failed, the alert posts a plain "failed before it reported any results" message. ## Limitations - With no saved list, the scan and smoke tests count everything the previous passing run skipped as checked, because the alert doesn't read that run's results. - Failures are matched by name, so a renamed job, step, or test, or a moved smoke test file, looks like one fixed failure and one new failure. - An incoming webhook can't edit an earlier message, so each change to the list is a new post. - The compare API returns at most 250 commits per page, oldest first. A longer range fetches its last two pages, so the alert lists the newest commits and the full count. - GitHub keeps only one pending run per concurrency group. If three runs of the same workflow finish at once, the middle alert is dropped, and the next one covers its commits. ## Review instructions 1. Run `pnpm -C e2e/docs test` and confirm all 55 tests pass. 2. Run the scan with the new reporter on a real guide and one that doesn't exist: ```bash cd e2e/docs && CI=1 DOCS_A11Y_FAILURES_FILE=/tmp/a11y.json PLAYWRIGHT_BASE_URL=https://supabase.com \ DOCS_E2E_PAGE_PATHS=/docs/guides/resources,/docs/guides/not-a-real-guide pnpm exec playwright test --grep @a11y cat /tmp/a11y.json ``` Expect one failure, `/docs/guides/not-a-real-guide: http-404`, with that guide also listed as unchecked, so its axe rules keep their earlier results. 3. Dry-run the alert against a real smoke test run, with a fake failure. `DRY_RUN` prints the Slack payload instead of posting it: ```bash mkdir -p /tmp/alert/results gh api repos/supabase/supabase/actions/runs/46574787371 \ | jq '{workflow_run: (. + {conclusion: "failure", path: ".github/workflows/docs-a11y-scan.yml", name: "Docs Accessibility Scan"})}' > /tmp/alert/event.json echo '{"failures":[{"key":"/docs/guides/database/custom-postgres-config: heading-order","page":"/docs/guides/database/custom-postgres-config"}],"unchecked":[]}' > /tmp/alert/results/a11y-failures.json GITHUB_TOKEN=$(gh auth token) GITHUB_REPOSITORY=supabase/supabase DRY_RUN=1 \ GITHUB_EVENT_PATH=/tmp/alert/event.json STATE_OUT=/tmp/alert/state.json RESULTS_DIR=/tmp/alert/results \ node e2e/docs/scripts/docs-alert.ts ``` Expect the failure to be `introduced by 450939c`, the only deployed commit in that range that touched the page. 4. Run step 3 again with `STATE_IN=/tmp/alert/state.json` and no other change. Expect no output, because the list didn't change. Verified locally: - Unit tests, typecheck, oxfmt, and actionlint on the changed workflows. The unit tests also pass in a copy of the repo with no installed packages, as CI runs them. - Mutation probes on the rules for unchecked pages, the push range, the unchecked baseline, Vitest files that fail to load, the saved-list check, deploy narrowing, skipped steps, smoke runs where every test timed out, the compare total, guides that return an error status, a guide whose error status changes, steps under a skipped job, and step baselines across skipped jobs. The sequence test alone catches all 14 unchecked-state bugs found in review when each is put back. - The reporter against production, including a guide that returns 404. - Dry runs against real runs: both workflows that test production, a failed push run, and a failed scheduled run. These covered a step whose range starts at the last run that ran it, a compare range of 400 commits, a new failure, a second failure added while the first stayed open, an unchanged list, every failure fixed, a crash before results, missing results, an older run, a saved list in the wrong shape, a passing run whose condition skipped a step with a saved failure, a push range that spans three pages of runs, and a first run with no saved list after a run that skipped a step. - The saved-list filter on real artifact data. Not run live: - The push and scheduled paths for the other workflows, because none had a recent failed run to test against. - The alert workflow itself. A `workflow_run` workflow only runs from `master`, so the first real alert comes after merge. Resolves [DOCS-1831](https://linear.app/supabase/issue/DOCS-1831/trace-docs-workflow-failures-to-the-commits-that-introduced-them) ## Checklist - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
11 KiB
Docs E2E tests
This guide explains how to run Playwright end-to-end checks against docs pages this repo owns.
Use this suite when you change guides or shared
partials under apps/docs/content. It loads each in-scope page, checks that the
article renders, and verifies that docs-owned links in the article resolve. For
links with an anchor, it also checks that the target page's article has an element
with that id or an a[name] with that value, including same-page #anchor
links.
This page covers:
- Set up — install the browser once
- Run the tests — the usual local command
- Choose a target URL — production, preview, or local docs
- Override which pages run — when the default git scope is wrong
- What the suite covers — in-scope paths and limits
- Accessibility scans — WCAG coverage and skipped rules
- Debug failures — reports and traces
- How CI uses this suite — pull request behavior
- Failure alerts — Slack alerts for docs workflows on
master
Set up
-
From this directory, install the Playwright Chromium browser once:
cd e2e/docs pnpm exec playwright install chromium
Run the tests
By default, pnpm e2e:docs tests pages affected by your current changes:
commits since origin/master, plus staged and unstaged working-tree files. If
nothing in scope changed, the command exits successfully without starting
Playwright.
-
From the repository root, point the suite at a deployed docs site and run it:
PLAYWRIGHT_BASE_URL=https://supabase.com pnpm e2e:docs -
Optional: open Playwright UI mode for the same scoped run:
PLAYWRIGHT_BASE_URL=https://supabase.com pnpm e2e:docs:ui
You can also run from e2e/docs with pnpm run e2e:docs.
Choose a target URL
Tests use PLAYWRIGHT_BASE_URL. When unset, they default to the local docs
dev server at http://localhost:3001.
Prefer a deployed site for day-to-day checks. Use the local server only when you need unpublished content that production does not serve yet.
Deployed site
PLAYWRIGHT_BASE_URL=https://supabase.com pnpm e2e:docs
For a protected Vercel preview, also set VERCEL_AUTOMATION_BYPASS_SECRET.
Local docs server
-
From the repository root, start docs in a separate terminal:
pnpm dev:docs -
Run the suite without
PLAYWRIGHT_BASE_URL, or set it tohttp://localhost:3001.
The local server needs a full monorepo install and credentials for some content.
Local runs are unreliable for pages whose docs-owned links point into
/docs/reference/* or /docs/guides/auth/server-side/*: reference pages can
take over a minute to compile on first request in dev mode, which exceeds the
suite's per-test timeout, and server-side auth guides have a known local-only
routing issue that 404s even though the page serves correctly in production.
Prefer a deployed site for pages that link into either of those sections.
Override which pages run
Leave DOCS_E2E_PAGE_PATHS unset to keep the default changed-files scope.
To test specific pages instead of the git diff:
DOCS_E2E_PAGE_PATHS=/docs/guides/getting-started/quickstarts/nextjs \
PLAYWRIGHT_BASE_URL=https://supabase.com pnpm e2e:docs
To compare against a different base ref:
DOCS_E2E_BASE_REF=origin/develop \
PLAYWRIGHT_BASE_URL=https://supabase.com pnpm e2e:docs
DOCS_E2E_PAGE_PATHS accepts a comma- or newline-separated list of /docs/...
paths.
Run every in-scope page
To test every guide instead of a changed-files scope — for example, a periodic full-site check — run:
PLAYWRIGHT_BASE_URL=https://supabase.com pnpm e2e:docs:all
This ignores DOCS_E2E_PAGE_PATHS and tests every page listed by
pnpm -C e2e/docs resolve-docs-scope across the whole guides
tree — several hundred pages as of this writing. Expect a long run. A list that
long runs on three workers, and --workers overrides that.
Run this against a deployed site, not the local dev server — see Local docs server for why local runs are unreliable for pages linking into reference docs or server-side auth guides.
What the suite covers
In scope
| Changed path | Behavior |
|---|---|
apps/docs/content/guides/**/*.mdx |
Test /docs/guides/<slug>, excluding federated sections |
apps/docs/content/_partials/** |
Test owned pages that include that partial |
Out of scope
- Federated guide sections:
graphql,database/extensions/wrappers,ai/python,deployment/terraform,deployment/ci - Reference docs under
/docs/reference - Non-docs routes such as
/dashboardand/ui, which the link checker skips - Guides that the nav disables, listed in
NAV_DISABLED_PAGESinutils/resolve-docs-scope.ts, because their HTML page returns 404 - Guides that
apps/docs/lib/redirects/static-redirects.jsonredirects elsewhere, because they have no docs article to test - Guides with no MDX file, such as the CLI and self-hosting config pages that the docs app builds from config files, because the suite only resolves MDX guides. This is a known limitation.
Limits
The suite tests every in-scope page, with no cap, and doesn't stop early on failures, so a run reports every page with a broken link. Past 20 pages it runs on three workers instead of one.
To inspect the resolved list without running Playwright, replicate the same
scope pnpm e2e:docs uses by default: commits since origin/master, plus
staged and unstaged working-tree changes.
{
git diff --name-only --diff-filter=ACMR origin/master...HEAD
git diff --name-only --diff-filter=ACMR
git diff --name-only --diff-filter=ACMR --cached
} | pnpm -C e2e/docs resolve-docs-scope
Accessibility scans
The @a11y-tagged test scans each in-scope page with @axe-core/playwright. It
reports WCAG 2.1 A/AA violations in the main article, and fails on the rules in
ENFORCED_RULES in utils/axe-rules.ts, which it checks across the whole page.
The scans are slow, so Docs E2E runs skip them. Instead, the Docs Accessibility
Scan workflow (.github/workflows/docs-a11y-scan.yml) scans every MDX guide on
production daily at 05:17 UTC. To start it by hand, run
gh workflow run docs-a11y-scan.yml.
When the daily scan finds a new failure or a fix, it posts to the docs alerts channel in Slack. See Failure alerts.
To run the scan locally:
PLAYWRIGHT_BASE_URL=https://supabase.com pnpm e2e:docs:a11y
Which pages get scanned comes from your branch, but the content comes from
whatever you point PLAYWRIGHT_BASE_URL at. Production won't have your edits and
will 404 on a page you just added, so use your pull request's preview to scan your
own content.
EXCLUDED_RULES in utils/axe-rules.ts lists the rules the scan skips.
color-contrast is most of the scan time and finds nothing inside an article, since
docs contrast comes from shared tokens and chrome. The rest target <html>, <head>,
and <body>, which an article-scoped scan can't reach.
Cross-origin frames are skipped, so a third-party embed isn't reported as ours.
Not covered: /docs/reference/*, shared chrome, and most of WCAG. Keyboard
navigation, focus management, and screen reader behavior need manual testing.
Debug failures
-
Open the HTML report after a run:
pnpm -C e2e/docs exec playwright show-report -
Inspect traces and screenshots under
test-results/for failed runs.
How CI uses this suite
The workflow at .github/workflows/docs-e2e.yml runs on pull requests that touch
owned docs content, partials, or e2e/docs.
- When
e2e/docsore2e/sharedchanged, run the harness unit tests (pnpm -C e2e/docs test). - Diff the pull request against its base branch and resolve in-scope page paths.
- Skip Playwright when nothing in scope changed.
- When
apps/docschanged, wait for the Vercel docs preview and setPLAYWRIGHT_BASE_URLto that preview. If Vercel skipped the head commit's build as not affected, the newest ready preview from an earlier commit of the pull request is used instead. When no preview resolves, skip rather than test against production. - Run the suite with
DOCS_E2E_PAGE_PATHSset to the resolved list, without the@a11yaccessibility scans.
Draft pull requests stay skipped until you mark them ready for review. Manual
workflow_dispatch runs require a page_paths input and accept an optional
base_url, which defaults to production.
Failure alerts
.github/workflows/docs-master-alert.yml keeps a list of open failures for each
of the following workflows when they run on master:
- Docs Accessibility Scan, with one failure per page and axe rule
- Docs Production Smoke Tests, with one failure per test
- Docs E2E Tests, which runs on
masteronly when started by hand - [Docs] Update last-changed dates
- Update JS Client Libraries Docs
- Update Mgmt Api Docs
- docs_sync
- Ingest Docs Content for Search V2
For the workflows without their own results, each failed job or step is one failure.
| When | The alert |
|---|---|
| A failure is added | Posts it with the commit that introduced it, or the possible commits |
| A failure is fixed | Posts the fix |
| The list doesn't change | Posts nothing |
| A page or test times out, a page doesn't render, or a job or step is skipped | Keeps its earlier result |
| A page returns an error status, such as 404 | Counts a failure for that status in place of any earlier one, and keeps the page's earlier scan results |
| No smoke test passes and some time out | Counts one failure for the run |
| A run fails before it reports results | Posts that the run failed, and keeps the list as it was |
For the scan, a new failure names the deployed commit that touched the page or a partial it includes. When no single commit did, the alert lists the possible commits as unconfirmed.