From 635d17bb49094614b6ef72412ffb9cf060641311 Mon Sep 17 00:00:00 2001 From: Soam Vasani Date: Fri, 11 Aug 2017 15:02:14 -0700 Subject: [PATCH] Don't set KUBECONFIG when there is no reachable cluster Travis doesn't pass secret env vars to tests run on forks, so we need a way to skip the tests when there are no credentials passed in. This change unsets KUBECONFIG when there's no reachable cluster. The Go tests already check for KUBECONFIG and skip when it's not defined. --- hack/runtests.sh | 5 +++++ hack/travis-kube-setup.sh | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/hack/runtests.sh b/hack/runtests.sh index 1aa73362c..943cbbd31 100755 --- a/hack/runtests.sh +++ b/hack/runtests.sh @@ -3,5 +3,10 @@ # The poolmgr unit test only works with NodePort-type services for # now. So disable it for our travis ci tests. +if [ ! -f ${KUBECONFIG} ] +then + unset KUBECONFIG +fi + go test -v -i $(go list ./... | grep -v '/vendor/' | grep -v 'examples/go') go test -v $(go list ./... | grep -v '/vendor/' | grep -v 'examples/go' | grep -v poolmgr) diff --git a/hack/travis-kube-setup.sh b/hack/travis-kube-setup.sh index 64b8da85b..524b0940a 100755 --- a/hack/travis-kube-setup.sh +++ b/hack/travis-kube-setup.sh @@ -6,6 +6,14 @@ set -e +# If we don't have gcloud credentials, bail out of these tests. +if [ -z ${FISSION_CI_SERVICE_ACCOUNT:+} ] +then + echo "Skipping tests, no cluster credentials" + exit 0 +fi + +# Get kubectl curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl chmod +x ./kubectl sudo mv ./kubectl /usr/local/bin/kubectl