Skip to content

Commit

Permalink
Merge pull request jupyterhub#3051 from manics/linkcheck-summarise-ou…
Browse files Browse the repository at this point in the history
…tput

Summarise linkcheck CI output
  • Loading branch information
consideRatio authored Mar 6, 2023
2 parents d21c790 + 25f8d6b commit 580ae79
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/test-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,8 @@ jobs:
run: |
cd docs
make linkcheck SPHINXOPTS='--color -W --keep-going'
- name: summarise linkcheck issues
if: always()
run: |
./ci/summarise-linkcheck-output ./docs/_build/linkcheck/output.json
23 changes: 23 additions & 0 deletions ci/summarise-linkcheck-output
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
# Parse the output.json created by the Sphinx linkchecker
# and summarise broken and redirected links

set -eu
LINKCHECK="$1"

N_BROKEN=$(jq -r 'select(.status=="broken")' "$LINKCHECK" | jq -s length)
N_PERMANENT_REDIRECT=$(jq -r 'select(.status=="redirected")' "$LINKCHECK" | jq -s length)

# shellcheck disable=SC2086
if [[ $N_BROKEN -gt 0 ]]; then
printf "\n\033[31;1m%s\033[0m\n" "Broken links"
jq -r 'select(.status=="broken") | "\(.filename):\(.lineno) \(.uri)\n \(.info)"' "$LINKCHECK"
fi

# shellcheck disable=SC2086
if [[ $N_PERMANENT_REDIRECT -gt 0 ]]; then
printf "\n\033[35;1m%s\033[0m\n" "Permanently redirected links"
jq -r 'select(.status=="redirected" and .code==301) | "\(.filename):\(.lineno) \(.uri)\n \(.info)"' "$LINKCHECK"
fi

exit "$N_BROKEN"

0 comments on commit 580ae79

Please sign in to comment.