mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
create-pull-request/patch
4
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
b66682ee07 |
ci(docs): scan only the guides production serves in the daily accessibility scan (#54499)
## Problem The daily Docs Accessibility Scan builds its page list from `apps/docs/content/guides` on `master`, then loads each page from production. When production runs behind `master`, every guide merged since the last production deploy returns 404 and fails the scan, even though the guide is fine. On 2026-12-02, the scan failed on 8 guides this way. A deployment freeze had moved docs production to a temporary `release` branch, so guides merged to `master` that day weren't deployed. The same thing can happen outside a freeze, when a guide merges minutes before the scan runs. ## Solution The scan now tests only the guides production serves. It keeps the guides from the repo list that also appear in the production sitemap, `https://supabase.com/docs/sitemap.xml`. - **Why the sitemap.** The docs build generates `sitemap.xml` from `content/guides` on every production deploy, leaving out guides the nav turns off. It isn't cached between builds, so it always lists what production serves. It needs no new credentials. Today it lists every one of the 609 guides the scan tests, plus the federated sections the scan already skips. - **How it's wired.** `run-e2e-docs.ts --all` filters the list when `DOCS_E2E_DEPLOYED_ONLY` is set, using the `/docs/sitemap.xml` of the site in `PLAYWRIGHT_BASE_URL`, so the page list and the scanned site can't come from different sites. `docs-a11y-scan.yml` sets it. Runs without the variable behave as before. The filter lives in `e2e/docs/utils/production-pages.ts`, with unit tests. - **Skipped guides are listed.** Each guide missing from the sitemap prints "Skipping `<page>`: not in `<sitemap URL>`." in the run log, and shows as a warning on the run page even when the scan passes. It's scanned on the first run after its deploy. - **Skipped guides keep their earlier results in the alert.** The runner passes the skipped guides to the a11y failures reporter from #54444, which lists each one as unchecked. A guide with an open failure that drops out of the sitemap keeps that failure open, instead of posting as fixed and then as new when it returns. - **A real 404 still fails.** A live guide that starts returning 404 is still in the sitemap, so it's still scanned and still fails. - **A broken sitemap fails the run.** The run fails when the sitemap can't be read, lists no guides, or is missing more than a tenth of the repo's guides. A partial sitemap can't silently shrink the scan. - **Wrapped tags.** The sitemap's formatter wraps long `<loc>` tags across lines, as `<loc\n >url</loc\n>`. The parser handles that. A line-based parse misses about 10 guides. The workflow header comment and `e2e/docs/README.md` say where the page list comes from. ### Behavior changes to review 1. **A guide whose nav entry is turned off is skipped, not failed.** The docs build leaves it out of the sitemap, and production returns 404 for it. That matches production. It also means turning off a live guide's nav entry by mistake doesn't fail the scan. The guide shows as a warning on the run page instead. 2. **Interaction with the failure alert from #54444.** The alert reports a guide that returns 404 as an `http-404` failure. With this change, only a guide production should serve can produce that failure. A skipped guide keeps whatever failures it already had open, so a guide whose nav entry is turned off stays in the list until it's back or deleted. ## Limitations - A guide skipped for about two weeks or more loses its commit attribution if it fails when it returns. The alert reads only the last 500 deployed commits, so it can't tell which commit production was running when the guide was last checked, and says so. - `getting-started/features` is in the sitemap even though a static redirect sends it elsewhere. The scan already skips redirected guides, so it doesn't affect the scan. ## Review instructions 1. Run `pnpm -C e2e/docs test` and confirm all 63 tests pass. 2. List the scan's tests against the live sitemap: ```bash cd e2e/docs && CI=1 PLAYWRIGHT_BASE_URL=https://supabase.com DOCS_E2E_DEPLOYED_ONLY=1 \ pnpm run e2e:docs:all --grep @a11y --list | grep -E 'Resolved|Skipping|Total' ``` Expect every guide resolved and nothing skipped while production matches `master`. 3. Run step 2 with `PLAYWRIGHT_BASE_URL=https://example.com`, a site with no docs sitemap. Expect the run to fail with the sitemap URL and its status. 4. Add a temporary guide that isn't on production, such as `apps/docs/content/guides/zz-temp-probe.mdx`, and run step 2 with `DOCS_A11Y_FAILURES_FILE=/tmp/a11y.json`. Expect "Skipping /docs/guides/zz-temp-probe", and both `/docs/guides/zz-temp-probe` and `/docs/guides/zz-temp-probe: http` under `unchecked` in `/tmp/a11y.json`. Delete the guide afterward. Verified locally: - Unit tests, typecheck, oxfmt, and actionlint on the changed workflow. The unit tests also pass in a copy of the repo with no installed packages, as CI runs them. The only actionlint warning is the existing blacksmith runner label. - Mutation probes on the wrapped-tag parsing, the trailing-slash trim, the guides-only filter, the missing-share guard, and each of the three ways a sitemap fails the run: an error status, no guides, and a site that can't be reached. Unit tests cover all three with a local `node:http` server. - A copy of the production sitemap with the 8 guides from the 2026-12-02 run removed. The run skipped exactly those 8 and resolved the rest. - A temporary guide that's in the sitemap but returns 404 on production. The scan failed it with "Expected a successful response … got 404". - Review step 4, after rebasing onto #54444. The skipped guide reached the reporter as unchecked under its page and status keys. A mutation probe that drops the skipped guides from the reporter fails the new test. - A sitemap with no guides, and one that can't be reached. Both failed the run before Playwright started. Resolves [DOCS-1839](https://linear.app/supabase/issue/DOCS-1839/scan-only-the-pages-production-serves-in-the-daily-docs-accessibility) ## Checklist - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) |
||
|
|
cf63aa5459 |
ci(docs): trace docs workflow failures to the commits that introduced them (#54444)
## 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) |
||
|
|
a5638ed9e2 |
fix(docs): check every changed page for broken links in Docs E2E (#53899)
## Problem The Docs E2E suite tests the guide pages a PR changes, but only the first 20 in sorted order. It drops the rest without a warning, so the check passes green with pages untested. That let a broken link through in #53561. The PR changed 62 guides, `delete-project` ranked 23rd, and the suite never loaded it. The link was missing its leading slash and resolved to a nested URL that returns 404 (fixed in #53871). A check that skips pages arbitrarily can't be relied on to catch the mistake it exists to catch. ## Solution The link check now runs on every changed page, with no cap. The accessibility scan no longer runs on pull requests, because it's slow and only checks the pages a diff names. A scheduled whole-site run fits it better, and that's tracked in [DOCS-1816](https://linear.app/supabase/issue/DOCS-1816/run-the-docs-e2e-accessibility-scan-on-a-schedule-across-the-whole). The `@a11y` tests stay in the suite, and `pnpm e2e:docs:a11y` still runs them. - The resolver returns every in-scope page. The 20-page cap is gone. - The workflow runs the suite with `--grep-invert @a11y`, so CI runs skip the accessibility scans. That includes manual `workflow_dispatch` runs, which ran them before. DOCS-1816 covers when CI runs them again. - Past 20 pages the suite runs on 3 workers instead of 1, the same as the Studio suite. - The suite no longer stops after 3 failed tests, so a run reports every page with a broken link. A broken link in a shared partial can fail many pages, and stopping at 3 left the rest unchecked. - The Docs E2E job now runs the harness unit tests (`pnpm -C e2e/docs test`) when `e2e/docs` or `e2e/shared` changes. No workflow ran them before, and harness-only changes skip Playwright. ## Run time Most PRs change few pages, so the added time is small. I looked at 51 recent merged PRs that touched guides: 67% changed 1 page, 20% changed 2-5, 8% changed 7-11, and 6% (3 PRs) changed 62-82. On the Vercel preview the link test takes about 6.5s per page. Estimated run time on the preview, excluding setup and retries. Skipping the accessibility scan (about 6.4s per page) offsets the extra link checks: | Pages changed | Before (capped at 20, link check and accessibility scan, 1 worker) | This PR (every page, link check only, 3 workers past 20) | | ------------- | ------------------------------------------------------------------ | -------------------------------------------------------- | | 1 | ~13s | ~7s | | 5 | ~1.1 min | ~0.5 min | | 11 | ~2.4 min | ~1.2 min | | 82 | ~4.3 min (62 pages unchecked) | ~3 min | On production, 40 link tests took 50s on one worker and 13s on four, so workers scale close to linearly. I haven't run a large page list in the CI workflow, and the Vercel preview might throttle 3 workers at once. If it does, lower the worker count in `playwright.config.ts`. CI retries a failing test up to 2 times, so a failing page can cost 3 runs. Since the suite no longer stops after 3 failures, a change that breaks many pages pays that cost for each of them. The job times out at 30 minutes, which the link check alone would reach at roughly 800 pages on 3 workers. ## Review instructions 1. Run `pnpm -C e2e/docs test` and confirm the scope tests pass, including the 82-page case. 2. Pipe 82 changed guide paths into the scope CLI and confirm `paths` lists all 82: ```bash printf 'apps/docs/content/guides/ai/%s.mdx\n' {1..82} | pnpm -C e2e/docs resolve-docs-scope ``` 3. List the tests the workflow runs for 3 pages and confirm there are 4 (1 guard, 3 link) and none for accessibility: ```bash cd e2e/docs && PLAYWRIGHT_BASE_URL=https://supabase.com DOCS_E2E_PAGE_PATHS=/docs/guides/auth,/docs/guides/database/overview,/docs/guides/storage pnpm exec playwright test --grep-invert @a11y --list ``` 4. Run the link test on 4 pages that don't exist and confirm all 4 fail, rather than the run stopping after 3: ```bash cd e2e/docs && PLAYWRIGHT_BASE_URL=https://supabase.com DOCS_E2E_PAGE_PATHS=/docs/guides/zz-nope-1,/docs/guides/zz-nope-2,/docs/guides/zz-nope-3,/docs/guides/zz-nope-4 pnpm exec playwright test --grep "loads and" ``` 5. Check that this PR's Docs E2E job runs the "Run docs E2E harness unit tests" step and that it passes. Verified locally: unit tests, the scope CLI with 82 paths, the test list above through the same `pnpm run e2e:docs --grep-invert @a11y` command the workflow uses, and the 4-failure run. Resolves [DOCS-1749](https://linear.app/supabase/issue/DOCS-1749/warn-instead-of-silently-skipping-pages-in-docs-e2e-when-a-pr-exceeds) ## Checklist - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
9199aad57e |
feat(docs) Add scaffolding and CI/CD step for Docs Playwright (#48120)
Closes DOCS-1197 ## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES ## Problem We do not have any E2E testing established. ## Solution This PR creates an ultra-lean starting place for Docs Playwright: - A CI/CD step that skips on draft and relies on Preview for testing - One simple broken link check for one page The goal: - Playwright is implemented where we want it, with an architecture we want, with set-up steps we can build from The anti-goal of this PR: - We have meaningful tests running ## CI/CD steps <img width="1191" height="72" alt="Screenshot 2026-07-21 at 10 17 06 AM" src="https://github.com/user-attachments/assets/eeb2454c-d864-4574-a050-ce39bb3f083f" /> 1. Checkout a thin slice of the repo (`apps/docs`, `packages`, `patches`). 2. Wait for the Vercel **docs** preview for that commit SHA. 3. Use that preview URL as `PLAYWRIGHT_BASE_URL`. 4. Install Node deps and Chromium. 5. Run `pnpm run e2e:docs` (`--grep @quickstart`). 6. If anything fails, upload the HTML report + traces. Manual runs skip the Vercel wait and default to `https://supabase.com` (or whatever URL you enter), then run the full suite (`pnpm run e2e`). ## What the test checks Because this PR is scaffolding, it is doing something very basic: 1. Opens `/docs/guides/getting-started/quickstarts/nextjs` only if a connected file was edited in CI/CD step 2. Asserts the page loaded and the H1 is visible. 3. Collects docs-owned `/docs/**` links from `#sb-docs-guide-main-article`. 4. HTTP-checks each link (no full navigation) and soft-fails so every broken link is reported. Config keeps it cheap: Chromium only, 1 worker, 2 CI retries, failure screenshots/traces. ## Docs vs Studio/Dashboard The setup of Docs Playwright differs from Studio. | | Docs E2E | Studio E2E | |---|---|---| | Location |`e2e/docs/` | `e2e/studio/` | | What it tests | One published docs page + its links | Many Studio UI flows (tables, auth, storage, …) | | Where the app runs | Already-deployed **Vercel preview** | Built and started **on the runner** | | Backend needed | None | Local Supabase via Docker | | Path filtering | Native `on.pull_request.paths` (skip whole workflow) | `dorny/paths-filter` after checkout (workflow starts, heavy steps gated) | | Parallelism | 1 worker, no shards | Matrix of frameworks × 2 shards | | Retries | 2 in CI | 5 in CI | | Reports | HTML report on failure | Blob reports per shard → merge → PR comment | | Draft handling | Explicit draft skip | No draft skip today | | Manual broader run | Yes (`workflow_dispatch`) | No | The big conceptual difference: **Studio owns the environment** (build Studio, start Supabase, hit `localhost`). **Docs borrows Vercel’s preview** and only asks “does this page and its docs links work on the deployed site?” ## Docs architecture justification The docs architecture is deliberately lightweight because docs are **static, published content served by Vercel**, not an interactive app with a backend. That single fact justifies every difference: - **Borrow the Vercel preview instead of building on the runner.** The preview is already the exact artifact users will see, and Vercel builds it for free on every PR. Rebuilding docs on the runner would duplicate that work and risk testing something different from what ships. Studio, by contrast, needs a running app plus a local Supabase, so it *has* to own its environment. - **No backend.** Docs pages don't need a database or auth to render, so there's nothing to spin up. This is what keeps the job cheap enough to run per-PR. - **Native `paths` filtering.** Since the job is cheap and self-contained, an all-or-nothing skip at the workflow level is sufficient—no need for `dorny/paths-filter` to gate expensive setup steps mid-run like Studio does. - **Low parallelism and modest retries.** One page and its links is a tiny surface, so 1 worker is plenty and there's no sharding to coordinate. Retries exist only to absorb transient network flakiness against a live URL, hence 2 rather than Studio's 5 (which also cushions a heavier, stateful environment). - **Non-blocking + draft skip + manual dispatch.** As initial scaffolding checking link health on a deployed site, it should inform rather than gate merges, avoid burning minutes on drafts, and still be runnable on demand against production. In short: **Studio owns its environment because it must; docs borrows Vercel's preview because it can.** The scope is intentionally minimal today. ## Testing 1. Break a docs-owned link in the Next.js quickstart. 1. Follow README instructions to set up and run e2e docs test. 1. Confirm the suite fails. 1. Restore the broken link and re-run. 1. Confirm the suite **passes** (`1 passed`). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Summary - **New Features** - Added a GitHub Actions workflow to run Playwright docs end-to-end tests on PRs and via manual dispatch (with optional base URL), including docs-preview waiting and concurrency cancellation. - **Documentation** - Added `e2e/docs` README with setup, how to run the suite (including UI/debug and single-spec), and how base URL selection works. - **Tests** - Added a quickstarts E2E spec that validates the page and soft-checks docs-owned links resolve. - **Chores** - Added shared Playwright configuration/package scripts and an `e2e/docs` `.gitignore` for test outputs. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> |