-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #657 from w3bdesign/dev
♿️ access: add pa11y automated accessibility testing workflow
- Loading branch information
Showing
3 changed files
with
122 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
name: Accessibility Tests | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
pa11y: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
|
||
- name: Install pnpm | ||
uses: pnpm/action-setup@v2 | ||
with: | ||
version: 8 | ||
run_install: false | ||
|
||
- name: Get pnpm store directory | ||
shell: bash | ||
run: | | ||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | ||
- name: Setup pnpm cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ env.STORE_PATH }} | ||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-pnpm-store- | ||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: Install dependencies and pa11y | ||
run: | | ||
pnpm add -D pa11y wait-on | ||
# Create pa11y config file | ||
echo '{"chromeLaunchConfig":{"args":["--no-sandbox"]}}' > .pa11y.json | ||
- name: Build Next.js app | ||
run: pnpm build | ||
|
||
- name: Start Next.js app | ||
run: pnpm start & | ||
|
||
- name: Wait for the application to be ready | ||
run: pnpm exec wait-on http://localhost:3000 | ||
|
||
- name: Run pa11y | ||
run: | | ||
# Create a directory for the reports | ||
mkdir -p pa11y-reports | ||
# Run pa11y on main pages with config | ||
pnpm exec pa11y --config .pa11y.json http://localhost:3000 > pa11y-reports/home.txt || true | ||
pnpm exec pa11y --config .pa11y.json http://localhost:3000/cv > pa11y-reports/cv.txt || true | ||
pnpm exec pa11y --config .pa11y.json http://localhost:3000/prosjekter > pa11y-reports/prosjekter.txt || true | ||
pnpm exec pa11y --config .pa11y.json http://localhost:3000/kontakt > pa11y-reports/kontakt.txt || true | ||
- name: Upload pa11y results | ||
if: always() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: pa11y-reports | ||
path: pa11y-reports/ | ||
|
||
- name: Check for accessibility issues | ||
run: | | ||
if grep -q "Error:" pa11y-reports/*.txt; then | ||
echo "Accessibility issues found. Check the uploaded artifacts for details." | ||
exit 1 | ||
fi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"defaults": { | ||
"standard": "WCAG2AA", | ||
"timeout": 30000, | ||
"wait": 1000, | ||
"viewport": { | ||
"width": 1280, | ||
"height": 800 | ||
}, | ||
"ignore": [ | ||
"WCAG2AA.Principle1.Guideline1_4.1_4_3.G18.Fail" | ||
], | ||
"chromeLaunchConfig": { | ||
"args": ["--no-sandbox"] | ||
} | ||
}, | ||
"urls": [ | ||
{ | ||
"url": "http://localhost:3000", | ||
"screenCapture": "pa11y-reports/home.png" | ||
}, | ||
{ | ||
"url": "http://localhost:3000/cv", | ||
"screenCapture": "pa11y-reports/cv.png" | ||
}, | ||
{ | ||
"url": "http://localhost:3000/prosjekter", | ||
"screenCapture": "pa11y-reports/prosjekter.png" | ||
}, | ||
{ | ||
"url": "http://localhost:3000/kontakt", | ||
"screenCapture": "pa11y-reports/kontakt.png" | ||
} | ||
] | ||
} |
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