Skip to content

Commit ef2c80f

Browse files
Merge pull request #335 from coding-for-reproducible-research/accessibility_assessment_complete
Add complete accessibility assessment without double computation
2 parents e3e4ece + 7624948 commit ef2c80f

File tree

1 file changed

+32
-22
lines changed

1 file changed

+32
-22
lines changed

.github/workflows/accessibility_complete.yml

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,50 +51,60 @@ jobs:
5151
npm install --save-dev pa11y-ci
5252
npx puppeteer browsers install chrome
5353
54-
- name: Identify all HTML files in _build/html
54+
- name: Identify HTML files with corresponding .md or .ipynb source
5555
id: map_html_targets
5656
shell: bash
5757
run: |
58-
find _build/html -type f -name '*.html' | jq -R . | jq -s . > pa11y_targets.json
58+
echo "[" > pa11y_targets.json
59+
first=true
60+
61+
# Find all .md and .ipynb files (excluding hidden and irrelevant folders)
62+
find . -type f \( -name "*.md" -o -name "*.ipynb" \) ! -path "./.*" ! -path "./_build/*" | while read -r source; do
63+
# Strip leading ./ and extension
64+
relative_path="${source#./}"
65+
base_path="${relative_path%.*}"
66+
67+
# Match corresponding HTML file in _build/html
68+
html_path="_build/html/${base_path}.html"
69+
if [[ -f "$html_path" ]]; then
70+
if [ "$first" = true ]; then
71+
first=false
72+
else
73+
echo "," >> pa11y_targets.json
74+
fi
75+
echo "\"$html_path\"" >> pa11y_targets.json
76+
fi
77+
done
78+
79+
echo "]" >> pa11y_targets.json
80+
5981
echo "Generated pa11y_targets.json:"
6082
cat pa11y_targets.json
6183
6284
63-
- name: Run Pa11y CI on changed pages only and save output
85+
- name: Run Pa11y CI once on all targets and save output
6486
id: run_pa11y
6587
shell: bash
6688
run: |
67-
num_files=$(jq length pa11y_targets.json)
6889
touch pa11y_output.md
6990
91+
num_files=$(jq length pa11y_targets.json)
7092
if [ "$num_files" -eq 0 ]; then
7193
echo "No relevant HTML files to check. Skipping Pa11y." | tee pa11y_output.md
7294
else
7395
echo "### 🚦 Pa11y Accessibility Report" > pa11y_output.md
7496
echo "" >> pa11y_output.md
7597
76-
mapfile -t html_files < <(jq -r '.[]' pa11y_targets.json | sort -u)
77-
total_files=${#html_files[@]}
78-
79-
for i in "${!html_files[@]}"; do
80-
file="${html_files[$i]}"
81-
current_index=$((i + 1))
82-
echo "🔎 Checking $current_index of $total_files: $file"
98+
# Run pa11y-ci once on all files in pa11y_targets.json
99+
result=$(npx pa11y-ci --reporter cli --config pa11yci.js 2>&1 || true)
100+
echo "$result" >> pa11y_output.md
83101
84-
echo "#### 📄 $file" >> pa11y_output.md
85-
echo '```' >> pa11y_output.md
86-
87-
result=$(npx pa11y-ci --reporter cli --config pa11yci.js "file://$(pwd)/$file" 2>&1 || true)
88-
echo "$result" >> pa11y_output.md
89-
echo '```' >> pa11y_output.md
90-
91-
base=$(basename "$file" .html)
92-
echo "_⚠️ Any errors likely originates from the source file (e.g., \`filename.md\`, \`filename.ipynb\`) used to generate the HTML._" >> pa11y_output.md
93-
echo "" >> pa11y_output.md
94-
done
102+
echo "" >> pa11y_output.md
103+
echo "_⚠️ Any errors likely originate from the source file (e.g., \`filename.md\`, \`filename.ipynb\`)._" >> pa11y_output.md
95104
fi
96105
97106
107+
98108
- name: 🔍 Debug comment body
99109
run: |
100110
echo "------- BEGIN COMMENT BODY -------"

0 commit comments

Comments
 (0)