Skip to content
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

axe api changes with more fine grained exceptions #26

Merged
merged 40 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
1e10e10
axe api changes with more fine grained exceptions
tonyfast Dec 20, 2023
d6629d4
raises correct exception
tonyfast Dec 20, 2023
cb468d4
raises type or tuple of types
tonyfast Dec 20, 2023
b5e6d5b
update settings test
tonyfast Dec 20, 2023
a2668ee
move exceptions to their own file
tonyfast Jan 8, 2024
7547cca
add hypothesis to gitignore
tonyfast Jan 8, 2024
b24cfa8
update git for pixi info
tonyfast May 25, 2024
7512a21
update locks
tonyfast May 25, 2024
0eb9683
add pixi
tonyfast May 25, 2024
20f9cbe
add a workflow that uses pixi
tonyfast May 25, 2024
82f9599
control ff install location
tonyfast May 25, 2024
9b21724
updates tests and dependencies
tonyfast May 25, 2024
62322fa
pad cell numbers
tonyfast May 25, 2024
cebeebb
exclude widegets from settings test
tonyfast May 25, 2024
44bce51
fix settings error
tonyfast May 25, 2024
1734f47
include window sin the tests
tonyfast May 25, 2024
7f83db0
rm raise expr
tonyfast May 25, 2024
9eaa46e
update pixi lock
tonyfast May 25, 2024
8b0ae93
skip ubuntu windows
tonyfast May 26, 2024
f90e9de
update pixi
tonyfast May 26, 2024
c180e69
add docs to pixi
tonyfast May 26, 2024
298bc1d
fix bad raise in test
tonyfast May 26, 2024
71fb7f5
update the artifact downloader
tonyfast May 26, 2024
bde5e3d
Merge branch 'pixi-manifest' into axe-api-improve
tonyfast May 28, 2024
187a2be
add scripts for extracting axe rules
tonyfast Jun 5, 2024
1bdd475
mv axe and testing utils
tonyfast Jun 6, 2024
5a13f4b
update tests
tonyfast Jun 6, 2024
58c8bb8
stricter test conditions
tonyfast Jun 6, 2024
8c85699
change w3c fixtures
tonyfast Jun 6, 2024
12d8328
bug in test
tonyfast Jun 6, 2024
4418afb
update tests
tonyfast Jun 7, 2024
b571e94
fix test and deprecation warning
tonyfast Jun 7, 2024
0259264
remove passing test
tonyfast Jun 7, 2024
b45e24b
updating tests to satisfy ci
tonyfast Jun 7, 2024
98edd25
drop old non pixi workflow
tonyfast Jun 7, 2024
6419cc7
rnm pixi test workflow
tonyfast Jun 7, 2024
097cd80
Merge branch 'pixi-manifest' into axe-api-improve
tonyfast Jun 7, 2024
f25f59a
squash old code
tonyfast Jun 7, 2024
7718356
add generate function for testing axe
tonyfast Jul 10, 2024
d0415be
add a test for the axe test tools
tonyfast Jul 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# GitHub syntax highlighting
pixi.lock linguist-language=YAML

109 changes: 109 additions & 0 deletions .github/workflows/pixi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: test with pixi

on:
push:
branches: [main]
pull_request:
branches: ["*"]
workflow_dispatch:

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

env:
PYTHONUNBUFFERED: "1"
PIP_DISABLE_PIP_VERSION_CHECK: "1"
USE_PIXI_VERSION: 0.22.0

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: prefix-dev/[email protected]
with:
pixi-version: v${{ env.USE_PIXI_VERSION }}
cache: true
environments: build
- run: pixi run -ve build build
- uses: actions/upload-artifact@v4
with:
name: nbconvert-a11y-${{ github.run_number }}-dist
path: ./dist

test:
name: (${{ matrix.os }}) test
needs: [build]
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os: ["ubuntu"]
# add matrix for browsers later on
steps:
- run: git config --global core.autocrlf false
- uses: actions/checkout@v4
- uses: prefix-dev/[email protected]
with:
pixi-version: v${{ env.USE_PIXI_VERSION }}
cache: true
environments: test
- uses: actions/download-artifact@v4
with:
name: nbconvert-a11y-${{ github.run_number }}-dist
path: ./dist
# need to make this install from the wheel
- run: pixi run -ve test test
- if: always()
uses: actions/upload-artifact@v4
with:
name: |-
nbconvert-a11y-${{ github.run_number }}-${{ matrix.os }}-test
path: |
./.pixi/task-cache-v0
./build/reports

docs:
name: docs
needs: [test]
runs-on: ubuntu-latest
steps:
- run: git config --global core.autocrlf false
- uses: actions/checkout@v4
- uses: prefix-dev/[email protected]
with:
pixi-version: v${{ env.USE_PIXI_VERSION }}
cache: true
environments: docs
- run: pixi run -ve docs build
- if: always()
uses: actions/upload-artifact@v4
with:
name: nbconvert-a11y-${{ github.run_number }}-site
path: site

publish:
name: publish the mkdocs build to github pages
needs: [docs]
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: nbconvert-a11y-${{ github.run_number }}-site
path: site
- name: Deploy main 🚀
uses: JamesIves/github-pages-deploy-action@v4
if: ${{ github.ref_name == 'main' }}
with:
folder: site # The folder the action should deploy.
single-commit: true
- name: Deploy non-main 🚀
uses: JamesIves/github-pages-deploy-action@v4
if: ${{ github.ref_name != 'main' }}
with:
folder: site # The folder the action should deploy.
single-commit: true
target-folder: branch/${{ github.ref_name }}
188 changes: 64 additions & 124 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,116 +1,98 @@
name: pytest nbconvert-a11y, axe test exports, build docs.
name: test with pixi

on:
push:
branches: [main]
pull_request:
branches: ['*']
branches: ["*"]
workflow_dispatch:

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

env:
# Increase this value to reset cache if environments have not changed
CACHE_NUMBER: 2
# squash some known warnings
JUPYTER_PLATFORM_DIRS: 1
PYTHONUNBUFFERED: "1"
PIP_DISABLE_PIP_VERSION_CHECK: "1"
USE_PIXI_VERSION: 0.22.0

jobs:
format:
name: format
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: prefix-dev/[email protected]
with:
fetch-depth: 0
- uses: actions/setup-python@v4
pixi-version: v${{ env.USE_PIXI_VERSION }}
cache: true
environments: build
- run: pixi run -ve build build
- uses: actions/upload-artifact@v4
with:
python-version: "3.12"
cache: pip
cache-dependency-path: pyproject.toml
- name: install dev dependencies
run: python -m pip install --upgrade pip hatch
- name: run formatters
run: |
echo "~~~bash" > "${GITHUB_STEP_SUMMARY}"
hatch run format:code 2>&1 | tee --append "${GITHUB_STEP_SUMMARY}"
echo "~~~" >> "${GITHUB_STEP_SUMMARY}"
- name: print diff
run: |
echo "~~~diff" >> "${GITHUB_STEP_SUMMARY}"
git diff | tee --append "${GITHUB_STEP_SUMMARY}"
echo "~~~" >> "${GITHUB_STEP_SUMMARY}"
name: nbconvert-a11y-${{ github.run_number }}-dist
path: ./dist

test:
name: test package and accessibility
defaults:
run:
shell: bash -el {0}
name: (${{ matrix.os }}) test
needs: [build]
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
python-version:
- "3.10"
runs-on: ubuntu-latest
os: ["ubuntu"]
# add matrix for browsers later on
steps:
- name: fetch all history and tags
uses: actions/checkout@v3
- run: git config --global core.autocrlf false
- uses: actions/checkout@v4
- uses: prefix-dev/[email protected]
with:
fetch-depth: 0
- uses: mamba-org/setup-micromamba@v1
pixi-version: v${{ env.USE_PIXI_VERSION }}
cache: true
environments: test
- uses: actions/download-artifact@v4
with:
environment-file: .github/test-environment.yml
- name: init plawright
run: |
playwright install --with-deps chromium
- name: init node & files
run: |
yarn
doit copy
- name: init dev module
run: |
python3 -m pip install -e . --no-deps --no-build-isolation --ignore-installed
- name: check pip env
run: |
python3 -m pip check
- name: smoke test
run: |
# the smoke generate html assets that are used in the accessibility testing.
# we run this script to generate assets and test the nbconvert-a11y module.
# failures here will stop any docs builds
pytest --color=yes tests/test_smoke.py
- name: build wheel and sdist
run: |
pyproject-build
- uses: actions/upload-artifact@v3
name: nbconvert-a11y-${{ github.run_number }}-dist
path: ./dist
# need to make this install from the wheel
- run: pixi run -ve test test
- if: always()
uses: actions/upload-artifact@v4
with:
name: dist
path: dist
- name: mkdocs
run: |
mkdocs build -v
- uses: actions/upload-artifact@v3
name: |-
nbconvert-a11y-${{ github.run_number }}-${{ matrix.os }}-test
path: |
./.pixi/task-cache-v0
./build/reports

docs:
name: docs
needs: [test]
runs-on: ubuntu-latest
steps:
- run: git config --global core.autocrlf false
- uses: actions/checkout@v4
- uses: prefix-dev/[email protected]
with:
pixi-version: v${{ env.USE_PIXI_VERSION }}
cache: true
environments: docs
- run: pixi run -ve docs build
- if: always()
uses: actions/upload-artifact@v4
with:
name: site
name: nbconvert-a11y-${{ github.run_number }}-site
path: site
- name: a11y tests
# always build the docs to see what the new versions look like.
# continue-on-error: true
run: |
pytest \
--color=yes \
-n auto \
--deselect tests/test_smoke.py \
--self-contained-html \
--html=tests/exports/pytest/report.html

publish:
name: publish the mkdocs build to github pages
needs: [test]
needs: [docs]
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: site
name: nbconvert-a11y-${{ github.run_number }}-site
path: site
- name: Deploy main 🚀
uses: JamesIves/github-pages-deploy-action@v4
Expand All @@ -125,45 +107,3 @@ jobs:
folder: site # The folder the action should deploy.
single-commit: true
target-folder: branch/${{ github.ref_name }}

release:
name: draft release when tagged
if: startsWith(github.ref, 'refs/tags/')
needs: [test]
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
steps:
- name: fetch contents
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: dist
path: dist
- uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: pip
cache-dependency-path: pyproject.toml
- name: install twine and pytest
run: |
pip install twine pytest
- name: Publish package distributions to TestPyPI
run: |
twine upload --repository testpypi \
--user __token__ --password ${{secrets.HATCH_TEST_INDEX_AUTH}} \
dist/*
- name: install nbconvert-a11y dependencies from test pip
run: |
pip install \
--index-url 'https://test.pypi.org/simple/' \
--extra-index-url 'https://pypi.org/simple/' \
nbconvert-a11y
- name: test test release
run: |
pytest tests/test_smoke.py
- uses: ncipollo/release-action@v1
with:
artifacts: "dist/.*"
draft: true # does not trigger a created event
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
.hypothesis
.pixi
.local-browsers


dist/
__pycache__
.#*
.doit.*
Expand All @@ -20,4 +26,4 @@ settings.json
site
tests/exports
tests/out.html
tests/outputs/*.html
tests/outputs/*.html
27 changes: 27 additions & 0 deletions nbconvert_a11y/axe/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# testing axe in python

the `test_axe` module provides utilities for running `axe-core` on html document in python. it is designed for asynchronous interactive use and synchronous testing with the `pytest_axe` extension.

`axe-core` is a javascript module that must be run inside of a live browser. currently, `playwright` is the only browser automation supporter, but `selenium` could be added.

<!-- can we add it to robots from jupyter after that? -->

## axe exceptions in python

each release contains a version of axe and a set of exceptions generated for that specific version.
the types are useful in accounting for expected accessibility that can be fixed later.

## playwright testing

it turns out the best ergonomics with working with axe from playwright are to append methods to the `Page` class. it has the following methods when `test_axe` is active:

`Page.axe`
: run axe and return the test results as a python dictionary

`Page.test_axe`
: run axe and return the test results as a python exception group

`Page.aom`
: an alias to the soon to be deprecated `page.accessibility.snapshot()`

we have to main synchronous and asynchronous methods for playwright
4 changes: 4 additions & 0 deletions nbconvert_a11y/axe/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .async_axe import *
from ..browsers import Browser
from .axe_exceptions import *
from .ipy import load_ipython_extension, unload_ipython_extension
Loading