forked from projectcalico/calico
-
Notifications
You must be signed in to change notification settings - Fork 0
/
htmlproofer.sh
executable file
·37 lines (28 loc) · 1.58 KB
/
htmlproofer.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
# This file executes htmlproofer checks on the compiled html files in _site.
# Version of htmlproofer to use.
HP_VERSION=v0.2
# Local directories to ignore when checking external links
HP_IGNORE_LOCAL_DIRS="/v1.5/,/v1.6/,/v2.0/,/v2.1/,/v2.2/,/v2.3/,/v2.4/,/v2.5/"
# URLs to ignore when checking external links.
HP_IGNORE_URLS="/docs.openshift.org/,#,/github.com\/projectcalico\/calico\/releases\/download/"
# The htmlproofer check is flaky, so we retry a number of times if we get a bad result.
# If it doesn't pass once in 10 tries, we count it as a failed check.
echo "Running a hard URL check against recent releases"
for i in `seq 1 10`; do
echo "htmlproofer attempt #${i}"
docker run -ti -e JEKYLL_UID=`id -u` --rm -v $(pwd)/_site:/_site/ quay.io/calico/htmlproofer:${HP_VERSION} /_site --file-ignore ${HP_IGNORE_LOCAL_DIRS} --assume-extension --check-html --empty-alt-ignore --url-ignore ${HP_IGNORE_URLS}
# Store the RC for future use.
rc=$?
echo "htmlproofer rc: $rc"
# If the command executed successfully, break out. Otherwise, retry.
if [[ $rc == 0 ]]; then break; fi
# Otherwise, sleep a short period and then retry.
echo "htmlproofer failed, retry in 10s"
sleep 10
done
# Rerun htmlproofer across _all_ files, but ignore failure, allowing us to notice legacy docs issues without failing CI
echo "Running a soft check across all files"
docker run -ti -e JEKYLL_UID=`id -u` --rm -v $(pwd)/_site:/_site/ quay.io/calico/htmlproofer:${HP_VERSION} /_site --assume-extension --check-html --empty-alt-ignore --url-ignore "#"
# Exit using the return code from the loop above.
exit $rc