Skip to content

Commit 580ae79

Browse files
authored
Merge pull request #3051 from manics/linkcheck-summarise-output
Summarise linkcheck CI output
2 parents d21c790 + 25f8d6b commit 580ae79

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

.github/workflows/test-docs.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,8 @@ jobs:
4343
run: |
4444
cd docs
4545
make linkcheck SPHINXOPTS='--color -W --keep-going'
46+
47+
- name: summarise linkcheck issues
48+
if: always()
49+
run: |
50+
./ci/summarise-linkcheck-output ./docs/_build/linkcheck/output.json

ci/summarise-linkcheck-output

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
# Parse the output.json created by the Sphinx linkchecker
3+
# and summarise broken and redirected links
4+
5+
set -eu
6+
LINKCHECK="$1"
7+
8+
N_BROKEN=$(jq -r 'select(.status=="broken")' "$LINKCHECK" | jq -s length)
9+
N_PERMANENT_REDIRECT=$(jq -r 'select(.status=="redirected")' "$LINKCHECK" | jq -s length)
10+
11+
# shellcheck disable=SC2086
12+
if [[ $N_BROKEN -gt 0 ]]; then
13+
printf "\n\033[31;1m%s\033[0m\n" "Broken links"
14+
jq -r 'select(.status=="broken") | "\(.filename):\(.lineno) \(.uri)\n \(.info)"' "$LINKCHECK"
15+
fi
16+
17+
# shellcheck disable=SC2086
18+
if [[ $N_PERMANENT_REDIRECT -gt 0 ]]; then
19+
printf "\n\033[35;1m%s\033[0m\n" "Permanently redirected links"
20+
jq -r 'select(.status=="redirected" and .code==301) | "\(.filename):\(.lineno) \(.uri)\n \(.info)"' "$LINKCHECK"
21+
fi
22+
23+
exit "$N_BROKEN"

0 commit comments

Comments
 (0)