Skip to content
Open
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
15 changes: 9 additions & 6 deletions .github/workflows/accessibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,24 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: '18'
cache: npm

- name: Install dependencies
run: npm ci

- name: Install LHCI
run: npm install -g @lhci/cli@0.7
run: npm install -g @lhci/cli@0.14

- name: Run Lighthouse CI
env:
# allow LHCI to include branch info
LHCI_BUILD_CONTEXT__CURRENT_BRANCH: ${{ github.head_ref }}
run: |
# Run LHCI autorun; results uploaded to temporary public storage
# Tell LHCI where the static site files live (repo root)
lhci autorun --upload.target=temporary-public-storage --collect.staticDistDir=.
CHROME_PATH: /usr/bin/google-chrome-stable
run: lhci autorun

- name: Upload LHCI artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: lhci-report
path: ./.lighthouseci/**/*
if-no-files-found: ignore
26 changes: 13 additions & 13 deletions .github/workflows/axe-audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,29 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: '18'
cache: npm

- name: Install dependencies
run: npm install --no-audit --no-fund
run: npm ci

- name: Install Playwright browsers
run: npx playwright install --with-deps
run: npx playwright install --with-deps chromium

- name: Start static server
- name: Serve site and run axe audit
run: |
npm run start &
npx http-server -p 8000 -c-1 &
echo $! > server.pid

- name: Run axe audit
run: |
node axe-audit.js > axe-results.json || true
for i in $(seq 1 30); do
if curl -sf http://127.0.0.1:8000/ > /dev/null; then break; fi
sleep 1
done
npm run axe-audit
kill "$(cat server.pid)" 2>/dev/null || true
shell: bash

- name: Upload axe results
if: always()
uses: actions/upload-artifact@v4
with:
name: axe-results
path: axe-results.json

- name: Stop server
if: always()
run: |
kill $(cat server.pid) || true
93 changes: 55 additions & 38 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
push:
branches: [ main, master ]

permissions:
contents: read
pull-requests: write

jobs:
build-and-a11y:
name: Build & A11y checks
Expand All @@ -17,6 +21,7 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: '18'
cache: npm

- name: Install dependencies
run: npm ci
Expand All @@ -25,35 +30,55 @@ jobs:
run: npm audit --audit-level=low || true

- name: Serve site
run: python3 -m http.server 8000 & sleep 2
run: |
npx http-server -p 8000 -c-1 &
echo $! > server.pid
for i in $(seq 1 30); do
if curl -sf http://127.0.0.1:8000/ > /dev/null; then exit 0; fi
sleep 1
done
echo "Server did not become ready" >&2
exit 1
shell: bash

- name: Run pa11y
run: npx pa11y http://127.0.0.1:8000 --reporter json > pa11y.json || true
run: |
if npx pa11y http://127.0.0.1:8000 --reporter json > pa11y.json; then
:
else
echo '[]' > pa11y.json
fi
shell: bash

- name: Upload pa11y report
if: always()
uses: actions/upload-artifact@v4
with:
name: pa11y-report
path: pa11y.json

- name: Install Playwright browsers
run: npx playwright install --with-deps
run: npx playwright install --with-deps chromium

- name: Run axe audit (Playwright)
run: npm run axe-audit || true
run: npm run axe-audit

- name: Upload axe results (if any)
if: always()
uses: actions/upload-artifact@v4
with:
name: axe-results
path: |
axe-results.json
path: axe-results.json

- name: Stop server
if: always()
run: kill "$(cat server.pid)" 2>/dev/null || true
shell: bash

- name: Comment accessibility summary on PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v6
if: github.event_name == 'pull_request' && !cancelled()
continue-on-error: true
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
Expand All @@ -62,38 +87,30 @@ jobs:
let paCount = 'n/a';
let axeCount = 'n/a';
if (paExists) {
try { const pa = JSON.parse(fs.readFileSync('pa11y.json','utf8')); paCount = Array.isArray(pa) ? pa.length : (pa.issues? pa.issues.length : Object.keys(pa).length); } catch(e) { paCount = 'parse error'; }
try {
const pa = JSON.parse(fs.readFileSync('pa11y.json', 'utf8'));
paCount = Array.isArray(pa) ? pa.length : (pa.issues ? pa.issues.length : Object.keys(pa).length);
} catch (e) {
paCount = 'parse error';
}
}
if (axeExists) {
try { const axe = JSON.parse(fs.readFileSync('axe-results.json','utf8')); axeCount = (axe.violations && axe.violations.length) ? axe.violations.length : 0; } catch(e) { axeCount = 'parse error'; }
try {
const axe = JSON.parse(fs.readFileSync('axe-results.json', 'utf8'));
if (axe.error) {
axeCount = 'audit error';
} else {
axeCount = (axe.violations && axe.violations.length) ? axe.violations.length : 0;
}
} catch (e) {
axeCount = 'parse error';
}
}
const artifactsUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}/artifacts`;
const body = `Accessibility report summary:\n- Pa11y issues: ${paCount}\n- Axe violations: ${axeCount}\n\nDownload artifacts (pa11y.json, axe-results.json) from the workflow run: ${artifactsUrl}`;
await github.rest.issues.createComment({owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, body});

deploy:
name: Deploy to GitHub Pages
runs-on: ubuntu-latest
needs: build-and-a11y
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Install
run: npm ci

- name: Build (if applicable)
run: npm run build || true

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./
publish_branch: gh-pages
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body,
});
26 changes: 0 additions & 26 deletions .github/workflows/eleventy-gh-pages.yml

This file was deleted.

71 changes: 0 additions & 71 deletions .github/workflows/hugo-deploy.yml

This file was deleted.

51 changes: 0 additions & 51 deletions .github/workflows/jekyll-gh-pages.yml

This file was deleted.

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ _site/
.next
temitope-hospital-starter/out
node_modules
axe-results.json
pa11y.json
.lighthouseci/
server.pid
8 changes: 6 additions & 2 deletions axe-audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@ const path = require('path');

// write results to file so the workflow can upload them
fs.writeFileSync(outPath, JSON.stringify(results, null, 2));
console.log('WROTE_AXE_RESULTS', outPath);
const violationCount = Array.isArray(results.violations) ? results.violations.length : 0;
console.error(`Wrote axe results to ${outPath} (${violationCount} violations)`);
if (violationCount > 0) {
process.exitCode = 1;
}
} catch (err) {
console.error('Audit failed:', err && err.stack ? err.stack : err);
try {
fs.writeFileSync(outPath, JSON.stringify({ error: String(err) }, null, 2));
console.log('WROTE_AXE_RESULTS_ERROR', outPath);
console.error(`Wrote axe error to ${outPath}`);
} catch (e) {
console.error('Failed to write error file:', e && e.message ? e.message : e);
}
Expand Down
Loading
Loading