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

a11y doc github action check #217

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from
Draft
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
59 changes: 59 additions & 0 deletions .github/workflows/check_a11y_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: check a11y docs

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
a11y:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'

- name: Set up Chrome
id: setup-chrome
uses: browser-actions/setup-chrome@v1
with:
install-chromedriver: true

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install '.[dev]'
# install ChromeDriver
npx browser-driver-manager install chrome
# copy chromedriver path to ENV variable
echo "CHROMEDRIVER-PATH=$CHROMEDRIVER_TEST_PATH" >> $GITHUB_ENV

- name: Build public documentation
run: |
export DB_URI="sqlite:///:memory:"
export INITIAL_ALGORITHMS=""
export VERSION=${{ env.NEXT_TAG }}
./scripts/build_docs.sh _site

- name: Serve documentation
run: |
# run npx serve in the background to serve the _site directory
npx serve _site & npx wait-on http://localhost:3000

- name: Run accessibility checks
run: |
npm install -g @axe-core/cli
# for every recursively nested *.html file in _site, run a11y checks
for file in $(find _site -name '*.html'); do
path=${file#_site/}
echo "path to check: ${path}"
echo "driver path: ${{ env.CHROMEDRIVER-PATH }}"
axe --exit --tags wcag2aa --load-delay 1500 http://127.0.0.1:3000/$path
done
1 change: 1 addition & 0 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
site_name: !ENV [SITE_NAME, 'RecordLinker Documentation']
site_url: !ENV [SITE_URL, 'http://localhost:3000']
theme:
name: "material"
icon:
Expand Down
4 changes: 2 additions & 2 deletions scripts/build_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ VERSION=${VERSION:-$(python -c "from recordlinker._version import __version__; p
SITE_NAME="RecordLinker Documentation (${VERSION})"

SITE_NAME=${SITE_NAME} mkdocs build --config-file docs/mkdocs.yml -d "../${OUT}"
python -m recordlinker.utils.openapi_schema > ${OUT}/openapi.json
npx @redocly/cli build-docs -t docs/api_template.hbs -o "${OUT}/api-docs.html" "${OUT}/openapi.json"
python -m recordlinker.utils.openapi_schema > "${OUT}/openapi.json"
npx @redocly/cli build-docs -t docs/api_template.hbs -o "${OUT}/api-docs.html" "${OUT}/openapi.json"
Loading