jjb: Use alternative log4j classpath on sles 15.4+
[lttng-ci.git] / scripts / babeltrace-www / deploy.sh
index 617e4ed33657aeb902f9c2e8d39c4137c078ad04..21010571a6555b24a8c12688b6b2cf7d572ed01a 100644 (file)
@@ -2,6 +2,7 @@
 # shellcheck disable=SC2103
 #
 # Copyright (C) 2021 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
+#               2023 Michael Jeanson <mjeanson@efficios.com>
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 
 set -exu
 
-RUBY_VERSION=2.7
+print_header() {
+    set +x
 
-# Add ssh key for deployment
-cp "$HOST_PUBLIC_KEYS" ~/.ssh/known_hosts
-cp "$KEY_FILE_VARIABLE" ~/.ssh/id_rsa
+    local message=" $1 "
+    local message_len
+    local padding_len
 
-# Nodejs
-# Using Debian, as root
-apt-add-repository ppa:brightbox/ruby-ng
-apt-get install -y ruby${RUBY_VERSION} ruby${RUBY_VERSION}-dev ruby-switch ruby-bundler
+    message_len="${#message}"
+    padding_len=$(( (80 - (message_len)) / 2 ))
 
-ruby-switch --list
-ruby-switch --set ruby${RUBY_VERSION}
+    printf '\n'; printf -- '#%.0s' {1..80}; printf '\n'
+    printf -- '-%.0s' {1..80}; printf '\n'
+    printf -- '#%.0s' $(seq 1 $padding_len); printf '%s' "$message"; printf -- '#%.0s' $(seq 1 $padding_len); printf '\n'
+    printf -- '-%.0s' {1..80}; printf '\n'
+    printf -- '#%.0s' {1..80}; printf '\n\n'
 
-ruby -v
-export PATH="/root/.gem/ruby/${RUBY_VERSION}.0/bin:$PATH"
-bundle config set --local path "/root/.gem"
+    set -x
+}
+
+# Add ssh key for deployment
+cp "$HOST_PUBLIC_KEYS" ~/.ssh/known_hosts
+cp "$KEY_FILE_VARIABLE" ~/.ssh/id_rsa
 
+export DEBIAN_FRONTEND=noninteractive
+apt-get update
 
-apt-get install -y jekyll npm grunt python3 python3-pip python3-venv
+print_header "Install web tooling dependencies"
+apt-get install -y jekyll npm grunt python3 python3-pip python3-venv linkchecker
 
-# babeltrace dependencies
+print_header "Install babeltrace build dependencies"
 apt-get install -y asciidoc xmlto libdw-dev libelf-dev elfutils autoconf automake libglib2.0-dev make doxygen flex bison
 
+print_header "Install NPM stuff"
 npm install
 
-python3 -m venv build_venv && source build_venv/bin/activate
+print_header "Install Python requirements"
+python3 -m venv build_venv
+source build_venv/bin/activate
 pip install -r requirements.txt
 
 # Setting TERM avoids spurious warnings when configure is checking TPUT, as
 # $TERM is not set in the build environment.
 # As we've already opened a venv, set SKIP_VENV so the python job doesn't
 # create a second nested virtual environment.
-TERM=dumb SKIP_VENV=1 grunt build:prod --verbose
+print_header "Build website with grunt"
+TERM=dumb SKIP_VENV=1 VERBOSE=1 grunt build:prod --verbose
+
+print_header "Check links"
+grunt connect:prod watch:prod &
+SERVER_PID="${!}"
+sleep 10 # While serve:prod starts up
+
+OUTPUT_DIR="$(mktemp -d)"
+OUTPUT_FILE="${OUTPUT_DIR}/linkchecker-out.csv"
+
+# linkchecker drops privileges to 'nobody' when run as root
+chown nobody "${OUTPUT_DIR}"
+
+# @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_DIR}"
+    sleep 5 # Let serve:prod stop
+    exit 1
+else
+    rm -rf "${OUTPUT_DIR}"
+    kill "${SERVER_PID}"
+fi
+
+print_header "Deploy website"
 grunt deploy:prod --verbose
 
 # In the venv functions generated by the version of python installed on bionic
This page took 0.022921 seconds and 4 git commands to generate.