From 7419937f81f851e746a48fd4f2a3a765e46be2d6 Mon Sep 17 00:00:00 2001 From: Jonathan Wren Date: Sat, 7 Nov 2020 15:45:10 -0800 Subject: [PATCH] add initial a11y config for docs site --- .github/workflows/docs.yaml | 42 +++++++++++++++++++++++++++++++++++++ .github/workflows/pa11y.sh | 19 +++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 .github/workflows/docs.yaml create mode 100755 .github/workflows/pa11y.sh diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml new file mode 100644 index 00000000..83459e11 --- /dev/null +++ b/.github/workflows/docs.yaml @@ -0,0 +1,42 @@ +name: Docs + +on: + push: + branches: [ develop, release ] + pull_request: + branches: [ develop ] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python 3.9 + uses: actions/setup-python@v2 + with: + python-version: 3.9 + + - name: Setup Node.js environment + uses: actions/setup-node@main + + - name: poetry cache + uses: actions/cache@v2 + with: + path: .venv + key: ${{ runner.os }}-${{ hashFiles('poetry.lock') }}-${{ matrix.python-version }} + + - name: Install dependencies + run: | + pip install poetry + poetry config --local virtualenvs.in-project true + poetry install --no-root --remove-untracked + npm install pa11y + + - name: Start docs server + run: poetry run mkdocs serve & + + - name: Accessibility testing (Pa11y) + run: poetry run .github/workflows/pa11y.sh + diff --git a/.github/workflows/pa11y.sh b/.github/workflows/pa11y.sh new file mode 100755 index 00000000..b3d5abc3 --- /dev/null +++ b/.github/workflows/pa11y.sh @@ -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