diff --git a/.travis.yml b/.travis.yml index a2546e93f8..10794a77b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,8 @@ stages: if: branch =~ /^rel\// AND type != pull_request - name: deploy if: branch =~ /^rel\// AND type != pull_request + - name: post_deploy + if: branch =~ /^rel\// AND type != pull_request jobs: allow_failures: @@ -25,6 +27,7 @@ jobs: - name: External ARM64 Integration Test - name: External ARM Build - name: External ARM Deploy + - name: Test Release Builds include: - stage: build_commit os: linux @@ -141,6 +144,16 @@ jobs: script: - scripts/travis/external_build.sh ./scripts/travis/deploy_packages.sh + - stage: post_deploy + os: linux + name: Test Release Builds + script: + - scripts/travis/test_release.sh + addons: + apt: + packages: + - awscli + # Don't rebuild libsodium every time cache: directories: diff --git a/scripts/travis/test_release.sh b/scripts/travis/test_release.sh new file mode 100755 index 0000000000..82cdcb0681 --- /dev/null +++ b/scripts/travis/test_release.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# We need to chdir to where the Dockerfile resides so the Docker context is properly set. +# Otherwise, Docker will look for the file to copied in `/var/lib/docker/tmp`, i.e., +# +# COPY install.sh . +# + +pushd test/packages +./test_release.sh +popd + diff --git a/test/packages/install.sh b/test/packages/install.sh new file mode 100755 index 0000000000..7a22eb87dc --- /dev/null +++ b/test/packages/install.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +# This is currently used by `test_release.sh`. +# It is copied into a docker image at build time +# and then invoked at run time. + +while [ "$1" != "" ]; do + case "$1" in + -b) + shift + BUCKET="$1" + ;; + -c) + shift + CHANNEL="$1" + ;; + *) + echo "Unknown option" "$1" + exit 1 + ;; + esac + shift +done + +curl --silent -L https://github.com/algorand/go-algorand-doc/blob/master/downloads/installers/linux_amd64/install_master_linux-amd64.tar.gz?raw=true | tar xzf - + +./update.sh -b "$BUCKET" -c "$CHANNEL" -i -p ~/node -d ~/node/data -n + +echo "[$0] Testing: algod -v" +./node/algod -v + diff --git a/test/packages/test_release.sh b/test/packages/test_release.sh new file mode 100755 index 0000000000..8fc7820910 --- /dev/null +++ b/test/packages/test_release.sh @@ -0,0 +1,139 @@ +#!/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) + +if [[ ! "$AWS_ACCESS_KEY_ID" || ! "$AWS_SECRET_ACCESS_KEY" ]] +then + echo -e "$RED_FG[$0]$END_FG_COLOR Missing AWS credentials." \ + "\nExport $GREEN_FG\$AWS_ACCESS_KEY_ID$END_FG_COLOR and $GREEN_FG\$AWS_SECRET_ACCESS_KEY$END_FG_COLOR before running this script." \ + "\nSee https://aws.amazon.com/blogs/security/wheres-my-secret-access-key/ to obtain creds." + exit 1 +fi + +OS_LIST=( + centos:7 + centos:8 + fedora:28 + ubuntu:16.04 + ubuntu:18.04 +) + +# These are default values which can be changed by the CLI args. +BUCKET=algorand-builds +CHANNEL=stable + +FAILED=() + +while [ "$1" != "" ]; do + case "$1" in + -b) + shift + BUCKET="$1" + ;; + -c) + shift + CHANNEL="$1" + ;; + *) + echo "Unknown option $1" + exit 1 + ;; + esac + shift +done + +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..." + if ! docker run --rm --name algorand -e "AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID" -e "AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY" -t "${item}-test" bash install.sh -b "$BUCKET" -c "$CHANNEL" + then + FAILED+=("$item") + fi + 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 + + cleanup + exit 1 + fi +} + +build_images +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." + +cleanup +exit 0 +