This repository has been archived by the owner on Sep 18, 2024. It is now read-only.
[Issue #40]: Setup pa11y-ci #7
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ./wait-for-frontend.sh | |
./wait-for-frontend.sh | |
shell: bash | |
- name: Run pa11y-ci | |
run: npm run test:pa11y 2>&1 | tee pa11y_output.txt | |
- 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 |