Skip to content

Accessibility Tests #193

Accessibility Tests

Accessibility Tests #193

Workflow file for this run

name: Accessibility Tests
on:
push:
branches: [main, develop]
paths: ['components/**', 'frontend/**', 'testing/accessibility/**']
pull_request:
branches: [main, develop]
schedule:
- cron: '0 3 * * 1' # Weekly Monday 03:00 UTC
concurrency:
group: a11y-${{ github.ref }}
cancel-in-progress: true
jobs:
automated-a11y:
name: Automated A11y (axe-core)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install root dependencies
run: npm ci
- name: Install a11y test dependencies
run: npm ci
working-directory: testing/accessibility
- name: Run automated accessibility tests
run: npm run test:ci
working-directory: testing/accessibility
env:
GITHUB_SHA: ${{ github.sha }}
- name: Generate accessibility report
run: node scripts/generate-a11y-report.js
working-directory: testing/accessibility
if: always()
- name: Upload accessibility reports
uses: actions/upload-artifact@v4
if: always()
with:
name: a11y-reports-${{ github.run_number }}
path: testing/accessibility/reports/
retention-days: 60
frontend-a11y:
name: Frontend A11y Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install frontend dependencies
run: npm ci
working-directory: frontend
- name: Run existing frontend a11y tests
run: node tests/a11y.test.js
working-directory: frontend
continue-on-error: true
- name: Upload frontend a11y report
uses: actions/upload-artifact@v4
if: always()
with:
name: frontend-a11y-report-${{ github.run_number }}
path: frontend/ACCESSIBILITY_REPORT.txt
retention-days: 60
comment-a11y:
name: Comment A11y Results
runs-on: ubuntu-latest
needs: [automated-a11y, frontend-a11y]
if: github.event_name == 'pull_request' && always()
permissions:
pull-requests: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: a11y-reports-*
merge-multiple: true
path: reports/
- name: Post a11y summary
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const p = 'reports/a11y-results.json';
if (!fs.existsSync(p)) return;
const { summary, meta } = JSON.parse(fs.readFileSync(p, 'utf-8'));
const icon = summary.failed === 0 ? '✅' : '❌';
const body = [
`### ${icon} Accessibility Tests (WCAG 2.1 AA)`,
'',
`| Metric | Value |`,
`|--------|-------|`,
`| Total | ${summary.total} |`,
`| Passed | ${summary.passed} |`,
`| Failed | ${summary.failed} |`,
`| Pass Rate | ${summary.pass_rate}% |`,
'',
summary.failed > 0
? '⚠ Accessibility violations detected. Review the uploaded report artifact.'
: '_All automated accessibility checks passed._',
].join('\n');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body,
});