Change approach for docs workflow to use pa11y-ci (#1116)

The previous plugin looked nice with the comments and annotations, but
apparently doesn't work for PRs. It can only run on the pr target (our
branch), which means that the tests are never actually run against the
new code.

As you can guess, this is pretty useless for PRs. So, this PR fixes
that, and uses the very nice pa11y-ci (instead of the normal pa11y).
While it doesn't upload annotations, the output is very readable and
seems like the best we're going to get.
This commit is contained in:
Jonathan Wren 2020-12-19 12:00:59 -08:00 committed by GitHub
parent 2ac883abb6
commit 12e39ffd61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,7 +9,7 @@ on:
- 'mkdocs.yml'
- 'readthedocs.yml'
- '.github/workflows/docs.yaml'
pull_request_target:
pull_request:
branches: [ develop ]
paths:
- 'docs/**'
@ -40,64 +40,29 @@ jobs:
path: .venv
key: ${{ runner.os }}-${{ hashFiles('poetry.lock') }}-${{ matrix.python-version }}
- name: npm cache
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-pa11y-v3
- name: Install dependencies
run: |
pip install poetry
poetry config --local virtualenvs.in-project true
poetry install --no-root --remove-untracked
npm install pa11y pa11y-reporter-junit
npm install pa11y-ci
echo "node_modules/.bin" >> $GITHUB_PATH
- name: Start docs server
run: poetry run mkdocs serve &
- name: Accessibility testing (Pa11y)
- name: Generate sitemap
env:
site_url: http://127.0.0.1:8000
exit_code: 0
run: |
set +e
poetry run mkdocs build
mkdir -p "reports"
printf -- 'scanning: /\n'
./node_modules/.bin/pa11y "$site_url" --reporter junit > "reports/root.xml" || exit_code=2
for file in $(poetry run 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/$file.xml" || exit_code=2
done
exit $exit_code
- name: Upload Unit Test Results
if: always()
uses: actions/upload-artifact@v2
with:
name: Unit Test Results (pa11y)
path: reports/*.xml
publish-test-results:
if: success() || failure()
name: "Publish Unit Tests Results"
needs: accessibility
runs-on: ubuntu-latest
steps:
- name: Download Artifacts
uses: actions/download-artifact@v2
with:
path: artifacts
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v1.4
if: success() || failure()
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
check_name: Unit Test Results
hide_comments: all but latest
comment_on_pr: true
files: '**/*.xml'
report_individual_runs: true
deduplicate_classes_by_file_name: false
select="{urls: [\"${site_url}/\", .urlset.url[].loc]}"
curl -s "$site_url/sitemap.xml" | poetry run xq "$select" > list.json
- name: Accessibility testing (Pa11y)
run: pa11y-ci -c list.json