Skip to content
Merged
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tsachiherman I'll check tomorrow if there's a docker package.


# Don't rebuild libsodium every time
cache:
directories:
Expand Down
12 changes: 12 additions & 0 deletions scripts/travis/test_release.sh
Original file line number Diff line number Diff line change
@@ -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

31 changes: 31 additions & 0 deletions test/packages/install.sh
Original file line number Diff line number Diff line change
@@ -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

139 changes: 139 additions & 0 deletions test/packages/test_release.sh
Original file line number Diff line number Diff line change
@@ -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 <<EOF
FROM {{OS}}

ENV AWS_ACCESS_KEY_ID=""
ENV AWS_SECRET_ACCESS_KEY=""

{{PACMAN}}
WORKDIR /root
COPY install.sh .
CMD ["/bin/bash"]
EOF

for item in ${OS_LIST[*]}
do
# Install root certs.
# We use pattern substitution here (like sed).
# ${parameter/pattern/substitution}
if [[ $item =~ ubuntu ]]
then
WITH_PACMAN=$(echo -e "${TOKENIZED//\{\{PACMAN\}\}/RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y curl}")
else
WITH_PACMAN=$(echo -e "${TOKENIZED//\{\{PACMAN\}\}/RUN yum install -y curl}")
fi

echo -e "$BLUE_FG[$0]$END_FG_COLOR Testing $item..."

# Note that we now create a Dockerfile so the Docker context is properly set.
# Without this context, Docker tried to COPY from /var/lib/docker/tmp and seemed
# to do so because the Dockerfile was being automatically generated, i.e.,
#
# echo -e "..." | docker build -t foo -
#
# To avoid this, we now redirect the generated Dockerfile to disk, overwriting it
# with each subsequent iteration (and cleaning it up upon exit).
#
# Since we eventually want to move to storing the Dockerfiles, this seems like an
# acceptable tradeoff.
echo -e "${WITH_PACMAN/\{\{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..."
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