Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/frontend-accessibility.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Frontend Accessibility (Lighthouse CI)

# Run on every push and pull request that touches the frontend or this workflow.
on:
push:
branches: [main, master]
paths:
- 'frontend/**'
- '.github/workflows/frontend-accessibility.yml'
pull_request:
branches: [main, master]
paths:
- 'frontend/**'
- '.github/workflows/frontend-accessibility.yml'

jobs:
lighthouse-accessibility:
name: Lighthouse Accessibility Audit
runs-on: ubuntu-latest

defaults:
run:
working-directory: frontend

steps:
# ── 1. Checkout ──────────────────────────────────────────────────────
- name: Checkout repository
uses: actions/checkout@v4

# ── 2. Node.js setup ─────────────────────────────────────────────────
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json

# ── 3. Install dependencies ───────────────────────────────────────────
- name: Install dependencies
run: npm ci

# ── 4. Build the frontend ─────────────────────────────────────────────
# Lighthouse CI needs a static build to audit; `npm run build` produces
# the ./dist directory referenced in lighthouserc.js.
- name: Build frontend
run: npm run build

# ── 5. Install Lighthouse CI ──────────────────────────────────────────
- name: Install @lhci/cli
run: npm install -g @lhci/cli@0.14.x

# ── 6. Run Lighthouse CI ──────────────────────────────────────────────
# Uses frontend/lighthouserc.js which asserts categories:accessibility >= 0.90.
# The step fails (exit code 1) if the score drops below the threshold,
# blocking the PR from merging.
- name: Run Lighthouse CI
run: lhci autorun --config=./lighthouserc.js
env:
LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}

# ── 7. Upload Lighthouse report as artifact ───────────────────────────
- name: Upload Lighthouse results
if: always()
uses: actions/upload-artifact@v4
with:
name: lighthouse-accessibility-report
path: frontend/.lighthouseci/
retention-days: 30
29 changes: 29 additions & 0 deletions frontend/lighthouserc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Lighthouse CI configuration for the Checkmate-Escrow frontend.
*
* Enforces a minimum accessibility score of 90 so that any PR that
* regresses the frontend's WCAG compliance is caught before it merges.
*
* @see https://github.com/GoogleChrome/lighthouse-ci/blob/main/docs/configuration.md
*/

export default {
ci: {
collect: {
// Build the Vite app and serve the static output locally.
staticDistDir: './dist',
// Run three passes and take the median to reduce score variance.
numberOfRuns: 3,
},
assert: {
assertions: {
// Fail the CI run if the accessibility score drops below 0.90 (90/100).
'categories:accessibility': ['error', { minScore: 0.9 }],
},
},
upload: {
// Store results as GitHub Actions artifacts — no external LHCI server needed.
target: 'temporary-public-storage',
},
},
};
Loading