From cc829a512d51ff5ac916239c00be63f0b08fb512 Mon Sep 17 00:00:00 2001 From: Ashley Scopes <73482956+ascopes@users.noreply.github.com> Date: Fri, 23 Sep 2022 08:40:55 +0100 Subject: [PATCH 1/2] Tidy up prepare-test-outputs-for-merge.sh --- scripts/prepare-test-outputs-for-merge.sh | 53 +++++++++++++++++------ 1 file changed, 40 insertions(+), 13 deletions(-) diff --git a/scripts/prepare-test-outputs-for-merge.sh b/scripts/prepare-test-outputs-for-merge.sh index cd7770efd..ee4b628ca 100755 --- a/scripts/prepare-test-outputs-for-merge.sh +++ b/scripts/prepare-test-outputs-for-merge.sh @@ -23,30 +23,54 @@ set -o errexit set -o pipefail -ci_java_version=${1?Pass the Java version as the first argument to this script!} -ci_os=${2?Pass the OS name as the second argument to this script!} +ci_java_version="${1?Pass the Java version as the first argument to this script!}" +ci_os="${2?Pass the OS name as the second argument to this script!}" + +function log() { + printf "\033[1;${1}m%s:\033[0;${1}m %s\033[0m\n" "${2}" "${3}" >&2 +} + +function err() { + log 31 ERROR "${@}" +} + +function warn() { + log 33 WARNING "${@}" +} + +function info() { + log 34 INFO "${@}" +} + +function stage() { + log 35 STAGE "${@}" +} + +function success() { + log 32 SUCCESS "${@}" +} # If we don't have xsltproc installed, try to resolve it first. -if ! command -v xsltproc >/dev/null 2>&1; then +if ! command -v xsltproc > /dev/null 2>&1; then # If we are not running in CI, then the user needs to install this dependency # manually. If we are in CI, assume we are running on ubuntu-latest # on a GitHub Actions runner and just install xsltproc. if [ -z ${CI+_} ]; then - echo -e "\e[1;31mERROR\e[0m: xsltproc is not found -- make sure it is installed first." + err "xsltproc is not found -- make sure it is installed first." exit 2 else - echo -e "\e[1;33mWARN\e[0m: xsltproc is not installed, so I will install it now..." + warn "xsltproc is not installed, so I will install it now..." sudo apt-get install xsltproc -qy - echo -e "\e[1;32m...done!\e[0m" + success "Installed xsltproc successfully" fi fi -echo -e "\e[1;35mUpdating Surefire reports...\e[0m" +stage "Generating Surefire XSLT script..." surefire_prefix_xslt_dir="$(mktemp -d)" trap 'rm -Rf "${surefire_prefix_xslt_dir}"' EXIT SIGINT SIGTERM SIGQUIT surefire_prefix_xslt="${surefire_prefix_xslt_dir}/surefire.xslt" -sed 's/^ //g' >"${surefire_prefix_xslt}" <<'EOF' +sed 's/^ //g' > "${surefire_prefix_xslt}" <<'EOF'