diff --git a/.scripts/test_all.sh b/.scripts/test_all.sh new file mode 100755 index 0000000..a52c9b4 --- /dev/null +++ b/.scripts/test_all.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +set -e + +# Find all packages inside the current directory, excluding the consullocker +# since this may not be run on all Go versions. +packages=$(find ./ -maxdepth 2 -name '*.go' -printf '%h\n' | sort | uniq) +packages=$(echo "$packages" | sed '/consul/d') + +# Install the AWS SDK which is explicitly not vendored +go get -u github.com/aws/aws-sdk-go + +# Test all packages which are allowed on all Go versions +go test $packages + +# The consul package only supports Go1.6+ and therefore we will only run the +# corresponding tests on these versions. +goversion=$(go version) +if [[ "$goversion" != *"go1.3"* ]] && + [[ "$goversion" != *"go1.4"* ]] && + [[ "$goversion" != *"go1.5"* ]]; then + + # Install the Consul packages which are not vendored. + go get -u github.com/hashicorp/consul + + go test ./consullocker +else + echo "Skipping tests requiring Consul which is not supported on $goversion" +fi diff --git a/.travis.yml b/.travis.yml index 13d4353..0aecbc9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,12 +21,9 @@ matrix: allow_failures: - go: tip install: -- export PACKAGES=$(find ./ -maxdepth 2 -name '*.go' -printf '%h\n' | sort | uniq) - rsync -r ./vendor/ $GOPATH/src -- go get github.com/aws/aws-sdk-go -- go get github.com/hashicorp/consul script: -- go test $PACKAGES +- ./.scripts/test_all.sh before_deploy: - ./.scripts/build_all.sh deploy: