Commit f8294f5e authored by Mahmood Ali's avatar Mahmood Ali
Browse files

Few Windows CI changes:

Always install go and vault: the check may accidentally use the CircleCI
pre-installed go version instead of the cached version.

Also, always install from sources without caching.  Go/vault
installation is basically a tarball download.  That's equivalent to
CirleCI caching without the complexity.  These steps don't add much time
either.

Lastly, infer the OS when downloading tarball to avoid managing them in
the job spec.
parent 4c679d4c
Showing with 316 additions and 342 deletions
+316 -342
This diff is collapsed.
......@@ -2,9 +2,6 @@ parameters:
target_directory:
type: string
default: /usr/local
os:
type: string
default: linux
steps:
- run:
name: Install golang
......@@ -13,20 +10,24 @@ steps:
echo installing golang ${GOLANG_VERSION}
if [[ << parameters.os >> != "windows" ]]
case "${OSTYPE}" in
linux*) os="linux" ;;
darwin*) os="darwin" ;;
msys*) os="windows" ;;
*) echo "unknown os: ${OSTYPE}"; exit 1 ;;
esac
if [[ "${os}" != "windows" ]]
then
sudo rm -rf << parameters.target_directory >>/go
sudo mkdir -p << parameters.target_directory >>
curl -SL --fail -o /tmp/golang.tar.gz https://dl.google.com/go/go${GOLANG_VERSION}.<< parameters.os >>-amd64.tar.gz
curl -SL --fail -o /tmp/golang.tar.gz https://dl.google.com/go/go${GOLANG_VERSION}.${os}-amd64.tar.gz
sudo tar -C << parameters.target_directory >> -xzf /tmp/golang.tar.gz
rm -rf /tmp/golang.tar.gz
else
if [[ ! -d "c:\go" ]]
then
echo "Cache not found, doing a fresh install of go"
rm -rf << parameters.target_directory >>/go
mkdir -p <<parameters.target_directory >>
curl -SL --fail -o go.zip https://dl.google.com/go/go${GOLANG_VERSION}.<< parameters.os >>-amd64.zip
unzip -o go.zip -d "/c"
fi
rm -rf << parameters.target_directory >>/go
mkdir -p <<parameters.target_directory >>
curl -SL --fail -o /tmp/go.zip https://dl.google.com/go/go${GOLANG_VERSION}.windows-amd64.zip
unzip -o /tmp/go.zip -d << parameters.target_directory >>
rm -rf /tmp/go.zip
fi
......@@ -2,28 +2,26 @@ parameters:
version:
type: string
default: 1.2.4
os:
type: string
default: linux
steps:
- run:
name: Install Vault
command: |
set -x
curl -SL --fail -o /tmp/vault.zip https://releases.hashicorp.com/vault/"<< parameters.version >>"/vault_"<< parameters.version >>"_"<< parameters.os >>"_amd64.zip
case "${OSTYPE}" in
linux*) os="linux" ;;
darwin*) os="darwin" ;;
msys*) os="windows" ;;
*) echo "unknown os: ${OSTYPE}"; exit 1 ;;
esac
curl -SL --fail -o /tmp/vault.zip https://releases.hashicorp.com/vault/"<< parameters.version >>"/vault_"<< parameters.version >>"_"${os}"_amd64.zip
if [[ << parameters.os >> == "linux" ]]
then
if [[ "${os}" != "windows" ]]; then
sudo unzip -d /usr/local/bin /tmp/vault.zip
rm -rf /tmp/vault*
fi
if [[ << parameters.os >> == "windows" ]]
then
if [[ ! -f "c:\Windows\vault.exe" ]]
then
echo "Cache not found, doing a fresh install of vault"
unzip /tmp/vault.zip -d "/c/Windows"
rm -rf /tmp/vault*
fi
else
rm -rf c:\Windows\vault.exe
unzip /tmp/vault.zip -d "/c/Windows"
rm -rf /tmp/vault*
fi
......@@ -8,7 +8,6 @@ steps:
- install-golang:
target_directory: ~/goinstall
os: darwin
- run: source ${BASH_ENV} && make deps
- run: brew install protobuf
- run: sudo -E PATH="$GOPATH/bin:${HOME}/goinstall/go/bin:$PATH" make generate-structs
......
......@@ -8,71 +8,34 @@ steps:
command: |
mkdir -p $GOBIN
mkdir -p $GOTESTSUM_PATH
echo "$GOLANG_VERSION" > ~/GOLANG_VERSION.txt
echo "$GOTESTSUM_VERSION" > ~/GOTESTSUM_VERSION.txt
echo "$VAULT_VERSION" > ~/VAULT_VERSION.txt
- restore_cache:
keys:
- win-golang-cache-{{ checksum "~/GOLANG_VERSION.txt" }}-v1
- restore_cache:
keys:
- win-gotestsum-cache-{{ checksum "~/GOTESTSUM_VERSION.txt" }}-v1
- restore_cache:
keys:
- win-vault-cache-{{ checksum "~/VAULT_VERSION.txt" }}-v1
- restore_cache:
keys:
- win-gobuild-cache-{{ checksum "/gopath/src/github.com/hashicorp/nomad/api/go.sum" }}-v1
- install-golang:
target_directory: "c:"
os: windows
- run: go version
- save_cache:
key: win-golang-cache-{{ checksum "~/GOLANG_VERSION.txt" }}-v1
paths:
- /go
- run: go version
- install-gotestsum:
os: windows
version: $GOTESTSUM_VERSION
- save_cache:
key: win-gotestsum-cache-{{ checksum "~/GOTESTSUM_VERSION.txt" }}-v1
paths:
- c:\Windows\gotestsum.exe
- install-vault:
os: windows
version: $VAULT_VERSION
- save_cache:
key: win-vault-cache-{{ checksum "~/VAULT_VERSION.txt" }}-v1
paths:
- c:\Windows\vault.exe
- run: vault version
- run: choco install make
- run:
name: Install golang dependencies
command: |
export PATH=$PATH:c/gopath/bin
go get -u github.com/kardianos/govendor
go get -u github.com/ugorji/go/codec/codecgen
go get -u github.com/hashicorp/go-bindata/go-bindata
go get -u github.com/elazarl/go-bindata-assetfs/go-bindata-assetfs
go get -u github.com/a8m/tree/cmd/tree
go get -u github.com/magiconair/vendorfmt/cmd/vendorfmt
go get -u github.com/golang/protobuf/protoc-gen-go
go get -u gotest.tools/gotestsum
export PATH=$PATH:/c/go/bin:/c/gopath/bin
make deps
- run:
name: Build nomad
command: |
export PATH=$PATH:/c/go/bin:/c/gopath/bin
go build -o $GOBIN\nomad.exe
- save_cache:
key: win-gobuild-cache-{{ checksum "/gopath/src/github.com/hashicorp/nomad/api/go.sum" }}-v1
paths:
- c:\Users\circleci\AppData\Local\go-build
- run:
name: Run tests with gotestsum
command: |
# Only test docker driver tests for now
gotestsum --format=short-verbose --junitfile $GOTESTSUM_PATH/results.xml github.com/hashicorp/nomad/drivers/docker github.com/hashicorp/nomad/client/lib/fifo github.com/hashicorp/nomad/client/logmon
export PATH=$PATH:/c/go/bin:/c/gopath/bin
gotestsum --format=short-verbose \
--junitfile $GOTESTSUM_PATH/results.xml \
github.com/hashicorp/nomad/drivers/docker \
github.com/hashicorp/nomad/client/lib/fifo \
github.com/hashicorp/nomad/client/logmon
- store_test_results:
path: c:\tmp\test-reports
- store_artifacts:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment