Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions scripts/travis/after_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
96 changes: 96 additions & 0 deletions test/platform/test_linux_amd64_compatibility.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/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 "$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

build_images () {
# We'll use this simple tokenized Dockerfile.
# https://serverfault.com/a/72511
IFS='' read -r -d '' TOKENIZED <<EOF
FROM {{OS}}

WORKDIR /root
CMD ["/bin/bash"]
EOF

for item in ${OS_LIST[*]}
do
echo "$BLUE_FG[$0]$END_FG_COLOR Testing $item..."

echo -e "${TOKENIZED/\{\{OS\}\}/$item}" > 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."