Skip to content

Commit bfcebbb

Browse files
authored
Check component documentation accessibility in CI (#1634)
* Audit official-site component docs with axe in CI * Audit component examples in SQLPage stock themes
1 parent 36552e8 commit bfcebbb

10 files changed

Lines changed: 275 additions & 51 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ on:
1212
- ".github/workflows/release.yml"
1313
# Required checks must be reported for every PR, including docs-only changes.
1414
pull_request:
15-
branches:
16-
- "main"
1715
merge_group:
1816

1917
concurrency:
@@ -29,23 +27,41 @@ jobs:
2927
ci_selection:
3028
runs-on: ubuntu-latest
3129
permissions:
30+
contents: read
3231
pull-requests: read
3332
outputs:
3433
# Only a confirmed excluded-files-only PR may skip the core jobs.
3534
full: ${{ github.event_name != 'pull_request' || steps.paths.outputs.full != 'false' }}
35+
# Run the audit when a tag or oversized PR cannot be filtered.
36+
accessibility: ${{ steps.paths.outputs.accessibility != 'false' }}
3637
steps:
38+
- uses: actions/checkout@v7
39+
if: github.event_name != 'pull_request' && github.ref_type != 'tag'
3740
- id: paths
3841
name: Select test jobs
3942
# The PR files API is limited to 3000 files; larger PRs select core jobs.
40-
if: github.event_name == 'pull_request' && github.event.pull_request.changed_files <= 3000
43+
if: github.ref_type != 'tag' && (github.event_name != 'pull_request' || github.event.pull_request.changed_files <= 3000)
4144
uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
4245
with:
43-
predicate-quantifier: every
46+
predicate-quantifier: some-with-excludes
4447
filters: |
4548
full:
49+
- '**'
4650
- '!docs/**'
4751
- '!README.md'
4852
- '!.github/workflows/release.yml'
53+
accessibility:
54+
- 'sqlpage/templates/**'
55+
- 'frontend/**'
56+
- 'src/{dynamic_component,render,template_helpers,templates}.rs'
57+
- 'examples/official-site/**'
58+
- 'configuration.md'
59+
- 'scripts/{build-frontend,site-build}.mjs'
60+
- 'package-lock.json'
61+
- 'package.json'
62+
- 'tests/end-to-end/**'
63+
- '.github/actions/install-frontend-dependencies/**'
64+
- '.github/workflows/ci.yml'
4965
5066
compile_and_lint:
5167
needs: ci_selection
@@ -233,7 +249,7 @@ jobs:
233249
playwright:
234250
runs-on: ubuntu-latest
235251
timeout-minutes: 10
236-
needs: compile_and_lint
252+
needs: [ci_selection, compile_and_lint]
237253
defaults:
238254
run:
239255
working-directory: ./tests/end-to-end
@@ -257,9 +273,15 @@ jobs:
257273
name: official-site
258274
path: target/official-site
259275
- name: Run Playwright tests
276+
env:
277+
RUN_ACCESSIBILITY: ${{ needs.ci_selection.outputs.accessibility }}
260278
run: |
261279
chmod +x "${{ runner.temp }}/sqlpage-bin/sqlpage"
262-
SQLPAGE_BINARY="${{ runner.temp }}/sqlpage-bin/sqlpage" npx playwright test
280+
args=()
281+
if [[ "$RUN_ACCESSIBILITY" == false ]]; then
282+
args+=(--grep-invert @accessibility)
283+
fi
284+
SQLPAGE_BINARY="${{ runner.temp }}/sqlpage-bin/sqlpage" npx playwright test "${args[@]}"
263285
- uses: actions/upload-artifact@v7
264286
if: ${{ !cancelled() }}
265287
with:

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## unreleased
44

5+
- Component reference pages accept `theme=light` and `theme=dark` to preview examples with SQLPage's stock themes.
56
- The first-website tutorial now lets you choose an installation target, copy a command, or download an archive for macOS, Windows, Linux, or AWS Lambda.
67
- Missing component pages on the official site return HTTP 404 and link to the catalog. Action buttons in colored alerts stay readable.
78
- The `shell` sidebar now uses `navbar_title` and preserves the colors of the supplied logo in dark mode.

‎CONTRIBUTING.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ built executable. Component suites use `fixtures/<suite>/{index.sql,test.ts}` an
6767
import the shared `fixture.ts` harness; root-level `*.spec.ts` files cover the
6868
official site.
6969

70+
Run `npx playwright test --grep @accessibility` from `tests/end-to-end` to audit
71+
the official site's component documentation and its live examples in SQLPage's
72+
stock light and dark themes with axe-core. CI includes this test when component
73+
templates, frontend code, the official site, or audit inputs change.
74+
7075
To show that an issue exists before you fix it, put the reproduction in a fixture and run it against releases with one command, such as `nix run .#reproduce -- repro_721 postgres v0.35.0 v0.36.1 tree`. The second argument is `sqlite` or `postgres`, and `tree` is your working tree. It prints Playwright's output for each version, then a table you can paste into the issue or pull request. Releases run from their Docker images, from v0.29.0 onwards, and Postgres from `docker compose`. Without Nix, run `npm run reproduce --` in `tests/end-to-end` instead.
7176

7277
To run a whole suite against a release instead, set `SQLPAGE_RELEASE` to its tag, such as `SQLPAGE_RELEASE=v0.47.0 npx playwright test fixtures/tracking`. Both servers then run that release's Docker image against the same fixtures, on ports 18080 and 18081, so the test fails on the release and passes on your working tree. Add `--ui` to watch the page in each step.

‎examples/official-site/README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ Run SQLPage from that directory, or run
2222
`docker compose -f examples/official-site/docker-compose.yml up --build` from
2323
the repository root.
2424

25+
Add `theme=light` or `theme=dark` to a component reference URL to preview its
26+
live examples using SQLPage's stock theme. For example, visit
27+
`/component.sql?component=form&theme=light`.
28+
2529
## Landing page
2630

2731
The home page is rendered by `index.sql` and the `landing-page` custom template.

‎examples/official-site/assets/docs/examples.css‎

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,44 +16,52 @@
1616
display: flow-root;
1717
container-type: inline-size;
1818
padding: var(--tblr-spacer-3);
19+
}
20+
21+
/* The branded previews adjust native components to fit the docs layout. */
22+
:where([data-site-theme="custom-docsite"]) .docs-example-output {
1923
--tblr-carousel-control-icon-filter: none;
2024
--tblr-carousel-indicator-active-bg: var(--tblr-heading-color);
21-
}
22-
/* Tabler sizes columns against the viewport. A card in a preview can have much less room. */
23-
.docs-example-output > .row > * {
24-
flex-grow: 1;
25-
min-width: min(100%, 17rem);
26-
}
27-
.docs-example-output form .row > label {
28-
min-width: min(100%, 12rem);
29-
}
30-
.docs-example-output .card {
31-
max-width: 100%;
32-
}
33-
.docs-example-output .table-freeze-columns tr > :first-child {
34-
width: clamp(7rem, 32cqi, 11rem);
35-
min-width: min(9rem, 40cqi);
36-
white-space: normal;
37-
}
38-
.docs-example-output .pagination {
39-
flex-wrap: wrap;
40-
}
41-
.docs-example-output .markdown table {
42-
display: block;
43-
overflow-x: auto;
25+
26+
/* Preview columns can have much less room than the viewport. */
27+
& > .row > * {
28+
flex-grow: 1;
29+
min-width: min(100%, 17rem);
30+
}
31+
& form .row > label {
32+
min-width: min(100%, 12rem);
33+
}
34+
& .card {
35+
max-width: 100%;
36+
}
37+
& .table-freeze-columns tr > :first-child {
38+
width: clamp(7rem, 32cqi, 11rem);
39+
min-width: min(9rem, 40cqi);
40+
white-space: normal;
41+
}
42+
& .pagination {
43+
flex-wrap: wrap;
44+
}
45+
& .markdown table {
46+
display: block;
47+
overflow-x: auto;
48+
}
49+
50+
@media (max-width: 27rem) {
51+
/* Give charts the full preview width while keeping the titles inset. */
52+
&:has(> .card > .card-body > .chart) {
53+
padding-inline: 0;
54+
}
55+
& > .card > .card-body > .chart {
56+
margin-inline: calc(-1 * var(--tblr-card-spacer-x));
57+
}
58+
}
4459
}
4560
@media (max-width: 27rem) {
4661
.docs-example > .docs-example-source,
4762
.docs-example-layout {
4863
margin-inline: calc(var(--tblr-spacer-1) - var(--docs-gutter));
4964
}
50-
/* A chart card fills the preview. Keep its title inset and give the plot the full width. */
51-
.docs-example-output:has(> .card > .card-body > .chart) {
52-
padding-inline: 0;
53-
}
54-
.docs-example-output > .card > .card-body > .chart {
55-
margin-inline: calc(-1 * var(--tblr-card-spacer-x));
56-
}
5765
}
5866
@container example (min-width: 52rem) {
5967
.docs-example-layout {

‎examples/official-site/sqlpage/docs-shell.sql‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ select 'shell-docs' as component,
77
$options->>'title' as title,
88
$options->>'description' as description,
99
$options->>'css' as css,
10+
case sqlpage.variables('get')->>'theme'
11+
when 'light' then 'light'
12+
when 'dark' then 'dark'
13+
end as stock_theme,
1014
$section as section,
1115
cast($catalog as integer) as catalog,
1216
coalesce($kind || 's', 'guides') as topic_label,

‎examples/official-site/sqlpage/templates/shell-docs.handlebars‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!doctype html>
2-
<html lang="en" data-bs-theme="dark">
2+
<html lang="en" data-bs-theme="{{default stock_theme 'dark'}}"{{#unless stock_theme}} data-site-theme="custom-docsite"{{/unless}}>
33
<head>
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1">
@@ -12,7 +12,9 @@
1212
<meta name="generator" content="SQLPage v{{buildinfo 'CARGO_PKG_VERSION'}}">
1313
<link rel="icon" href="/favicon.ico">
1414
<link rel="stylesheet" href="{{static_path 'sqlpage.css'}}">
15-
<link rel="stylesheet" href="/assets/highlightjs-and-tabler-theme.css">
15+
{{#unless stock_theme}}
16+
<link rel="stylesheet" href="/assets/highlightjs-and-tabler-theme.css">
17+
{{/unless}}
1618
<link rel="stylesheet" href="/assets/docs/shell.css">
1719
{{#if catalog}}
1820
<link rel="canonical" href="{{catalog_link}}">

‎package-lock.json‎

Lines changed: 40 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)