Files
supabase/.github/workflows/docs-a11y-scan.yml
Alexis Aguilar 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)
2026-12-03 17:03:53 -07:00

86 lines
2.7 KiB
YAML

# Scans every docs guide on production for accessibility violations, daily.
# The page list is the guides in apps/docs/content/guides on master that also appear in
# https://supabase.com/docs/sitemap.xml, so a guide merged after the last production deploy waits
# for the next scan and shows as a warning on the run page. docs-master-alert.yml posts to Slack
# when its list of failures changes.
name: Docs Accessibility Scan
on:
workflow_dispatch:
schedule:
- cron: '17 5 * * *'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
CI: true
jobs:
a11y:
name: Docs accessibility scan
timeout-minutes: 45
runs-on: blacksmith-4vcpu-ubuntu-2404
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
sparse-checkout: |
e2e/docs
e2e/shared
patches
apps/docs/content/guides
apps/docs/scripts/federated-content/sources
apps/docs/lib/redirects
- uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
name: Install pnpm
with:
run_install: false
- name: Use Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile --filter=e2e-docs...
- name: Install Playwright Chromium
run: pnpm -C e2e/docs exec playwright install chromium --with-deps --only-shell
- name: Run accessibility scan
working-directory: e2e/docs
run: pnpm run e2e:docs:all --grep @a11y
env:
PLAYWRIGHT_BASE_URL: https://supabase.com
DOCS_A11Y_FAILURES_FILE: ${{ github.workspace }}/e2e/docs/a11y-failures.json
DOCS_E2E_DEPLOYED_ONLY: 1
- name: Upload failures for the alert
# docs-alert.ts reads this file through RESULTS_WORKFLOWS
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: docs-failures-${{ github.run_attempt }}
path: e2e/docs/a11y-failures.json
retention-days: 7
if-no-files-found: ignore
- name: Upload Playwright report
if: failure()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: docs-a11y-playwright-report
path: |
e2e/docs/playwright-report/
e2e/docs/test-results/
retention-days: 7