diff --git a/tests/release.sh b/tests/release.sh index afaedb3..31aee6f 100755 --- a/tests/release.sh +++ b/tests/release.sh @@ -29,6 +29,6 @@ command_exists jq if version_ge "$INSP_VERSION" "$(github_latest_release "inspircd/inspircd")"; then echo "InspIRCd version ($INSP_VERSION) is up to date! Test successful." else - echo >&2 "A newer base image is available! Please update. New version is $(github_latest_release "inspircd/inspircd")" + echo >&2 "A newer InspIRCd release is available! Please update. New version is $(github_latest_release "inspircd/inspircd")" exit 1 fi diff --git a/tests/version.sh b/tests/version.sh deleted file mode 100755 index dcfeb49..0000000 --- a/tests/version.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh -echo " - ###################################### - ### Base image test ## - ###################################### -" - -DOCKERFILE="${1:-Dockerfile}" - - -# Check for command existence -# See: https://www.shivering-isles.com/helpful-shell-snippets-for-docker-testing-and-bootstrapping/ -command_exits() { command -v "$1" >/dev/null 2>&1 || { echo >&2 "I require $1 but it's not installed. Aborting."; exit 1; }; } - -# Docker latest version tag -# See: https://www.shivering-isles.com/helpful-shell-snippets-for-docker-testing-and-bootstrapping/ -docker_image_latest_tag() { REPO=$1; [ "$(echo "$REPO" | grep -c '/')" -eq 0 ] && REPO=library/$1; wget -q -O- "https://registry.hub.docker.com/v2/repositories/${REPO}/tags" | jq .results[].name | sort -V | sed -e 's/"//g' | grep -P '^[[:digit:]]+(\.[[:digit:]]+)$' | tail -1; } - -# Version comparison greater or equal -# See: https://www.shivering-isles.com/helpful-shell-snippets-for-docker-testing-and-bootstrapping/ -version_ge() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1" || test "$1" = "$2"; } - -# Docker base image version -# See: https://www.shivering-isles.com/helpful-shell-snippets-for-docker-testing-and-bootstrapping/ -# shellcheck disable=SC2002 -docker_base_version() { cat "$1" | grep FROM | sed -e "s/FROM.*://g"; } - -# Docker base image name -# See: https://www.shivering-isles.com/helpful-shell-snippets-for-docker-testing-and-bootstrapping/ -# shellcheck disable=SC2002 -docker_base_name() { cat "$1" | grep FROM | sed -e "s/FROM[^[:alpha:]]//g" -e "s/:.*//g"; } - -command_exits wget - -[ -e "$DOCKERFILE" ] || { echo >&2 "File '$DOCKERFILE' doesn't exist. Aborting."; exit 1; } - -REMOTE_VERSION=$(docker_image_latest_tag "$(docker_base_name "$DOCKERFILE")") - -if version_ge "$(docker_base_version "$DOCKERFILE")" "$REMOTE_VERSION"; then - echo "Base image is up to date! Test successful." -else - echo >&2 "A newer base image ($REMOTE_VERSION) is available! Please update." - exit 1 -fi