jjb: Check internal site links on efficios.com before deploy
authorKienan Stewart <kstewart@efficios.com>
Fri, 7 Jul 2023 14:25:54 +0000 (10:25 -0400)
committerKienan Stewart <kstewart@efficios.com>
Fri, 7 Jul 2023 14:33:53 +0000 (10:33 -0400)
Change-Id: I56b36751928d7b06f9d598566ddb0c0cf715287c

scripts/efficios-www/deploy.sh

index 7a9ef2230cdf1de489e607b4838a9143c0cb3a25..f1c22d9b6cd737e60c0d5852fabb9c3aa274221c 100644 (file)
@@ -22,8 +22,10 @@ set -exu
 cp "$HOST_PUBLIC_KEYS" ~/.ssh/known_hosts
 cp "$KEY_FILE_VARIABLE" ~/.ssh/id_rsa
 
+apt-get update
+
 # Nodejs
-apt-get install -y npm
+apt-get install --no-install-recommends -y npm
 ./bootstrap-ubuntu.sh
 npm install
 
@@ -31,5 +33,27 @@ grunt build:dev --verbose
 grunt deploy:pre --verbose
 
 grunt build:prod --verbose
+
+# Check for broken internal links
+apt-get install -y linkchecker
+grunt connect:prod watch:prod &
+SERVER_PID="${!}"
+sleep 10 # While serve:prod starts up
+OUTPUT_FILE="$(mktemp -d)/linkchecker-out.csv"
+# linkchecker drops privileges to 'nobody' when run as root
+chown nobody "$(dirname "${OUTPUT_FILE}")"
+# @Note: Only internal links are checked by default
+if ! linkchecker -q -F "csv/utf-8/${OUTPUT_FILE}" http://localhost:10000/ ; then
+    echo "Linkchecker failed or found broken links"
+    cat "${OUTPUT_FILE}"
+    kill "${SERVER_PID}"
+    rm -rf "${OUTPUT_FILE}/.."
+    sleep 5 # Let serve:prod stop
+    exit 1
+else
+    rm -rf "${OUTPUT_FILE}/.."
+    kill "${SERVER_PID}"
+fi
+
 grunt deploy:prod --verbose
 # EOF
This page took 0.029528 seconds and 4 git commands to generate.