Skip to content

Commit a673233

Browse files
committed
build: Make linkchecker handle HTTP redirects gracefully
Since linkchecker 10.3.0, external links that are being redirected (that is, they result in HTTP 301 or 302, rather than 200) result in a warning. Since we are running linkchecker in strict mode (that is, not ignoring warnings), this means the link check now fails on such links. This is not good, however it would also not be good to just ignore all warnings, as we would if we ran with --no-warnings. We just don't want to fail on redirects. Unfortunately, the `ignorewarnings` option in the linkchecker configuration file, which allows us to ignore only *specific* warnings (like `http-redirected`, in this case) has no equivalent CLI option. Thus, we must bring back the .linkcheckerrc file (which we dropped in 49eeb6e), and set that option in the config file. References: https://linkchecker.github.io/linkchecker/man/linkchecker.html#return-value https://linkchecker.github.io/linkchecker/man/linkcheckerrc.html#filtering linkchecker/linkchecker#750
1 parent ad595e6 commit a673233

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

.linkcheckerrc

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[checking]
2+
recursionlevel=2
3+
4+
[filtering]
5+
# Check external links (i.e. ones not within the domain given as a
6+
# command-line argument).
7+
checkextern=1
8+
9+
# Don't fail on links that result in HTTP 301 or 302, rather than 200.
10+
ignorewarnings=http-redirected

scripts/linkcheck.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ fi
4444

4545
# Actually run the link check
4646
linkchecker \
47-
--check-extern \
48-
--recursion-level 2 \
47+
--config .linkcheckerrc \
4948
$linkchecker_ignore_options \
5049
$* \
5150
$DOCS_SITE_URL/sitemap.xml

0 commit comments

Comments
 (0)