Skip to content

Commit a2f4a05

Browse files
Merge pull request #333 from coding-for-reproducible-research/accessibility_assessment_complete
Complete Website Accessibility Check
2 parents 4a43282 + 65f4166 commit a2f4a05

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: pa11y-accessibility-check-all-website-html
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
accessibility_check_all_html:
8+
runs-on: ubuntu-latest
9+
container:
10+
image: mcr.microsoft.com/playwright:v1.42.1-jammy
11+
steps:
12+
- uses: actions/checkout@v3
13+
14+
- name: Set up Python 3.11
15+
uses: actions/setup-python@v4
16+
with:
17+
python-version: '3.11.6'
18+
19+
- name: Install Poetry
20+
run: |
21+
curl -sSL https://install.python-poetry.org | python3 -
22+
echo "$HOME/.local/bin" >> $GITHUB_PATH
23+
24+
- name: Install dependencies
25+
run: |
26+
export PATH="$HOME/.local/bin:$PATH"
27+
poetry install
28+
29+
- name: Cache executed notebooks
30+
uses: actions/cache@v4
31+
with:
32+
path: _build/.jupyter_cache
33+
key: jupyter-book-cache-${{ hashFiles('pyproject.toml') }}
34+
35+
- name: Build the book
36+
run: poetry run jupyter-book build .
37+
38+
- name: Install Node.js and dependencies
39+
run: |
40+
apt-get update
41+
apt-get install -y curl gnupg jq findutils
42+
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
43+
apt-get install -y nodejs
44+
npm install --save-dev pa11y-ci
45+
npx puppeteer browsers install chrome
46+
47+
- name: Find all HTML files
48+
id: list_html
49+
shell: bash
50+
run: |
51+
find _build/html -type f -name '*.html' | jq -R . | jq -s . > all_html_files.json
52+
echo "HTML files to check:"
53+
cat all_html_files.json
54+
55+
- name: Run Pa11y on all HTML files and save output
56+
id: run_pa11y
57+
shell: bash
58+
run: |
59+
num_files=$(jq length all_html_files.json)
60+
touch pa11y_output.md
61+
62+
if [ "$num_files" -eq 0 ]; then
63+
echo "No HTML files found to check." | tee pa11y_output.md
64+
else
65+
echo "### 🚦 Pa11y Accessibility Report" > pa11y_output.md
66+
echo "" >> pa11y_output.md
67+
68+
mapfile -t html_files < <(jq -r '.[]' all_html_files.json | sort -u)
69+
total_files=${#html_files[@]}
70+
71+
for i in "${!html_files[@]}"; do
72+
file="${html_files[$i]}"
73+
current_index=$((i + 1))
74+
echo "🔎 Checking $current_index of $total_files: $file"
75+
76+
echo "#### 📄 $file" >> pa11y_output.md
77+
echo '```' >> pa11y_output.md
78+
79+
result=$(npx pa11y-ci --reporter cli --config pa11yci.js "file://$(pwd)/$file" 2>&1 || true)
80+
echo "$result" >> pa11y_output.md
81+
echo '```' >> pa11y_output.md
82+
83+
echo "" >> pa11y_output.md
84+
done
85+
fi
86+
87+
- name: Upload Pa11y Report
88+
uses: actions/upload-artifact@v4
89+
with:
90+
name: pa11y-accessibility-report
91+
path: pa11y_output.md

0 commit comments

Comments
 (0)