From ec50e3fc8ba39928f4eaab48a99b3963447decb7 Mon Sep 17 00:00:00 2001 From: Tsachi Herman Date: Wed, 18 Dec 2019 21:00:51 -0500 Subject: [PATCH 1/3] Add platform testing using docker for generated binaries. --- scripts/travis/after_build.sh | 3 + .../test_linux_amd64_compatibility.sh | 98 +++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100755 test/platform/test_linux_amd64_compatibility.sh diff --git a/scripts/travis/after_build.sh b/scripts/travis/after_build.sh index 79c414fabb..c3a0042281 100755 --- a/scripts/travis/after_build.sh +++ b/scripts/travis/after_build.sh @@ -23,3 +23,6 @@ if [ "${TRAVIS_EVENT_TYPE}" = "cron" ] || [[ "${TRAVIS_BRANCH}" =~ ^rel/ ]]; the rm ./node/node.test fi; fi; + +# test binary compatibility +"${SCRIPTPATH}/test/platform/test_linux_amd64_compatibility.sh" \ No newline at end of file diff --git a/test/platform/test_linux_amd64_compatibility.sh b/test/platform/test_linux_amd64_compatibility.sh new file mode 100755 index 0000000000..41e2a2ac62 --- /dev/null +++ b/test/platform/test_linux_amd64_compatibility.sh @@ -0,0 +1,98 @@ +#!/usr/bin/env bash + +BLUE_FG=$(tput setaf 4) +GREEN_FG=$(tput setaf 2) +RED_FG=$(tput setaf 1) +TEAL_FG=$(tput setaf 6) +END_FG_COLOR=$(tput sgr0) + +OS_LIST=( + centos:7 + centos:8 + fedora:28 + ubuntu:16.04 + ubuntu:18.04 +) + +FAILED=() + +SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" +PLATFORM=$($SCRIPTPATH/../../scripts/osarchtype.sh) + +if [ "${PLATFORM}" != "linux/amd64" ] +then + echo "The test_linux_amd64_compatibility.sh script is intended to support local execution only on linux/x86-64 machines." + exit 0 +fi + +build_images () { + # We'll use this simple tokenized Dockerfile. + # https://serverfault.com/a/72511 + IFS='' read -r -d '' TOKENIZED < Dockerfile + if ! docker build -t "${item}-test" . + then + FAILED+=("$item") + fi + done +} + +run_images () { + for item in ${OS_LIST[*]} + do + echo "$TEAL_FG[$0]$END_FG_COLOR Running ${item}-test..." + DOCKER_CONTAINER_ID=$(docker run -dt "${item}-test") + docker cp $GOPATH/bin/algod ${DOCKER_CONTAINER_ID}:/root/algod + docker cp $GOPATH/bin/goal ${DOCKER_CONTAINER_ID}:/root/goal + if ! docker exec ${DOCKER_CONTAINER_ID} /root/algod -v + then + FAILED+=("$item") + elif ! docker exec ${DOCKER_CONTAINER_ID} /root/goal --version + then + FAILED+=("$item") + fi + docker stop ${DOCKER_CONTAINER_ID} + done +} + +cleanup() { + rm -f Dockerfile +} + +check_failures() { + if [ "${#FAILED[@]}" -gt 0 ] + then + echo -e "\n$RED_FG[$0]$END_FG_COLOR The following images could not be $1:" + + for failed in ${FAILED[*]} + do + echo " - $failed" + done + + echo + + exit 1 + fi +} + +build_images +cleanup + +check_failures built +echo "$GREEN_FG[$0]$END_FG_COLOR Builds completed with no failures." + +run_images +check_failures run +echo "$GREEN_FG[$0]$END_FG_COLOR Runs completed with no failures." From e9d4f0aaf0ee9b0180d4280cdeb26deaab958a90 Mon Sep 17 00:00:00 2001 From: Tsachi Herman Date: Wed, 18 Dec 2019 21:15:54 -0500 Subject: [PATCH 2/3] Fix path. --- scripts/travis/after_build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/travis/after_build.sh b/scripts/travis/after_build.sh index c3a0042281..cbe2609e56 100755 --- a/scripts/travis/after_build.sh +++ b/scripts/travis/after_build.sh @@ -25,4 +25,4 @@ if [ "${TRAVIS_EVENT_TYPE}" = "cron" ] || [[ "${TRAVIS_BRANCH}" =~ ^rel/ ]]; the fi; # test binary compatibility -"${SCRIPTPATH}/test/platform/test_linux_amd64_compatibility.sh" \ No newline at end of file +"${SCRIPTPATH}/../../test/platform/test_linux_amd64_compatibility.sh" \ No newline at end of file From bfa5cc0542102b29f036b64c343d881d3811d324 Mon Sep 17 00:00:00 2001 From: Tsachi Herman Date: Thu, 19 Dec 2019 12:39:43 -0500 Subject: [PATCH 3/3] Apply reviewer's requested changes. --- test/platform/test_linux_amd64_compatibility.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/test/platform/test_linux_amd64_compatibility.sh b/test/platform/test_linux_amd64_compatibility.sh index 41e2a2ac62..2081c7872f 100755 --- a/test/platform/test_linux_amd64_compatibility.sh +++ b/test/platform/test_linux_amd64_compatibility.sh @@ -21,7 +21,7 @@ PLATFORM=$($SCRIPTPATH/../../scripts/osarchtype.sh) if [ "${PLATFORM}" != "linux/amd64" ] then - echo "The test_linux_amd64_compatibility.sh script is intended to support local execution only on linux/x86-64 machines." + echo "$RED_FG[$0]$END_FG_COLOR The test_linux_amd64_compatibility.sh script is intended to support local execution only on linux/x86-64 machines." exit 0 fi @@ -37,11 +37,9 @@ EOF for item in ${OS_LIST[*]} do - WITH_PACMAN=$(echo -e "${TOKENIZED}") + echo "$BLUE_FG[$0]$END_FG_COLOR Testing $item..." - echo -e "$BLUE_FG[$0]$END_FG_COLOR Testing $item..." - - echo -e "${WITH_PACMAN/\{\{OS\}\}/$item}" > Dockerfile + echo -e "${TOKENIZED/\{\{OS\}\}/$item}" > Dockerfile if ! docker build -t "${item}-test" . then FAILED+=("$item")