From 8ae912ace23563ea29a3c4abee7c1216299d50c9 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Tue, 15 Aug 2023 11:31:16 -0400 Subject: [PATCH] jjb: lttng-www: move to deb12 builders Change-Id: I5e8fe708af25aa568293da6e6b6b9d0e4c87fb4a Signed-off-by: Michael Jeanson --- jobs/lttng-www.yaml | 26 ++++++++--------- scripts/lttng-www/deploy.sh | 56 +++++++++++++++++++++++++++---------- 2 files changed, 54 insertions(+), 28 deletions(-) diff --git a/jobs/lttng-www.yaml b/jobs/lttng-www.yaml index 15ea9a2..4e18c59 100644 --- a/jobs/lttng-www.yaml +++ b/jobs/lttng-www.yaml @@ -2,7 +2,7 @@ name: lttng-www project-type: freestyle defaults: global - node: amd64-rootnode-jammy + node: amd64-rootnode description: | This job is responsible for updating the lttng website. @@ -32,9 +32,19 @@ !include-raw: scripts/lttng-www/deploy.sh scm: - - lttng-www + - git: + url: git@git.efficios.com:lttng-www.git + credentials-id: 63a5abb5-9056-47e2-b419-f5946c1b8f08 + basedir: ./ + skip-tag: true + branches: + - master publishers: + - archive: + artifacts: 'site/**,prod/**' + follow-symlinks: true + allow-empty: false - ircbot: strategy: statechange-only message-type: summary @@ -61,15 +71,3 @@ matrix-trigger: only-parent send-to: - recipients - -- scm: - name: lttng-www - scm: - - git: - url: git@git.efficios.com:lttng-www.git - credentials-id: 63a5abb5-9056-47e2-b419-f5946c1b8f08 - basedir: ./ - skip-tag: true - branches: - - master - diff --git a/scripts/lttng-www/deploy.sh b/scripts/lttng-www/deploy.sh index ac35fb5..3d73a4d 100755 --- a/scripts/lttng-www/deploy.sh +++ b/scripts/lttng-www/deploy.sh @@ -18,48 +18,76 @@ set -exu +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 +} + # 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 -# Nodejs -# Using Debian, as root apt-get update -apt-get install -y nodejs npm -apt-get install -y ruby ruby-bundler ruby-dev + +print_header "Install web tooling dependencies" +apt-get install -y nodejs node-grunt-cli npm ruby-bundler ruby-dev python3-pip python3-venv + ruby -v -apt-get install -y asciidoc xmlto python3 python3-pip doclifter -npm install -g grunt-cli -npm install -g sass +apt-get install -y xmlto doclifter linkchecker + +python3 -m venv build_venv +# shellcheck disable=SC1091 +source build_venv/bin/activate bundle config set --local path "vendor/bundle" -./bootstrap.sh +./bootstrap-debian.sh -bundle exec grunt build:prod --network +print_header "Build website with grunt" +bundle exec grunt build:prod -apt-get install -y linkchecker +print_header "Check links" bundle exec grunt connect:prod watch:prod & SERVER_PID="${!}" sleep 10 # While serve:prod starts up -OUTPUT_FILE="$(mktemp -d)/linkchecker-out.csv" -chown nobody "$(dirname "${OUTPUT_FILE}")" + +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_FILE}/.." + rm -rf "${OUTPUT_DIR}" sleep 5 # Let serve:prod stop exit 1 else - rm -rf "${OUTPUT_FILE}/.." + rm -rf "${OUTPUT_DIR}" kill "${SERVER_PID}" fi +print_header "Deploy website" bundle exec grunt deploy:prod --network # EOF -- 2.34.1