Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

[Issue #40]: Setup pa11y-ci #12

[Issue #40]: Setup pa11y-ci

[Issue #40]: Setup pa11y-ci #12

name: pa11y tests
on:
pull_request:
paths:
- frontend/**
- .github/workflows/ci-frontend-a11y.yml
defaults:
run:
working-directory: ./frontend
env:
NODE_VERSION: 18
LOCKFILE_PATH: ./frontend/package-lock.json
PACKAGE_MANAGER: npm
jobs:
build:
name: Building site and running pa11y-ci tests
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache-dependency-path: ${{ env.LOCKFILE_PATH }}
cache: ${{ env.PACKAGE_MANAGER }}
- name: Install dependencies
run: npm ci
- name: Create screenshots directory
run: mkdir -p screenshots-output
- name: Start server
run: npm run dev &
- name: Wait for server to be ready
run: |
# Ensure the server wait script is executable
chmod +x ./bin/wait-for-frontend.sh
./bin/wait-for-frontend.sh
shell: bash
- name: Check server health
run: curl -I http://localhost:3000
- name: Run pa11y-ci
run: npm run test:pa11y 2>&1 | tee pa11y_output.txt
- name: Debug pa11y-ci failure
if: failure()
run: cat pa11y_output.txt || echo "pa11y_output.txt not found"
- name: Read pa11y_output file
id: pa11y_output
uses: juliangruber/read-file-action@v1
with:
path: ./pa11y_output.txt
- name: Comment on pull request
uses: thollander/actions-comment-pull-request@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
message: |
<details><summary>Pa11y testing results</summary>
```
${{ steps.pa11y_output.outputs.content }}
```
</details>
- name: Check for pa11y failures
if: contains(steps.pa11y_output.outputs.content, 'errno 2')
run: |
echo "::error::The site is failing accessibility tests. Please review the comment in the pull request or the pa11y-ci step in the workflow for details."
exit 1