2016-09-29 22:46:05 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2016-09-29 23:07:07 +00:00
|
|
|
# Find all packages containing Go source code inside the current directory
|
2016-09-29 22:46:05 +00:00
|
|
|
packages=$(find ./ -maxdepth 2 -name '*.go' -printf '%h\n' | sort | uniq)
|
|
|
|
|
2019-06-11 15:03:53 +00:00
|
|
|
# Some packages only support Go1.10+ and therefore we will only run the
|
2016-09-29 22:46:05 +00:00
|
|
|
# corresponding tests on these versions.
|
|
|
|
goversion=$(go version)
|
2016-12-20 16:25:24 +00:00
|
|
|
if [[ "$goversion" == *"go1.5"* ]] ||
|
2017-11-21 12:18:47 +00:00
|
|
|
[[ "$goversion" == *"go1.6"* ]] ||
|
2018-05-13 12:33:05 +00:00
|
|
|
[[ "$goversion" == *"go1.7"* ]] ||
|
2018-07-14 20:12:21 +00:00
|
|
|
[[ "$goversion" == *"go1.8"* ]] ||
|
2018-07-14 20:08:16 +00:00
|
|
|
[[ "$goversion" == *"go1.9"* ]]; then
|
2016-09-29 22:46:05 +00:00
|
|
|
|
2017-09-16 18:49:09 +00:00
|
|
|
echo "Skipping tests requiring GCSStore, which is not supported on $goversion"
|
|
|
|
packages=$(echo "$packages" | sed '/gcsstore/d')
|
2019-01-13 23:22:12 +00:00
|
|
|
|
|
|
|
echo "Skipping tests requiring Prometheus, which is not supported on $goversion"
|
|
|
|
packages=$(echo "$packages" | sed '/prometheuscollector/d')
|
2016-09-29 22:46:05 +00:00
|
|
|
else
|
2019-01-13 23:22:12 +00:00
|
|
|
go get -u github.com/prometheus/client_golang/prometheus
|
2016-09-29 22:46:05 +00:00
|
|
|
fi
|
2016-09-29 23:07:07 +00:00
|
|
|
|
2018-11-10 20:05:44 +00:00
|
|
|
install_etcd_pkgs() {
|
|
|
|
ETCD_VERSION="3.3.10"
|
|
|
|
go get -u go.etcd.io/etcd/clientv3
|
|
|
|
go get -u github.com/chen-anders/go-etcd-harness
|
|
|
|
wget -q -O /tmp/etcd.tar.gz "https://github.com/etcd-io/etcd/releases/download/v$ETCD_VERSION/etcd-v$ETCD_VERSION-linux-amd64.tar.gz"
|
|
|
|
tar xvzf /tmp/etcd.tar.gz -C /tmp
|
|
|
|
export PATH="$PATH:/tmp/etcd-v$ETCD_VERSION-linux-amd64"
|
|
|
|
}
|
|
|
|
|
2019-05-20 20:38:53 +00:00
|
|
|
# The etcd 3.3.x package only supports Go1.11+ and therefore
|
2018-11-10 20:05:44 +00:00
|
|
|
# we will only run the corresponding tests on these versions.
|
|
|
|
if [[ "$goversion" == *"go1.5"* ]] ||
|
|
|
|
[[ "$goversion" == *"go1.6"* ]] ||
|
|
|
|
[[ "$goversion" == *"go1.7"* ]] ||
|
2019-05-20 20:38:53 +00:00
|
|
|
[[ "$goversion" == *"go1.8"* ]] ||
|
|
|
|
[[ "$goversion" == *"go1.9"* ]] ||
|
|
|
|
[[ "$goversion" == *"go1.10"* ]]; then
|
2018-11-10 20:05:44 +00:00
|
|
|
echo "Skipping tests requiring etcd3locker, which is not supported on $goversion"
|
|
|
|
packages=$(echo "$packages" | sed '/etcd3locker/d')
|
|
|
|
else
|
|
|
|
# Install the etcd packages which are not vendored.
|
|
|
|
install_etcd_pkgs
|
|
|
|
fi
|
|
|
|
|
2019-01-13 23:22:12 +00:00
|
|
|
# Install the AWS SDK which is explicitly not vendored
|
2019-05-20 20:52:15 +00:00
|
|
|
go get -u github.com/aws/aws-sdk-go/service/s3
|
|
|
|
go get -u github.com/aws/aws-sdk-go/aws/...
|
2016-09-29 23:07:07 +00:00
|
|
|
|
|
|
|
# Test all packages which are allowed on all Go versions
|
2016-10-13 14:45:19 +00:00
|
|
|
go test $packages
|
2017-02-28 19:39:25 +00:00
|
|
|
|
|
|
|
go vet $packages
|