mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
ci(docs): scan every docs guide for accessibility issues daily (#54339)
## 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)
This commit is contained in:
1 parent
a310db593b
commit
c1330ca99f
6 files changed
+130
-22
No files matched your search
@@ -0,0 +1,70 @@
|
||||
# Scans every docs guide on production for accessibility violations, daily.
|
||||
# docs-master-alert.yml posts failures to Slack.
|
||||
|
||||
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
|
||||
|
||||
- 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
|
||||
@@ -79,6 +79,7 @@ jobs:
|
||||
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'
|
||||
@@ -240,7 +241,7 @@ jobs:
|
||||
- name: Run docs E2E
|
||||
if: steps.base-url.outputs.should_test == 'true'
|
||||
working-directory: e2e/docs
|
||||
# Accessibility scans are slow, so CI runs skip them.
|
||||
# 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 }}
|
||||
|
||||
@@ -11,6 +11,7 @@ on:
|
||||
- 'Docs removed anchors'
|
||||
- 'docs_sync'
|
||||
- 'Docs Production Smoke Tests'
|
||||
- 'Docs Accessibility Scan'
|
||||
- 'Ingest Docs Content for Search V2'
|
||||
- 'Docs Tests'
|
||||
branches: [master]
|
||||
@@ -31,37 +32,28 @@ jobs:
|
||||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DOCS_WEBHOOK_URL }}
|
||||
WORKFLOW_NAME: ${{ github.event.workflow_run.name }}
|
||||
WORKFLOW_URL: ${{ github.event.workflow_run.html_url }}
|
||||
COMMIT_SHA: ${{ github.event.workflow_run.head_sha }}
|
||||
COMMIT_MESSAGE: ${{ github.event.workflow_run.head_commit.message }}
|
||||
COMMIT_AUTHOR: ${{ github.event.workflow_run.head_commit.author.name }}
|
||||
REPO_URL: https://github.com/${{ github.repository }}
|
||||
TRIGGER: ${{ github.event.workflow_run.event }}
|
||||
run: |
|
||||
SHORT_SHA="${COMMIT_SHA:0:7}"
|
||||
FIRST_LINE=$(echo "$COMMIT_MESSAGE" | head -1)
|
||||
|
||||
PAYLOAD=$(jq -n \
|
||||
--arg workflow_name "$WORKFLOW_NAME" \
|
||||
--arg workflow_url "$WORKFLOW_URL" \
|
||||
--arg commit_sha "$COMMIT_SHA" \
|
||||
--arg short_sha "$SHORT_SHA" \
|
||||
--arg commit_msg "$FIRST_LINE" \
|
||||
--arg author "$COMMIT_AUTHOR" \
|
||||
--arg repo_url "$REPO_URL" \
|
||||
'{
|
||||
text: ":rotating_light: \($workflow_name) failed on master",
|
||||
--arg trigger "$TRIGGER" \
|
||||
'(if $trigger == "push" then "push to master" elif $trigger == "schedule" then "scheduled run" elif $trigger == "workflow_dispatch" then "manual run" else "\($trigger) run" end) as $run
|
||||
| {
|
||||
text: ":rotating_light: \($workflow_name) failed on a \($run)",
|
||||
blocks: [
|
||||
{
|
||||
type: "header",
|
||||
text: {
|
||||
type: "plain_text",
|
||||
text: ":rotating_light: master is broken"
|
||||
text: ":rotating_light: \($workflow_name) failed"
|
||||
}
|
||||
},
|
||||
{
|
||||
type: "section",
|
||||
text: {
|
||||
type: "mrkdwn",
|
||||
text: "*Workflow:* <\($workflow_url)|\($workflow_name)>\n*Commit:* <\($repo_url)/commit/\($commit_sha)|\($short_sha)> \($commit_msg)\n*Author:* \($author)"
|
||||
text: "*Workflow:* <\($workflow_url)|\($workflow_name)> (\($run))"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
+12
-3
@@ -144,6 +144,11 @@ pages linking into reference docs or server-side auth guides.
|
||||
- Non-docs routes such as `/dashboard` and `/ui`, which the link checker skips
|
||||
- Guides that the nav disables, listed in `NAV_DISABLED_PAGES` in
|
||||
`utils/resolve-docs-scope.ts`, because their HTML page returns 404
|
||||
- Guides that `apps/docs/lib/redirects/static-redirects.json` redirects
|
||||
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
|
||||
|
||||
@@ -165,9 +170,13 @@ staged and unstaged working-tree changes.
|
||||
|
||||
## Accessibility scans
|
||||
|
||||
The `@a11y`-tagged test scans each in-scope page for WCAG 2.1 A/AA violations using
|
||||
`@axe-core/playwright`, limited to the main article. The scans are slow, so CI
|
||||
runs skip them.
|
||||
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-helpers.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, and a failure posts to the docs alerts channel in
|
||||
Slack. To start it by hand, run `gh workflow run docs-a11y-scan.yml`.
|
||||
|
||||
```bash
|
||||
PLAYWRIGHT_BASE_URL=https://supabase.com pnpm e2e:docs:a11y
|
||||
|
||||
@@ -50,6 +50,25 @@ test('excludes a guide that the navigation disables from the full run', async ()
|
||||
assert.ok(!pages.includes('/docs/guides/ai-tools/agent-feedback'))
|
||||
})
|
||||
|
||||
test('skips a guide that redirects out of the docs', async () => {
|
||||
const result = await resolveDocsScope({
|
||||
changedFiles: [
|
||||
'apps/docs/content/guides/getting-started/features.mdx',
|
||||
'apps/docs/content/guides/ai-tools/mcp.mdx',
|
||||
],
|
||||
repoRoot,
|
||||
})
|
||||
|
||||
assert.deepEqual(result.pages, ['/docs/guides/ai-tools/mcp'])
|
||||
})
|
||||
|
||||
test('excludes a guide that redirects out of the docs from the full run', async () => {
|
||||
const pages = await resolveAllDocsPages(repoRoot)
|
||||
|
||||
assert.ok(pages.includes('/docs/guides/ai-tools/mcp'))
|
||||
assert.ok(!pages.includes('/docs/guides/getting-started/features'))
|
||||
})
|
||||
|
||||
test('keeps every page in a large change', async () => {
|
||||
const changedFiles = Array.from(
|
||||
{ length: 82 },
|
||||
|
||||
@@ -15,6 +15,7 @@ const GUIDES_PREFIX = 'apps/docs/content/guides/'
|
||||
const PARTIALS_PREFIX = 'apps/docs/content/_partials/'
|
||||
const DOCS_GUIDES_URL_PREFIX = '/docs/guides/'
|
||||
const FEDERATED_CONTENT_SOURCES_DIR = 'apps/docs/scripts/federated-content/sources'
|
||||
const STATIC_REDIRECTS_FILE = 'apps/docs/lib/redirects/static-redirects.json'
|
||||
export const GUIDE_LIST_COMPONENT =
|
||||
'apps/docs/components/Navigation/NavigationMenu/NavigationMenuGuideListItems.tsx'
|
||||
|
||||
@@ -27,6 +28,20 @@ export const GUIDE_LIST_COMPONENT_PAGES = [
|
||||
// the nav disables these guides, so the docs app returns 404 for their html page
|
||||
const NAV_DISABLED_PAGES = new Set(['/docs/guides/ai-tools/agent-feedback'])
|
||||
|
||||
// guides with no docs article to test: nav-disabled guides, and guides that redirect elsewhere
|
||||
async function loadUntestablePages(repoRoot: string): Promise<Set<string>> {
|
||||
const redirects: unknown = JSON.parse(
|
||||
await readFile(join(repoRoot, STATIC_REDIRECTS_FILE), 'utf8')
|
||||
)
|
||||
if (!Array.isArray(redirects)) {
|
||||
throw new Error(`${STATIC_REDIRECTS_FILE} should be an array of redirects.`)
|
||||
}
|
||||
const redirectedPages = redirects.flatMap((redirect) =>
|
||||
typeof redirect?.source === 'string' ? [redirect.source] : []
|
||||
)
|
||||
return new Set([...NAV_DISABLED_PAGES, ...redirectedPages])
|
||||
}
|
||||
|
||||
const PARTIAL_PATH_RE = /<\$Partial\b[\s\S]*?\bpath\s*=\s*"([^"]+)"[\s\S]*?\/?>/g
|
||||
const SOURCE_SECTION_RE = /\bsection:\s*'([^']+)'/g
|
||||
|
||||
@@ -266,8 +281,9 @@ export async function resolveDocsScope(
|
||||
}
|
||||
}
|
||||
|
||||
const untestablePages = await loadUntestablePages(options.repoRoot)
|
||||
const sorted = [...new Set([...requiredPages, ...pages])]
|
||||
.filter((page) => !NAV_DISABLED_PAGES.has(page))
|
||||
.filter((page) => !untestablePages.has(page))
|
||||
.sort()
|
||||
|
||||
return {
|
||||
@@ -282,12 +298,13 @@ export async function resolveAllDocsPages(repoRoot: string): Promise<string[]> {
|
||||
const guidesDir = join(repoRoot, 'apps/docs/content/guides')
|
||||
const guideFiles = await walkMdxFiles(guidesDir).catch(() => [] as string[])
|
||||
|
||||
const untestablePages = await loadUntestablePages(repoRoot)
|
||||
const pages = new Set<string>()
|
||||
|
||||
for (const file of guideFiles) {
|
||||
const relFromGuides = normalizeRepoPath(relative(guidesDir, file)).replace(/\.mdx$/, '')
|
||||
const page = `${DOCS_GUIDES_URL_PREFIX}${relFromGuides}`
|
||||
if (isFederatedGuideSlug(relFromGuides) || NAV_DISABLED_PAGES.has(page)) continue
|
||||
if (isFederatedGuideSlug(relFromGuides) || untestablePages.has(page)) continue
|
||||
pages.add(page)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user