From 0a106fb6fe8e69fecb9cda9b40771aa01c8e178d Mon Sep 17 00:00:00 2001 From: Danny Berger Date: Wed, 12 Oct 2016 10:30:53 -0700 Subject: [PATCH] Enforce CI pipelines running with expected go version [#132166973](https://www.pivotaltracker.com/story/show/132166973) Signed-off-by: Tom Viehman --- bin/require-ci-golang-version | 10 ++++++++++ ci/docker/Dockerfile | 4 ++-- ci/docker/deps-golang | 3 +++ ci/docker/install-go.sh | 3 +-- ci/tasks/build.sh | 1 + ci/tasks/test-acceptance.sh | 1 + ci/tasks/test-integration.sh | 1 + ci/tasks/test-unit.sh | 1 + 8 files changed, 20 insertions(+), 4 deletions(-) create mode 100755 bin/require-ci-golang-version create mode 100644 ci/docker/deps-golang diff --git a/bin/require-ci-golang-version b/bin/require-ci-golang-version new file mode 100755 index 000000000..c49746379 --- /dev/null +++ b/bin/require-ci-golang-version @@ -0,0 +1,10 @@ +#!/bin/bash + +source ci/docker/deps-golang + +if ! go version | grep -q " go$GO_VERSION " ; then + echo -n "DEBUG: " ; go version + echo "ERROR: expected version to be $GO_VERSION" >&2 + exit 1 +fi + diff --git a/ci/docker/Dockerfile b/ci/docker/Dockerfile index 2f9f71d31..2cccc6754 100644 --- a/ci/docker/Dockerfile +++ b/ci/docker/Dockerfile @@ -27,9 +27,9 @@ RUN vagrant plugin install vagrant-aws # bosh-init dependencies RUN apt-get install -y mercurial && apt-get clean # ...go -ADD install-go.sh /tmp/install-go.sh +ADD install-go.sh deps-golang /tmp/ RUN chmod a+x /tmp/install-go.sh -RUN cd tmp && ./install-go.sh && rm install-go.sh +RUN cd /tmp && ./install-go.sh && rm install-go.sh deps-golang # lifecycle ssh test RUN apt-get install -y sshpass && apt-get clean diff --git a/ci/docker/deps-golang b/ci/docker/deps-golang new file mode 100644 index 000000000..9f6eee977 --- /dev/null +++ b/ci/docker/deps-golang @@ -0,0 +1,3 @@ +GO_VERSION=1.7.1 +GO_ARCHIVE_SHA256=43ad621c9b014cde8db17393dc108378d37bc853aa351a6c74bf6432c1bbd182 +GO_ARCHIVE_URL=https://storage.googleapis.com/golang/go$GO_VERSION.linux-amd64.tar.gz diff --git a/ci/docker/install-go.sh b/ci/docker/install-go.sh index 0be4b7585..d5a7d63c5 100644 --- a/ci/docker/install-go.sh +++ b/ci/docker/install-go.sh @@ -2,9 +2,8 @@ set -ex +source deps-golang GOROOT=/usr/local/go -GO_ARCHIVE_URL=https://storage.googleapis.com/golang/go1.7.1.linux-amd64.tar.gz -GO_ARCHIVE_SHA256=43ad621c9b014cde8db17393dc108378d37bc853aa351a6c74bf6432c1bbd182 GO_ARCHIVE=$(basename $GO_ARCHIVE_URL) echo "Downloading go..." diff --git a/ci/tasks/build.sh b/ci/tasks/build.sh index 604917471..06da578d6 100755 --- a/ci/tasks/build.sh +++ b/ci/tasks/build.sh @@ -12,6 +12,7 @@ timestamp=`date -u +"%Y-%m-%dT%H:%M:%SZ"` filename="bosh-cli-${semver}-${GOOS}-${GOARCH}" cd gopath/src/github.com/cloudfoundry/bosh-cli +bin/require-ci-golang-version git_rev=`git rev-parse --short HEAD` version="${semver}-${git_rev}-${timestamp}" diff --git a/ci/tasks/test-acceptance.sh b/ci/tasks/test-acceptance.sh index eb930a4f2..a920851b1 100755 --- a/ci/tasks/test-acceptance.sh +++ b/ci/tasks/test-acceptance.sh @@ -40,4 +40,5 @@ set -x export BOSH_LITE_PRIVATE_KEY=$tmpfile cd $GOPATH/src/github.com/cloudfoundry/bosh-cli +./bin/require-ci-golang-version base=$PWD ./bin/test-acceptance-with-vm --provider=aws diff --git a/ci/tasks/test-integration.sh b/ci/tasks/test-integration.sh index 00908c914..3bcf825c0 100755 --- a/ci/tasks/test-integration.sh +++ b/ci/tasks/test-integration.sh @@ -9,6 +9,7 @@ export PATH=/usr/local/ruby/bin:/usr/local/go/bin:$PATH export GOPATH=$(pwd)/gopath cd gopath/src/github.com/cloudfoundry/bosh-cli +bin/require-ci-golang-version bin/clean bin/install-ginkgo bin/test-integration diff --git a/ci/tasks/test-unit.sh b/ci/tasks/test-unit.sh index 21321fb2c..cffc7ad15 100755 --- a/ci/tasks/test-unit.sh +++ b/ci/tasks/test-unit.sh @@ -8,6 +8,7 @@ export PATH=/usr/local/ruby/bin:/usr/local/go/bin:$PATH export GOPATH=$(pwd)/gopath cd gopath/src/github.com/cloudfoundry/bosh-cli +bin/require-ci-golang-version bin/clean bin/install-ginkgo bin/test-prepare