-
Notifications
You must be signed in to change notification settings - Fork 339
Accessibility test Kitchen Sink with Playwright #1260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 52 commits
e3ed101
a16cc88
68079b2
5030606
423ed5d
de4e2dd
310f171
09906c1
2480b00
6f938ba
b5b57ca
f47a60a
62b6ae7
fc04acf
23be214
66fac74
bc311db
94fb49f
9436844
e5a8814
3f86b11
700b64a
c57011d
ced281d
33b10ac
f8cee2c
9df077a
1c2b8d5
a4325f5
72dfedc
f1c8007
0317729
744fc94
5e06478
6820864
419d9e8
c18dbd6
e63d3e7
83af9ac
178a689
f7b92ea
926d426
49c15a9
036506b
0f0d599
2176326
ec6a9d7
452ef73
71a86ac
645202c
07b9566
19ccd1b
112a27a
00005d2
b9d83f6
22953ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,9 @@ jobs: | |
# windows test | ||
- os: windows-latest | ||
python-version: "3.11" | ||
# needed to cache the browsers for the accessibility tests | ||
env: | ||
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/pw-browsers | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
@@ -90,14 +93,30 @@ jobs: | |
pip install nox | ||
nox -s compile | ||
- name: Run tests | ||
run: pytest --color=yes --cov pydata_sphinx_theme --cov-branch --cov-report xml:cov.xml --cov-report= --cov-fail-under ${{ env.COVERAGE_THRESHOLD }} | ||
run: pytest -m "not a11y" --color=yes --cov pydata_sphinx_theme --cov-branch --cov-report xml:cov.xml --cov-report= --cov-fail-under ${{ env.COVERAGE_THRESHOLD }} | ||
- name: Upload to Codecov | ||
if: matrix.python-version == '3.11' && matrix.os == 'ubuntu-latest' | ||
uses: codecov/[email protected] | ||
with: | ||
files: cov.xml | ||
fail_ci_if_error: true | ||
|
||
# note I am setting this on top of the Python cache as I could not find | ||
# how to set the hash key on the python one | ||
- name: Set up browser cache (for accessibility tests) | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
${{ github.workspace }}/pw-browsers | ||
key: ${{ runner.os }}-pw-${{ hashFiles('pyproject.toml') }} | ||
restore-keys: | | ||
${{ runner.os }}-pw- | ||
|
||
- name: Run accessibility tests with playwright | ||
if: matrix.python-version == '3.11' && matrix.os == 'ubuntu-latest' | ||
run: | | ||
nox -s a11y | ||
|
||
# Build our site on the 3 major OSes and check for Sphinx warnings | ||
build-site: | ||
needs: [lint] | ||
|
@@ -124,7 +143,7 @@ jobs: | |
- name: Build docs | ||
run: sphinx-build -b html docs/ docs/_build/html --keep-going -w warnings.txt | ||
- name: Check for unexpected Sphinx warnings | ||
run: python tests/check_warnings.py | ||
run: python tests/utils/check_warnings.py | ||
|
||
# Run local Lighthouse audit against built site | ||
audit: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
# Accessibility checks | ||
|
||
The accessibility checking tools can find a number of common HTML patterns which | ||
```{note} | ||
April-2023: we are currently | ||
[re-evaluating how we do accessibility checks](https://github.com/pydata/pydata-sphinx-theme/issues/1168) | ||
and reporting, so this may change soon. | ||
``` | ||
|
||
In general, accessibility-checking tools can find a limited number of common HTML patterns which | ||
assistive technology can't help users understand. | ||
We run a [Lighthouse](https://developers.google.com/web/tools/lighthouse) job in our CI/CD, which generates a "score" for all pages in our **Kitchen Sink** example documentation. | ||
The configuration for Lighthouse is in: | ||
|
||
- `.github/workflows/lighthouserc.json` | ||
## Accessibility checks as part of our development process | ||
|
||
We run a [Lighthouse](https://developers.google.com/web/tools/lighthouse) job in our CI/CD, which generates a "score" for all pages in our **Kitchen Sink** example documentation. | ||
The configuration for Lighthouse can be found in the `.github/workflows/lighthouserc.json` file. | ||
|
||
For more information about configuring lighthouse, see [the lighthouse documentation](https://github.com/GoogleChrome/lighthouse-ci/blob/main/docs/configuration.md). | ||
For more information about configuring Lighthouse, see [the Lighthouse documentation](https://github.com/GoogleChrome/lighthouse-ci/blob/main/docs/configuration.md). | ||
For more information about Accessibility in general, see [](../../user_guide/accessibility.rst). |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
|
||
nox -s docs -- -r | ||
""" | ||
import os | ||
import shutil as sh | ||
import tempfile | ||
from pathlib import Path | ||
|
@@ -87,7 +88,28 @@ def test(session: nox.Session) -> None: | |
if _should_install(session): | ||
session.install("-e", ".[test]") | ||
session.run(*split("pybabel compile -d src/pydata_sphinx_theme/locale -D sphinx")) | ||
session.run("pytest", *session.posargs) | ||
session.run("pytest", "-m", "not a11y", *session.posargs) | ||
|
||
|
||
@nox.session() | ||
def a11y(session: nox.Session) -> None: | ||
"""Run the accessibility test suite only.""" | ||
if _should_install(session): | ||
session.install("-e", ".[test]") | ||
# Install the drivers that Playwright needs to control the browsers. | ||
if os.environ.get("CI") or os.environ.get("GITPOD_WORKSPACE_ID"): | ||
# CI and other cloud environments are potentially missing system | ||
# dependencies, so we tell Playwright to also install the system | ||
# dependencies | ||
session.run("playwright", "install", "--with-deps") | ||
Comment on lines
+100
to
+104
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had initially removed this until I had to update the CI tests and realised I duplicated a lot of code trying to use Note: I am unsure if we should keep the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hadn't heard of Gitpod, but I wasn't confused :) I figured "probably some containerized thing" (I've since looked it up). |
||
else: | ||
# But most dev environments have the needed system dependencies | ||
session.run("playwright", "install") | ||
# Build the docs so we can run accessibility tests against them. | ||
session.run("nox", "-s", "docs") | ||
# The next step would be to open a server to the docs for Playwright, but | ||
# that is done in the test file, along with the accessibility checks. | ||
session.run("pytest", "-m", "a11y", *session.posargs) | ||
|
||
|
||
@nox.session(name="test-sphinx") | ||
|
gabalafou marked this conversation as resolved.
Show resolved
Hide resolved
gabalafou marked this conversation as resolved.
Show resolved
Hide resolved
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.