|
| 1 | +name: Accessibility Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, develop] |
| 6 | + paths: ['components/**', 'frontend/**', 'testing/accessibility/**'] |
| 7 | + pull_request: |
| 8 | + branches: [main, develop] |
| 9 | + schedule: |
| 10 | + - cron: '0 3 * * 1' # Weekly Monday 03:00 UTC |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: a11y-${{ github.ref }} |
| 14 | + cancel-in-progress: true |
| 15 | + |
| 16 | +jobs: |
| 17 | + automated-a11y: |
| 18 | + name: Automated A11y (axe-core) |
| 19 | + runs-on: ubuntu-latest |
| 20 | + |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - uses: actions/setup-node@v4 |
| 25 | + with: |
| 26 | + node-version: '20' |
| 27 | + cache: 'npm' |
| 28 | + |
| 29 | + - name: Install root dependencies |
| 30 | + run: npm ci |
| 31 | + |
| 32 | + - name: Install a11y test dependencies |
| 33 | + run: npm ci |
| 34 | + working-directory: testing/accessibility |
| 35 | + |
| 36 | + - name: Run automated accessibility tests |
| 37 | + run: npm run test:ci |
| 38 | + working-directory: testing/accessibility |
| 39 | + env: |
| 40 | + GITHUB_SHA: ${{ github.sha }} |
| 41 | + |
| 42 | + - name: Generate accessibility report |
| 43 | + run: node scripts/generate-a11y-report.js |
| 44 | + working-directory: testing/accessibility |
| 45 | + if: always() |
| 46 | + |
| 47 | + - name: Upload accessibility reports |
| 48 | + uses: actions/upload-artifact@v4 |
| 49 | + if: always() |
| 50 | + with: |
| 51 | + name: a11y-reports-${{ github.run_number }} |
| 52 | + path: testing/accessibility/reports/ |
| 53 | + retention-days: 60 |
| 54 | + |
| 55 | + frontend-a11y: |
| 56 | + name: Frontend A11y Tests |
| 57 | + runs-on: ubuntu-latest |
| 58 | + |
| 59 | + steps: |
| 60 | + - uses: actions/checkout@v4 |
| 61 | + |
| 62 | + - uses: actions/setup-node@v4 |
| 63 | + with: |
| 64 | + node-version: '20' |
| 65 | + cache: 'npm' |
| 66 | + |
| 67 | + - name: Install frontend dependencies |
| 68 | + run: npm ci |
| 69 | + working-directory: frontend |
| 70 | + |
| 71 | + - name: Run existing frontend a11y tests |
| 72 | + run: node tests/a11y.test.js |
| 73 | + working-directory: frontend |
| 74 | + continue-on-error: true |
| 75 | + |
| 76 | + - name: Upload frontend a11y report |
| 77 | + uses: actions/upload-artifact@v4 |
| 78 | + if: always() |
| 79 | + with: |
| 80 | + name: frontend-a11y-report-${{ github.run_number }} |
| 81 | + path: frontend/ACCESSIBILITY_REPORT.txt |
| 82 | + retention-days: 60 |
| 83 | + |
| 84 | + comment-a11y: |
| 85 | + name: Comment A11y Results |
| 86 | + runs-on: ubuntu-latest |
| 87 | + needs: [automated-a11y, frontend-a11y] |
| 88 | + if: github.event_name == 'pull_request' && always() |
| 89 | + permissions: |
| 90 | + pull-requests: write |
| 91 | + |
| 92 | + steps: |
| 93 | + - uses: actions/download-artifact@v4 |
| 94 | + with: |
| 95 | + pattern: a11y-reports-* |
| 96 | + merge-multiple: true |
| 97 | + path: reports/ |
| 98 | + |
| 99 | + - name: Post a11y summary |
| 100 | + uses: actions/github-script@v7 |
| 101 | + with: |
| 102 | + script: | |
| 103 | + const fs = require('fs'); |
| 104 | + const p = 'reports/a11y-results.json'; |
| 105 | + if (!fs.existsSync(p)) return; |
| 106 | + const { summary, meta } = JSON.parse(fs.readFileSync(p, 'utf-8')); |
| 107 | + const icon = summary.failed === 0 ? '✅' : '❌'; |
| 108 | + const body = [ |
| 109 | + `### ${icon} Accessibility Tests (WCAG 2.1 AA)`, |
| 110 | + '', |
| 111 | + `| Metric | Value |`, |
| 112 | + `|--------|-------|`, |
| 113 | + `| Total | ${summary.total} |`, |
| 114 | + `| Passed | ${summary.passed} |`, |
| 115 | + `| Failed | ${summary.failed} |`, |
| 116 | + `| Pass Rate | ${summary.pass_rate}% |`, |
| 117 | + '', |
| 118 | + summary.failed > 0 |
| 119 | + ? '⚠ Accessibility violations detected. Review the uploaded report artifact.' |
| 120 | + : '_All automated accessibility checks passed._', |
| 121 | + ].join('\n'); |
| 122 | + github.rest.issues.createComment({ |
| 123 | + issue_number: context.issue.number, |
| 124 | + owner: context.repo.owner, |
| 125 | + repo: context.repo.repo, |
| 126 | + body, |
| 127 | + }); |
0 commit comments