mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
## Problem Since #53899, Docs E2E skips the accessibility scan on every CI run, because the scan is slow and only covers the pages a diff names. Nothing checks docs accessibility automatically, and a change to a shared component can break pages that no pull request lists. ## Solution A new **Docs Accessibility Scan** workflow scans every MDX guide on production once a day. - `.github/workflows/docs-a11y-scan.yml` runs `pnpm e2e:docs:all --grep @a11y` against `https://supabase.com` at 05:17 UTC, off the top of the hour when GitHub can delay or drop scheduled runs, and on demand through `workflow_dispatch`. Its concurrency group includes the ref, so a manual run on a branch can't cancel the scheduled run on `master`. It uploads the Playwright report when the scan fails. - `docs-master-alert.yml` now watches the new workflow, so a failed run posts to the docs alerts Slack channel the same way the Production Smoke Tests do. - The shared alert no longer names the latest `master` commit and its author. That commit often didn't cause the failure: a scheduled or manual run tests whatever is deployed, and a workflow that was already failing keeps failing on later commits. The alert now names the workflow, says whether a push, schedule, or manual run failed, and links the run. This applies to every workflow the alert watches. - The scope resolver skips guides that `static-redirects.json` sends elsewhere, in both the pull request scope and the full run. A redirected guide has no docs article to scan, so it could never pass. Today that's only `getting-started/features`. Docs E2E's sparse checkout now includes `apps/docs/lib/redirects` so the resolver can read the file. One helper lists every guide with no docs article to test (nav-disabled and redirected), and both resolvers use it. - The README says where and when the scans run, which checks fail the scan, and how to start one by hand. It also lists guides with no MDX file, such as the CLI and self-hosting config pages, as a known limitation: the full run only resolves MDX guides, so the scan skips them. The full run doesn't need sharding. A list over 20 pages already runs on 3 workers, and the whole site took 15.3 minutes against production, inside the job's 45-minute timeout. ## Known failures A full run against production on 2026-11-30 failed on 5 guides with real accessibility issues: 4 `duplicate-id` and 1 `heading-order`. Until [DOCS-1817](https://linear.app/supabase/issue/DOCS-1817/fix-the-accessibility-issues-the-daily-docs-scan-finds-on-5-guides) fixes them, each daily run fails and posts an alert. ## Follow-ups - [DOCS-1831](https://linear.app/supabase/issue/DOCS-1831/trace-each-docs-accessibility-scan-failure-to-the-commit-that): keep a list of open failures in every docs alert, each with the commit that introduced it, or its possible commits marked unconfirmed. ## Review instructions 1. Run `pnpm -C e2e/docs test` and confirm all 15 tests pass, including the two redirect tests. 2. Confirm a change to a redirected guide resolves to no pages: ```bash printf 'apps/docs/content/guides/getting-started/features.mdx\n' | pnpm -C e2e/docs resolve-docs-scope ``` Expect `skip=true`. 3. Run the scan the way the workflow does, on one passing guide and one guide from DOCS-1817: ```bash cd e2e/docs && PLAYWRIGHT_BASE_URL=https://supabase.com DOCS_E2E_PAGE_PATHS=/docs/guides/auth,/docs/guides/resources pnpm exec playwright test --grep @a11y ``` Expect `/docs/guides/auth` to pass and `/docs/guides/resources` to fail on `heading-order`. 4. Check the alert payload. Copy the `run` script from `docs-master-alert.yml`, replace the `curl` call with `echo "$PAYLOAD"`, and run it with `TRIGGER` set to `push`, then `schedule`. Expect no commit or author in either, and the run type in the workflow line. 5. After merge, start the workflow with `gh workflow run docs-a11y-scan.yml` and confirm it finishes in about 15 to 20 minutes. Verified locally: unit tests, mutation probes on both redirect tests, typecheck, actionlint on the changed workflows, the alert payload for push, scheduled, and manual runs, the resolver on a sparse checkout like the workflow's, and a full-site scan against production. A scheduled workflow only runs from `master`, so the workflow itself hasn't run on GitHub yet. Resolves [DOCS-1816](https://linear.app/supabase/issue/DOCS-1816/run-the-docs-e2e-accessibility-scan-on-a-schedule-across-the-whole) Resolves [DOCS-1826](https://linear.app/supabase/issue/DOCS-1826/word-docs-slack-alerts-for-scheduled-workflow-failures-without-blaming) ## Checklist - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
260 lines
11 KiB
YAML
260 lines
11 KiB
YAML
name: Docs E2E Tests
|
||
|
||
# "Docs E2E" is a required status check on master, so this workflow must
|
||
# produce a check run on every PR — a `paths` trigger filter would leave
|
||
# non-docs PRs waiting on a check that never reports. Path scoping happens
|
||
# in the "Detect changed paths" step instead; when nothing docs-related
|
||
# changed, the remaining steps are skipped and the check reports green.
|
||
on:
|
||
pull_request:
|
||
types: [opened, synchronize, reopened, ready_for_review, converted_to_draft]
|
||
branches: ['master', 'release']
|
||
workflow_dispatch:
|
||
inputs:
|
||
base_url:
|
||
description: 'Base URL to test against'
|
||
required: false
|
||
default: 'https://supabase.com'
|
||
type: string
|
||
page_paths:
|
||
description: 'Comma-separated /docs/... paths to test (required for manual runs)'
|
||
required: false
|
||
default: ''
|
||
type: string
|
||
|
||
concurrency:
|
||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||
cancel-in-progress: true
|
||
|
||
permissions:
|
||
contents: read
|
||
statuses: read
|
||
pull-requests: read
|
||
|
||
env:
|
||
CI: true
|
||
|
||
jobs:
|
||
e2e:
|
||
name: Docs E2E
|
||
if: github.event_name == 'workflow_dispatch' || github.event.pull_request.draft == false
|
||
timeout-minutes: 30
|
||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||
|
||
steps:
|
||
# Runs before checkout — reads the PR file list from the API. `docs`
|
||
# mirrors the path scope this workflow used to have as a trigger filter;
|
||
# `docs_app` decides whether a Vercel docs preview exists to test against.
|
||
- name: Detect changed paths
|
||
id: changes
|
||
if: github.event_name == 'pull_request'
|
||
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
|
||
with:
|
||
filters: |
|
||
docs:
|
||
- 'apps/docs/content/guides/**/*.mdx'
|
||
- 'apps/docs/content/_partials/**'
|
||
- 'e2e/docs/**'
|
||
- 'e2e/shared/**'
|
||
- 'pnpm-lock.yaml'
|
||
- '.github/workflows/docs-e2e.yml'
|
||
docs_app:
|
||
- 'apps/docs/**'
|
||
harness:
|
||
- 'e2e/docs/**'
|
||
- 'e2e/shared/**'
|
||
|
||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||
if: github.event_name == 'workflow_dispatch' || steps.changes.outputs.docs == 'true'
|
||
with:
|
||
persist-credentials: false
|
||
# Need full history on PRs so we can diff against the base branch.
|
||
# Use string '0' — numeric 0 is falsy in GitHub Actions expressions.
|
||
fetch-depth: ${{ github.event_name == 'pull_request' && '0' || '1' }}
|
||
sparse-checkout: |
|
||
e2e/docs
|
||
e2e/shared
|
||
scripts
|
||
patches
|
||
apps/docs/content/guides
|
||
apps/docs/content/_partials
|
||
apps/docs/scripts/federated-content/sources
|
||
apps/docs/lib/redirects
|
||
|
||
- name: Use Node.js
|
||
if: github.event_name == 'workflow_dispatch' || steps.changes.outputs.docs == 'true'
|
||
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||
with:
|
||
node-version-file: '.nvmrc'
|
||
|
||
# The harness unit tests need no installed packages, so they run before the
|
||
# scope step and also on harness-only changes, which skip Playwright.
|
||
- name: Run docs E2E harness unit tests
|
||
if: github.event_name == 'pull_request' && steps.changes.outputs.harness == 'true'
|
||
working-directory: e2e/docs
|
||
# `node --test` passes when its pattern matches no files, so fail here if a
|
||
# rename or move leaves nothing to run.
|
||
run: |
|
||
shopt -s nullglob
|
||
test_files=(utils/*.test.ts)
|
||
if [ "${#test_files[@]}" -eq 0 ]; then
|
||
echo "::error::No harness unit tests match e2e/docs/utils/*.test.ts."
|
||
exit 1
|
||
fi
|
||
node --test --experimental-strip-types "${test_files[@]}"
|
||
|
||
# Map changed owned content (guides, partials) to page
|
||
# URLs. Harness-only PRs resolve to skip=true and exit before Playwright.
|
||
- name: Resolve docs E2E scope
|
||
id: scope
|
||
if: github.event_name == 'workflow_dispatch' || steps.changes.outputs.docs == 'true'
|
||
env:
|
||
EVENT_NAME: ${{ github.event_name }}
|
||
BASE_REF: ${{ github.base_ref }}
|
||
PAGE_PATHS_INPUT: ${{ inputs.page_paths }}
|
||
run: |
|
||
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
|
||
if [ -z "$PAGE_PATHS_INPUT" ]; then
|
||
echo "skip=true" >> "$GITHUB_OUTPUT"
|
||
echo "paths=" >> "$GITHUB_OUTPUT"
|
||
echo "Manual run requires the page_paths input."
|
||
exit 0
|
||
fi
|
||
echo "skip=false" >> "$GITHUB_OUTPUT"
|
||
printf 'paths=%s\n' "$PAGE_PATHS_INPUT" >> "$GITHUB_OUTPUT"
|
||
exit 0
|
||
fi
|
||
|
||
git diff --name-only --diff-filter=ACMR "origin/$BASE_REF"...HEAD \
|
||
| node --experimental-strip-types e2e/docs/scripts/resolve-docs-scope.ts
|
||
|
||
- name: Skip Playwright (no in-scope pages)
|
||
if: steps.scope.outputs.skip == 'true'
|
||
run: echo "No in-scope docs pages changed; skipping Playwright suite."
|
||
|
||
- uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
|
||
if: steps.scope.outputs.skip == 'false'
|
||
name: Install pnpm
|
||
with:
|
||
run_install: false
|
||
|
||
- name: Enable pnpm store cache
|
||
if: steps.scope.outputs.skip == 'false'
|
||
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||
with:
|
||
node-version-file: '.nvmrc'
|
||
cache: 'pnpm'
|
||
|
||
# Vercel skips the docs preview when a PR only changes the harness
|
||
# (e2e/docs, workflow), so wait for a preview only when apps/docs changed.
|
||
# When apps/docs changed earlier in the PR but not in the head commit,
|
||
# Vercel skips the head build as not affected and its URL serves a
|
||
# placeholder page; the script then uses the newest READY preview from
|
||
# an earlier commit of the PR, which serves the same docs content.
|
||
#
|
||
# Vercel's GitHub App stopped writing GitHub Deployment objects on
|
||
# 2026-02-17 (broken app auth), so vercel/wait-for-deployment-action
|
||
# times out polling that API even though the preview builds fine.
|
||
# Poll the "Vercel – docs" commit status instead — Vercel keeps posting
|
||
# those — then resolve the deployment it points to via Vercel's own API
|
||
# to get the actual preview URL. See scripts/waitForVercelPreview.js.
|
||
# A Vercel failure or timeout is not the author's problem, and the required
|
||
# "Vercel – docs" check already reports it. Resolve no URL and skip below.
|
||
- name: Wait for Vercel docs preview
|
||
if: steps.scope.outputs.skip == 'false' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && steps.changes.outputs.docs_app == 'true'
|
||
id: deployment
|
||
continue-on-error: true
|
||
# Polls for minutes; install deps and Chromium while it does.
|
||
background: true
|
||
run: node scripts/waitForVercelPreview.js
|
||
env:
|
||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||
VERCEL_STATUS_CONTEXT: 'Vercel – docs'
|
||
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
|
||
VERCEL_TEAM_ID: ${{ secrets.VERCEL_TEAM_ID }}
|
||
|
||
- name: Install dependencies
|
||
if: steps.scope.outputs.skip == 'false'
|
||
run: pnpm install --frozen-lockfile --filter=e2e-docs...
|
||
|
||
- name: Install Playwright Chromium
|
||
if: steps.scope.outputs.skip == 'false'
|
||
run: pnpm -C e2e/docs exec playwright install chromium --with-deps --only-shell
|
||
|
||
- name: Wait for Vercel docs preview to finish
|
||
wait: [deployment]
|
||
|
||
- name: Resolve base URL
|
||
if: steps.scope.outputs.skip == 'false'
|
||
id: base-url
|
||
env:
|
||
EVENT_NAME: ${{ github.event_name }}
|
||
BASE_URL_INPUT: ${{ inputs.base_url }}
|
||
DEPLOYMENT_URL: ${{ steps.deployment.outputs.deployment-url }}
|
||
PAGE_PATHS: ${{ steps.scope.outputs.paths }}
|
||
run: |
|
||
set -euo pipefail
|
||
|
||
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
|
||
printf 'url=%s\n' "$BASE_URL_INPUT" >> "$GITHUB_OUTPUT"
|
||
# Non-production targets are previews, which may need the bypass.
|
||
if [ "$BASE_URL_INPUT" = "https://supabase.com" ]; then
|
||
echo "use_bypass=false" >> "$GITHUB_OUTPUT"
|
||
else
|
||
echo "use_bypass=true" >> "$GITHUB_OUTPUT"
|
||
fi
|
||
echo "should_test=true" >> "$GITHUB_OUTPUT"
|
||
exit 0
|
||
fi
|
||
|
||
if [ -n "$DEPLOYMENT_URL" ]; then
|
||
printf 'url=%s\n' "$DEPLOYMENT_URL" >> "$GITHUB_OUTPUT"
|
||
echo "use_bypass=true" >> "$GITHUB_OUTPUT"
|
||
echo "should_test=true" >> "$GITHUB_OUTPUT"
|
||
exit 0
|
||
fi
|
||
|
||
# Production is not a substitute: it lacks pages this pull request
|
||
# adds, so testing it fails a required check for a valid change.
|
||
echo "url=" >> "$GITHUB_OUTPUT"
|
||
echo "use_bypass=false" >> "$GITHUB_OUTPUT"
|
||
echo "should_test=false" >> "$GITHUB_OUTPUT"
|
||
echo "::warning::No Vercel docs preview URL for this pull request, so there is nothing serving its content to test. Skipping Playwright rather than testing production, which does not have pages this pull request adds."
|
||
{
|
||
echo "### Docs E2E skipped: no preview to test against"
|
||
echo
|
||
echo "Nothing is serving this pull request's content, and production is not a"
|
||
echo "substitute — pages it adds do not exist there yet."
|
||
echo
|
||
echo "Fork pull requests reach this path because they run without repository"
|
||
echo "secrets. A maintainer can run the suite against the preview manually:"
|
||
echo
|
||
echo '```'
|
||
echo "gh workflow run docs-e2e.yml \\"
|
||
echo " -f base_url=<preview-url> \\"
|
||
echo " -f page_paths=$PAGE_PATHS"
|
||
echo '```'
|
||
} >> "$GITHUB_STEP_SUMMARY"
|
||
|
||
- name: Run docs E2E
|
||
if: steps.base-url.outputs.should_test == 'true'
|
||
working-directory: e2e/docs
|
||
# Accessibility scans are slow, so they run daily in docs-a11y-scan.yml instead.
|
||
run: pnpm run e2e:docs --grep-invert @a11y
|
||
env:
|
||
PLAYWRIGHT_BASE_URL: ${{ steps.base-url.outputs.url }}
|
||
DOCS_E2E_PAGE_PATHS: ${{ steps.scope.outputs.paths }}
|
||
VERCEL_AUTOMATION_BYPASS_SECRET: ${{ steps.base-url.outputs.use_bypass == 'true' && secrets.VERCEL_AUTOMATION_BYPASS_DOCS || '' }}
|
||
|
||
- name: Upload Playwright report
|
||
if: failure() && steps.scope.outputs.skip == 'false'
|
||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||
with:
|
||
name: docs-playwright-report
|
||
path: |
|
||
e2e/docs/playwright-report/
|
||
e2e/docs/test-results/
|
||
retention-days: 7
|