-
Notifications
You must be signed in to change notification settings - Fork 130
92 lines (74 loc) Β· 2.82 KB
/
Copy pathaccessibility.yml
File metadata and controls
92 lines (74 loc) Β· 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: Accessibility Audit
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
jobs:
accessibility-audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
working-directory: ./frontend
run: npm ci --legacy-peer-deps
- name: Run contrast audit
working-directory: ./frontend
run: npm run audit:contrast
- name: Run Jest accessibility tests
working-directory: ./frontend
run: npm test -- --testPathPattern=accessibility
- name: Install Playwright browsers
working-directory: ./frontend
run: npx playwright install --with-deps chromium
- name: Run Playwright accessibility tests
working-directory: ./frontend
run: npm run test:a11y
- name: Upload accessibility test results
uses: actions/upload-artifact@v4
if: always()
with:
name: accessibility-results
path: |
frontend/test-results/
frontend/playwright-report/
frontend/audit-reports/
retention-days: 30
- name: Comment PR with accessibility results
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const path = require('path');
// Read contrast audit results
const auditDir = 'frontend/audit-reports';
if (fs.existsSync(auditDir)) {
const files = fs.readdirSync(auditDir);
const latestReport = files
.filter(f => f.startsWith('contrast-audit-'))
.sort()
.pop();
if (latestReport) {
const report = JSON.parse(fs.readFileSync(path.join(auditDir, latestReport), 'utf8'));
const comment = `## π¨ Accessibility Audit Results
**Contrast Compliance:** ${report.summary.passRate} (${report.summary.passed}/${report.summary.total} tests passed)
${report.failures.length > 0 ?
`### β Contrast Failures:\n${report.failures.map(f => `- ${f.name}: ${f.ratio}:1 (needs ${f.threshold}:1)`).join('\n')}` :
'### β
All contrast tests passed!'
}
Full report available in build artifacts.`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
}
}