forked from python/pythonineducation.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pre-flight-checks.sh
executable file
·70 lines (51 loc) · 1.23 KB
/
pre-flight-checks.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
ERRORS=()
###
# Check that site can be built.
###
echo " *** Checking that site can be built."
wok --serve >/dev/null 2>&1 &
WOK_PID=$!
if [[ $? -eq 0 ]]; then
echo " *** Site built ok."
else
echo " *** Site could not be built."
exit 1
fi
###
# Wait for server to start.
###
sleep 5
curl "http://localhost:8000" >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
echo " *** Server is not running."
exit 1
fi
###
# Check that no links are broken.
###
# TODO reinstate this
#echo " *** Checking that no links are broken."
#linkchecker --no-status --no-warnings --check-extern "http://localhost:8000"
#if [[ $? -ne 0 ]]; then
# ERRORS+=("Broken links found on site")
#fi
###
# Check that common names are spelt correctly.
###
#echo " *** Checking that common names are spelt correctly"
#grep -e "MicroBit" -e "Microbit" -e "microbit" -e "microBit" --line-number --recursive --include "*.html" output | grep -v https://microbit.co.uk
#if [[ $? -eq 0 ]]; then
# ERRORS+=("Spelling mistaik detected. :-)")
#fi
kill $WOK_PID
if [[ ${#ERRORS[@]} -eq 0 ]]; then
echo " *** All pre-flight checks passed!"
exit 0
else
echo " *** The following pre-flight check(s) failed:"
for error in "${ERRORS[@]}"; do
echo " - $error"
done
exit 1
fi