forked from Xoulomon/Stellar-Save
-
Notifications
You must be signed in to change notification settings - Fork 0
224 lines (190 loc) · 7.21 KB
/
Copy pathaccessibility.yml
File metadata and controls
224 lines (190 loc) · 7.21 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
name: Accessibility Testing
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
jobs:
# ─── Unit-level axe-core accessibility tests (Vitest + jest-axe) ────────────
axe-unit:
name: axe-core Component Tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
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
run: npm ci
- name: Run accessibility unit tests
run: npm run test:a11y:ci
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: a11y-unit-results
path: frontend/test-results/
retention-days: 30
# ─── Pa11y full-page WCAG 2.1 AA scan ───────────────────────────────────────
pa11y:
name: Pa11y WCAG 2.1 AA Scan
runs-on: ubuntu-latest
needs: axe-unit
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 frontend dependencies
run: npm ci
working-directory: frontend
- name: Build frontend
run: npm run build
working-directory: frontend
- name: Install pa11y-ci
run: npm install -g pa11y-ci@3.1.0
- name: Start preview server
run: |
nohup npm run preview -- --host 127.0.0.1 --port 4173 > /tmp/pa11y-server.log 2>&1 &
echo $! > /tmp/pa11y-server.pid
# Wait for server to be ready
timeout 30 bash -c 'until curl -sf http://127.0.0.1:4173 > /dev/null; do sleep 1; done'
working-directory: frontend
- name: Create screenshots directory
run: mkdir -p frontend/pa11y-screenshots
- name: Run Pa11y CI scan
run: pa11y-ci --config frontend/.pa11yrc.json
continue-on-error: true
id: pa11y_scan
- name: Stop preview server
if: always()
run: |
PID=$(cat /tmp/pa11y-server.pid 2>/dev/null || echo "")
[ -n "$PID" ] && kill "$PID" || true
- name: Upload Pa11y screenshots
uses: actions/upload-artifact@v4
if: always()
with:
name: pa11y-screenshots
path: frontend/pa11y-screenshots/
retention-days: 30
- name: Upload Pa11y server log
uses: actions/upload-artifact@v4
if: always()
with:
name: pa11y-server-log
path: /tmp/pa11y-server.log
retention-days: 7
- name: Fail if Pa11y found errors
if: steps.pa11y_scan.outcome == 'failure'
run: |
echo "::error::Pa11y found WCAG 2.1 AA violations. Review the uploaded screenshots and logs."
exit 1
# ─── Lighthouse accessibility audit ─────────────────────────────────────────
lighthouse-a11y:
name: Lighthouse Accessibility Audit
runs-on: ubuntu-latest
needs: axe-unit
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 frontend dependencies
run: npm ci
working-directory: frontend
- name: Build frontend
run: npm run build
working-directory: frontend
- name: Start preview server
run: |
cd frontend
nohup npm run preview -- --host 127.0.0.1 --port 4173 > /tmp/lhci-a11y.log 2>&1 &
echo $! > /tmp/lhci-server.pid
timeout 30 bash -c 'until curl -sf http://127.0.0.1:4173 > /dev/null; do sleep 1; done'
- name: Run Lighthouse accessibility audit
run: |
npx lhci autorun \
--collect.url=http://127.0.0.1:4173 \
--collect.numberOfRuns=1 \
--assert.assertions.accessibility=["error",{"minScore":0.9}] \
--assert.assertions.best-practices=["warn",{"minScore":0.8}] \
--upload.target=filesystem \
--upload.outputDir=/tmp/lhci-results
continue-on-error: true
id: lhci_a11y
- name: Stop preview server
if: always()
run: |
PID=$(cat /tmp/lhci-server.pid 2>/dev/null || echo "")
[ -n "$PID" ] && kill "$PID" || true
- name: Upload Lighthouse results
uses: actions/upload-artifact@v4
if: always()
with:
name: lighthouse-a11y-results
path: /tmp/lhci-results/
retention-days: 30
- name: Comment Lighthouse score on PR
if: github.event_name == 'pull_request' && always()
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const resultsDir = '/tmp/lhci-results';
let comment = '## ♿ Lighthouse Accessibility Audit\n\n';
try {
const files = fs.readdirSync(resultsDir);
const manifestFile = files.find(f => f === 'manifest.json');
if (manifestFile) {
const manifest = JSON.parse(fs.readFileSync(`${resultsDir}/${manifestFile}`, 'utf8'));
const run = manifest[0];
if (run && run.summary) {
const score = Math.round(run.summary.accessibility * 100);
const emoji = score >= 90 ? '✅' : score >= 70 ? '⚠️' : '❌';
comment += `${emoji} **Accessibility Score: ${score}/100**\n\n`;
comment += `> Minimum required: 90/100\n\n`;
comment += `[View full report](${run.url})\n`;
}
}
} catch (e) {
comment += `_Could not parse Lighthouse results: ${e.message}_\n`;
}
if (context.payload.pull_request) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: comment,
});
}
# ─── Summary gate ────────────────────────────────────────────────────────────
a11y-gate:
name: Accessibility Gate
runs-on: ubuntu-latest
needs: [axe-unit, pa11y, lighthouse-a11y]
if: always()
steps:
- name: Check all accessibility jobs passed
run: |
if [ "${{ needs.axe-unit.result }}" != "success" ]; then
echo "::error::axe-core unit tests failed"
exit 1
fi
if [ "${{ needs.pa11y.result }}" != "success" ]; then
echo "::error::Pa11y WCAG scan failed"
exit 1
fi
echo "✅ All accessibility checks passed"