X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=scripts%2Flttng-www%2Fdeploy.sh;h=2d3fe528f929a18db78f1a232e9b20d277fa4b45;hb=51664b4cbe19d0a970c820aad9864d2f55023cc9;hp=bb81757e02f474600052b0c66eb9ef0e449af4cc;hpb=de518de89e68782bcf1e58b3340e3c0350f02f5c;p=lttng-ci.git diff --git a/scripts/lttng-www/deploy.sh b/scripts/lttng-www/deploy.sh index bb81757..2d3fe52 100755 --- a/scripts/lttng-www/deploy.sh +++ b/scripts/lttng-www/deploy.sh @@ -18,39 +18,79 @@ set -exu -RUBY_VERSION=2.7 +print_header() { + set +x + + local message=" $1 " + local message_len + local padding_len + + message_len="${#message}" + padding_len=$(( (80 - (message_len)) / 2 )) + + 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' + + set -x +} + +# Fail out early if this is not set +echo "Deploy target: ${DEPLOY_TARGET}" # Add ssh key for deployment cp "$HOST_PUBLIC_KEYS" ~/.ssh/known_hosts cp "$KEY_FILE_VARIABLE" ~/.ssh/id_rsa # lttng-www dependencies +export DPKG_FRONTEND=noninteractive +apt-get update -# Nodejs -# Using Debian, as root -curl -fsSL https://deb.nodesource.com/setup_16.x | bash - -apt-get install -y nodejs +print_header "Install web tooling dependencies" +apt-get install -y nodejs node-grunt-cli npm ruby-bundler ruby-dev python3-pip python3-venv -apt-add-repository ppa:brightbox/ruby-ng -apt-get install -y ruby${RUBY_VERSION} ruby${RUBY_VERSION}-dev ruby-switch ruby-bundler +ruby -v -ruby-switch --list -ruby-switch --set ruby${RUBY_VERSION} +apt-get install -y xmlto doclifter linkchecker -ruby -v +python3 -m venv build_venv +# shellcheck disable=SC1091 +source build_venv/bin/activate + +bundle config set --local path "vendor/bundle" + +./bootstrap-debian.sh -apt-get install -y asciidoc xmlto python3 python3-pip +print_header "Build website with grunt" +bundle exec grunt build:prod -npm install -g grunt-cli -npm install -g sass +print_header "Check links" +bundle exec grunt connect:prod watch:prod & +SERVER_PID="${!}" +sleep 10 # While serve:prod starts up -export PATH="/root/.gem/ruby/${RUBY_VERSION}.0/bin:$PATH" +OUTPUT_DIR="$(mktemp -d)" +OUTPUT_FILE="${OUTPUT_DIR}/linkchecker-out.csv" -bundle config set --local path "/root/.gem" +# linkchecker drops privileges to 'nobody' when run as root +chown nobody "${OUTPUT_DIR}" -./bootstrap.sh +# @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 -grunt build:prod -grunt deploy:prod +print_header "Deploy website" +bundle exec grunt "${DEPLOY_TARGET}" --network # EOF