-
Notifications
You must be signed in to change notification settings - Fork 526
Created test_release.sh to test centos|fedora|ubuntu images
#613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e4d5bd3
Created `test_release.sh` to test centos|fedora|ubuntu images
ab43bad
Incorporate some review suggestions (more to come):
d8f15e2
Add ability to pass bucket, channel and aws creds
fc0012e
Ensure aws creds are in env before starting
ca01487
Make colorized text more readable
9fe7083
Break script into `build` and `run` operations
d51a038
Run `update.sh` at RUN time
c6bf2b1
Merge branch 'master' into test_releases
9ace86f
We're not writing the Dockerfile to disk before running it.
65b8383
Added new `post_deploy` stage and our script
0d52edb
Adding new `scripts/travis/test_release.sh` script
878e419
Add filtering for new `post_deploy` stage
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.