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

Add accessibility testing for docs site (http://jrnl.sh) #1067

Merged
merged 1 commit into from
Oct 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
35 changes: 34 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ executors:

python39:
docker:
- image: circleci/python:3.9.0
- image: cimg/python:3.9.0
resource_class: small

with_browser:
docker:
- image: cimg/python:3.9.0-browsers
resource_class: small

commands:
Expand All @@ -34,6 +39,18 @@ commands:
paths:
- ~/project/.venv

install_pa11y:
steps:
- restore_cache:
key: deps-00-pa11y
- run:
name: Install accessibility software (pa11y)
command: npm install pa11y pa11y-reporter-junit
- save_cache:
key: deps-00-pa11y
paths:
- ~/project/node_modules

pytest:
steps:
- run:
Expand Down Expand Up @@ -107,10 +124,26 @@ jobs:
- get_poetry_deps
- lint

docs_a11y:
executor: with_browser
steps:
- checkout
- get_poetry_deps
- install_pa11y
- run:
name: Starting mkdocs server
command: poetry run mkdocs serve
background: true
- run: poetry run .circleci/pa11y.sh
- store_test_results:
path: reports

workflows:
version: 2
main:
jobs:
- docs_a11y:
name: Documentation site (jrnl.sh) accessibility
- linting:
name: Linting and Formatting
- test_37_linux:
Expand Down
19 changes: 19 additions & 0 deletions .circleci/pa11y.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#! /bin/bash
set +e

reports_dir="reports/pa11y"
site_url="http://127.0.0.1:8000"
exit_code=0

mkdocs build
mkdir -p "$reports_dir"

printf -- 'scanning: /\n'
./node_modules/.bin/pa11y "$site_url" --reporter junit > "$reports_dir/root.xml" || exit_code=2

for file in $(xq '.urlset.url[].loc' site/sitemap.xml -r | sed -r 's!https://jrnl.sh/(.*?)/$!\1!'); do
printf -- 'scanning: /%s\n' "$file"
./node_modules/.bin/pa11y "$site_url/$file" --reporter junit > "$reports_dir/$file.xml" || exit_code=2
done

exit $exit_code
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
site_name: jrnl
site_url: https://jrnl.sh
theme:
name: readthedocs
custom_dir: docs/theme
Expand Down
Loading