diff --git a/.circleci/config.yml b/.circleci/config.yml index 751cc4e29..2f656dc42 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -26,19 +26,30 @@ jobs: command: | set -x - os="linux" - if [[ "$OSTYPE" == "darwin"* ]] - then - os="darwin" - fi - echo installing golang ${GOLANG_VERSION} - sudo rm -rf /usr/local/go - sudo mkdir -p /usr/local - curl -SL --fail -o /tmp/golang.tar.gz https://dl.google.com/go/go${GOLANG_VERSION}.${os}-amd64.tar.gz - sudo tar -C /usr/local -xzf /tmp/golang.tar.gz - rm -rf /tmp/golang.tar.gz - name: install golang + + 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 /usr/local/go + sudo mkdir -p /usr/local + curl -SL --fail -o /tmp/golang.tar.gz https://dl.google.com/go/go${GOLANG_VERSION}.${os}-amd64.tar.gz + sudo tar -C /usr/local -xzf /tmp/golang.tar.gz + rm -rf /tmp/golang.tar.gz + else + rm -rf /usr/local/go + mkdir -p /usr/local + curl -SL --fail -o /tmp/go.zip https://dl.google.com/go/go${GOLANG_VERSION}.windows-amd64.zip + unzip -q -o /tmp/go.zip -d /usr/local + rm -rf /tmp/go.zip + fi + name: Install golang - run: command: | sudo rm -rf /usr/bin/protoc @@ -52,10 +63,26 @@ jobs: name: Install Consul 1.6.4 - run: command: | - curl -SL --fail -o /tmp/vault.zip https://releases.hashicorp.com/vault/1.2.4/vault_1.2.4_linux_amd64.zip - sudo unzip -d /usr/local/bin /tmp/vault.zip - rm -rf /tmp/vault* - name: Install Vault 1.2.4 + set -x + + 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/"1.2.4"/vault_"1.2.4"_"${os}"_amd64.zip + + if [[ "${os}" != "windows" ]]; then + sudo unzip -d /usr/local/bin /tmp/vault.zip + rm -rf /tmp/vault* + else + rm -rf c:\Windows\vault.exe + unzip /tmp/vault.zip -d "/c/Windows" + rm -rf /tmp/vault* + fi + name: Install Vault - run: command: | if [ ! -z $GOTESTARCH ] && [ $GOTESTARCH == "386" ]; then @@ -111,19 +138,30 @@ jobs: command: | set -x - os="linux" - if [[ "$OSTYPE" == "darwin"* ]] - then - os="darwin" - fi - echo installing golang ${GOLANG_VERSION} - sudo rm -rf /usr/local/go - sudo mkdir -p /usr/local - curl -SL --fail -o /tmp/golang.tar.gz https://dl.google.com/go/go${GOLANG_VERSION}.${os}-amd64.tar.gz - sudo tar -C /usr/local -xzf /tmp/golang.tar.gz - rm -rf /tmp/golang.tar.gz - name: install golang + + 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 /usr/local/go + sudo mkdir -p /usr/local + curl -SL --fail -o /tmp/golang.tar.gz https://dl.google.com/go/go${GOLANG_VERSION}.${os}-amd64.tar.gz + sudo tar -C /usr/local -xzf /tmp/golang.tar.gz + rm -rf /tmp/golang.tar.gz + else + rm -rf /usr/local/go + mkdir -p /usr/local + curl -SL --fail -o /tmp/go.zip https://dl.google.com/go/go${GOLANG_VERSION}.windows-amd64.zip + unzip -q -o /tmp/go.zip -d /usr/local + rm -rf /tmp/go.zip + fi + name: Install golang - run: command: | sudo rm -rf /usr/bin/protoc @@ -137,10 +175,26 @@ jobs: name: Install Consul 1.6.4 - run: command: | - curl -SL --fail -o /tmp/vault.zip https://releases.hashicorp.com/vault/1.2.4/vault_1.2.4_linux_amd64.zip - sudo unzip -d /usr/local/bin /tmp/vault.zip - rm -rf /tmp/vault* - name: Install Vault 1.2.4 + set -x + + 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/"1.2.4"/vault_"1.2.4"_"${os}"_amd64.zip + + if [[ "${os}" != "windows" ]]; then + sudo unzip -d /usr/local/bin /tmp/vault.zip + rm -rf /tmp/vault* + else + rm -rf c:\Windows\vault.exe + unzip /tmp/vault.zip -d "/c/Windows" + rm -rf /tmp/vault* + fi + name: Install Vault - run: command: | if [ ! -z $GOTESTARCH ] && [ $GOTESTARCH == "386" ]; then @@ -196,19 +250,30 @@ jobs: command: | set -x - os="linux" - if [[ "$OSTYPE" == "darwin"* ]] - then - os="darwin" - fi - echo installing golang ${GOLANG_VERSION} - sudo rm -rf /usr/local/go - sudo mkdir -p /usr/local - curl -SL --fail -o /tmp/golang.tar.gz https://dl.google.com/go/go${GOLANG_VERSION}.${os}-amd64.tar.gz - sudo tar -C /usr/local -xzf /tmp/golang.tar.gz - rm -rf /tmp/golang.tar.gz - name: install golang + + 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 /usr/local/go + sudo mkdir -p /usr/local + curl -SL --fail -o /tmp/golang.tar.gz https://dl.google.com/go/go${GOLANG_VERSION}.${os}-amd64.tar.gz + sudo tar -C /usr/local -xzf /tmp/golang.tar.gz + rm -rf /tmp/golang.tar.gz + else + rm -rf /usr/local/go + mkdir -p /usr/local + curl -SL --fail -o /tmp/go.zip https://dl.google.com/go/go${GOLANG_VERSION}.windows-amd64.zip + unzip -q -o /tmp/go.zip -d /usr/local + rm -rf /tmp/go.zip + fi + name: Install golang - run: command: | sudo rm -rf /usr/bin/protoc @@ -222,10 +287,26 @@ jobs: name: Install Consul 1.6.4 - run: command: | - curl -SL --fail -o /tmp/vault.zip https://releases.hashicorp.com/vault/1.2.4/vault_1.2.4_linux_amd64.zip - sudo unzip -d /usr/local/bin /tmp/vault.zip - rm -rf /tmp/vault* - name: Install Vault 1.2.4 + set -x + + 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/"1.2.4"/vault_"1.2.4"_"${os}"_amd64.zip + + if [[ "${os}" != "windows" ]]; then + sudo unzip -d /usr/local/bin /tmp/vault.zip + rm -rf /tmp/vault* + else + rm -rf c:\Windows\vault.exe + unzip /tmp/vault.zip -d "/c/Windows" + rm -rf /tmp/vault* + fi + name: Install Vault - run: command: | if [ ! -z $GOTESTARCH ] && [ $GOTESTARCH == "386" ]; then @@ -281,19 +362,30 @@ jobs: command: | set -x - os="linux" - if [[ "$OSTYPE" == "darwin"* ]] - then - os="darwin" - fi - echo installing golang ${GOLANG_VERSION} - sudo rm -rf /usr/local/go - sudo mkdir -p /usr/local - curl -SL --fail -o /tmp/golang.tar.gz https://dl.google.com/go/go${GOLANG_VERSION}.${os}-amd64.tar.gz - sudo tar -C /usr/local -xzf /tmp/golang.tar.gz - rm -rf /tmp/golang.tar.gz - name: install golang + + 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 /usr/local/go + sudo mkdir -p /usr/local + curl -SL --fail -o /tmp/golang.tar.gz https://dl.google.com/go/go${GOLANG_VERSION}.${os}-amd64.tar.gz + sudo tar -C /usr/local -xzf /tmp/golang.tar.gz + rm -rf /tmp/golang.tar.gz + else + rm -rf /usr/local/go + mkdir -p /usr/local + curl -SL --fail -o /tmp/go.zip https://dl.google.com/go/go${GOLANG_VERSION}.windows-amd64.zip + unzip -q -o /tmp/go.zip -d /usr/local + rm -rf /tmp/go.zip + fi + name: Install golang - run: command: | sudo rm -rf /usr/bin/protoc @@ -307,10 +399,26 @@ jobs: name: Install Consul 1.6.4 - run: command: | - curl -SL --fail -o /tmp/vault.zip https://releases.hashicorp.com/vault/1.2.4/vault_1.2.4_linux_amd64.zip - sudo unzip -d /usr/local/bin /tmp/vault.zip - rm -rf /tmp/vault* - name: Install Vault 1.2.4 + set -x + + 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/"1.2.4"/vault_"1.2.4"_"${os}"_amd64.zip + + if [[ "${os}" != "windows" ]]; then + sudo unzip -d /usr/local/bin /tmp/vault.zip + rm -rf /tmp/vault* + else + rm -rf c:\Windows\vault.exe + unzip /tmp/vault.zip -d "/c/Windows" + rm -rf /tmp/vault* + fi + name: Install Vault - run: command: | if [ ! -z $GOTESTARCH ] && [ $GOTESTARCH == "386" ]; then @@ -344,6 +452,111 @@ jobs: path: /tmp/test-reports - store_artifacts: path: /tmp/test-reports + test-windows: + machine: + image: windows-server-2019-vs2019:stable + working_directory: c:\gopath\src\github.com\hashicorp\nomad + steps: + - run: + command: git config --global core.autocrlf false + - checkout + - run: + command: | + mkdir -p $GOBIN + mkdir -p $GOTESTSUM_PATH + name: Setup + - run: + command: | + set -x + + echo installing golang ${GOLANG_VERSION} + + 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 c:/go + sudo mkdir -p c: + curl -SL --fail -o /tmp/golang.tar.gz https://dl.google.com/go/go${GOLANG_VERSION}.${os}-amd64.tar.gz + sudo tar -C c: -xzf /tmp/golang.tar.gz + rm -rf /tmp/golang.tar.gz + else + rm -rf c:/go + mkdir -p c: + curl -SL --fail -o /tmp/go.zip https://dl.google.com/go/go${GOLANG_VERSION}.windows-amd64.zip + unzip -q -o /tmp/go.zip -d c: + rm -rf /tmp/go.zip + fi + name: Install golang + - run: + command: go version + - run: + command: | + set -x + + 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/"$VAULT_VERSION"/vault_"$VAULT_VERSION"_"${os}"_amd64.zip + + if [[ "${os}" != "windows" ]]; then + sudo unzip -d /usr/local/bin /tmp/vault.zip + rm -rf /tmp/vault* + else + rm -rf c:\Windows\vault.exe + unzip /tmp/vault.zip -d "/c/Windows" + rm -rf /tmp/vault* + fi + name: Install Vault + - run: + command: vault version + - run: + command: choco install make + - run: + command: | + export PATH=$PATH:/c/go/bin:/c/gopath/bin + make deps + name: Install golang dependencies + - run: + command: docker pull hashicorpnomad/busybox-windows:server2016-0.1 + name: Pre-download docker test image + - run: + command: | + export PATH=$PATH:/c/go/bin:/c/gopath/bin + go build -o $GOBIN\nomad.exe + name: Build nomad + - run: + command: | + # Only test docker driver tests for now + 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 + name: Run tests with gotestsum + - store_test_results: + path: c:\tmp\test-reports + - store_artifacts: + path: c:\tmp\test-reports + environment: + - GOBIN: c:\gopath\bin + - GOLANG_VERSION: 1.14.1 + - GOPATH: c:\gopath + - GOTESTSUM_PATH: c:\tmp\test-reports + - GOTESTSUM_VERSION: 0.4.2 + - VAULT_VERSION: 1.4.1 + resource_class: windows.medium + shell: bash --login -eo pipefail test-shared-exec: machine: image: ubuntu-1604:201903-01 @@ -366,19 +579,30 @@ jobs: command: | set -x - os="linux" - if [[ "$OSTYPE" == "darwin"* ]] - then - os="darwin" - fi - echo installing golang ${GOLANG_VERSION} - sudo rm -rf /usr/local/go - sudo mkdir -p /usr/local - curl -SL --fail -o /tmp/golang.tar.gz https://dl.google.com/go/go${GOLANG_VERSION}.${os}-amd64.tar.gz - sudo tar -C /usr/local -xzf /tmp/golang.tar.gz - rm -rf /tmp/golang.tar.gz - name: install golang + + 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 /usr/local/go + sudo mkdir -p /usr/local + curl -SL --fail -o /tmp/golang.tar.gz https://dl.google.com/go/go${GOLANG_VERSION}.${os}-amd64.tar.gz + sudo tar -C /usr/local -xzf /tmp/golang.tar.gz + rm -rf /tmp/golang.tar.gz + else + rm -rf /usr/local/go + mkdir -p /usr/local + curl -SL --fail -o /tmp/go.zip https://dl.google.com/go/go${GOLANG_VERSION}.windows-amd64.zip + unzip -q -o /tmp/go.zip -d /usr/local + rm -rf /tmp/go.zip + fi + name: Install golang - run: command: | sudo rm -rf /usr/bin/protoc @@ -392,10 +616,26 @@ jobs: name: Install Consul 1.6.4 - run: command: | - curl -SL --fail -o /tmp/vault.zip https://releases.hashicorp.com/vault/1.2.4/vault_1.2.4_linux_amd64.zip - sudo unzip -d /usr/local/bin /tmp/vault.zip - rm -rf /tmp/vault* - name: Install Vault 1.2.4 + set -x + + 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/"1.2.4"/vault_"1.2.4"_"${os}"_amd64.zip + + if [[ "${os}" != "windows" ]]; then + sudo unzip -d /usr/local/bin /tmp/vault.zip + rm -rf /tmp/vault* + else + rm -rf c:\Windows\vault.exe + unzip /tmp/vault.zip -d "/c/Windows" + rm -rf /tmp/vault* + fi + name: Install Vault - run: command: | if [ ! -z $GOTESTARCH ] && [ $GOTESTARCH == "386" ]; then @@ -542,19 +782,30 @@ jobs: command: | set -x - os="linux" - if [[ "$OSTYPE" == "darwin"* ]] - then - os="darwin" - fi - echo installing golang ${GOLANG_VERSION} - sudo rm -rf /usr/local/go - sudo mkdir -p /usr/local - curl -SL --fail -o /tmp/golang.tar.gz https://dl.google.com/go/go${GOLANG_VERSION}.${os}-amd64.tar.gz - sudo tar -C /usr/local -xzf /tmp/golang.tar.gz - rm -rf /tmp/golang.tar.gz - name: install golang + + 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 /usr/local/go + sudo mkdir -p /usr/local + curl -SL --fail -o /tmp/golang.tar.gz https://dl.google.com/go/go${GOLANG_VERSION}.${os}-amd64.tar.gz + sudo tar -C /usr/local -xzf /tmp/golang.tar.gz + rm -rf /tmp/golang.tar.gz + else + rm -rf /usr/local/go + mkdir -p /usr/local + curl -SL --fail -o /tmp/go.zip https://dl.google.com/go/go${GOLANG_VERSION}.windows-amd64.zip + unzip -q -o /tmp/go.zip -d /usr/local + rm -rf /tmp/go.zip + fi + name: Install golang - run: command: | sudo rm -rf /usr/bin/protoc @@ -568,10 +819,26 @@ jobs: name: Install Consul 1.6.4 - run: command: | - curl -SL --fail -o /tmp/vault.zip https://releases.hashicorp.com/vault/1.2.4/vault_1.2.4_linux_amd64.zip - sudo unzip -d /usr/local/bin /tmp/vault.zip - rm -rf /tmp/vault* - name: Install Vault 1.2.4 + set -x + + 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/"1.2.4"/vault_"1.2.4"_"${os}"_amd64.zip + + if [[ "${os}" != "windows" ]]; then + sudo unzip -d /usr/local/bin /tmp/vault.zip + rm -rf /tmp/vault* + else + rm -rf c:\Windows\vault.exe + unzip /tmp/vault.zip -d "/c/Windows" + rm -rf /tmp/vault* + fi + name: Install Vault - run: command: | if [ ! -z $GOTESTARCH ] && [ $GOTESTARCH == "386" ]; then @@ -639,10 +906,26 @@ jobs: name: Install Consul 1.6.4 - run: command: | - curl -SL --fail -o /tmp/vault.zip https://releases.hashicorp.com/vault/1.2.4/vault_1.2.4_linux_amd64.zip - sudo unzip -d /usr/local/bin /tmp/vault.zip - rm -rf /tmp/vault* - name: Install Vault 1.2.4 + set -x + + 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/"1.2.4"/vault_"1.2.4"_"${os}"_amd64.zip + + if [[ "${os}" != "windows" ]]; then + sudo unzip -d /usr/local/bin /tmp/vault.zip + rm -rf /tmp/vault* + else + rm -rf c:\Windows\vault.exe + unzip /tmp/vault.zip -d "/c/Windows" + rm -rf /tmp/vault* + fi + name: Install Vault - run: command: | if [ -z $GOTEST_PKGS_EXCLUDE ]; @@ -678,19 +961,30 @@ jobs: command: | set -x - os="linux" - if [[ "$OSTYPE" == "darwin"* ]] - then - os="darwin" - fi - echo installing golang ${GOLANG_VERSION} - sudo rm -rf ~/goinstall/go - sudo mkdir -p ~/goinstall - curl -SL --fail -o /tmp/golang.tar.gz https://dl.google.com/go/go${GOLANG_VERSION}.${os}-amd64.tar.gz - sudo tar -C ~/goinstall -xzf /tmp/golang.tar.gz - rm -rf /tmp/golang.tar.gz - name: install golang + + 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 ~/goinstall/go + sudo mkdir -p ~/goinstall + curl -SL --fail -o /tmp/golang.tar.gz https://dl.google.com/go/go${GOLANG_VERSION}.${os}-amd64.tar.gz + sudo tar -C ~/goinstall -xzf /tmp/golang.tar.gz + rm -rf /tmp/golang.tar.gz + else + rm -rf ~/goinstall/go + mkdir -p ~/goinstall + curl -SL --fail -o /tmp/go.zip https://dl.google.com/go/go${GOLANG_VERSION}.windows-amd64.zip + unzip -q -o /tmp/go.zip -d ~/goinstall + rm -rf /tmp/go.zip + fi + name: Install golang - run: command: source ${BASH_ENV} && make deps - run: @@ -733,19 +1027,30 @@ jobs: command: | set -x - os="linux" - if [[ "$OSTYPE" == "darwin"* ]] - then - os="darwin" - fi - echo installing golang ${GOLANG_VERSION} - sudo rm -rf /usr/local/go - sudo mkdir -p /usr/local - curl -SL --fail -o /tmp/golang.tar.gz https://dl.google.com/go/go${GOLANG_VERSION}.${os}-amd64.tar.gz - sudo tar -C /usr/local -xzf /tmp/golang.tar.gz - rm -rf /tmp/golang.tar.gz - name: install golang + + 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 /usr/local/go + sudo mkdir -p /usr/local + curl -SL --fail -o /tmp/golang.tar.gz https://dl.google.com/go/go${GOLANG_VERSION}.${os}-amd64.tar.gz + sudo tar -C /usr/local -xzf /tmp/golang.tar.gz + rm -rf /tmp/golang.tar.gz + else + rm -rf /usr/local/go + mkdir -p /usr/local + curl -SL --fail -o /tmp/go.zip https://dl.google.com/go/go${GOLANG_VERSION}.windows-amd64.zip + unzip -q -o /tmp/go.zip -d /usr/local + rm -rf /tmp/go.zip + fi + name: Install golang - run: command: | sudo rm -rf /usr/bin/protoc @@ -759,10 +1064,26 @@ jobs: name: Install Consul 1.6.4 - run: command: | - curl -SL --fail -o /tmp/vault.zip https://releases.hashicorp.com/vault/1.2.4/vault_1.2.4_linux_amd64.zip - sudo unzip -d /usr/local/bin /tmp/vault.zip - rm -rf /tmp/vault* - name: Install Vault 1.2.4 + set -x + + 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/"1.2.4"/vault_"1.2.4"_"${os}"_amd64.zip + + if [[ "${os}" != "windows" ]]; then + sudo unzip -d /usr/local/bin /tmp/vault.zip + rm -rf /tmp/vault* + else + rm -rf c:\Windows\vault.exe + unzip /tmp/vault.zip -d "/c/Windows" + rm -rf /tmp/vault* + fi + name: Install Vault - run: command: | if [ ! -z $GOTESTARCH ] && [ $GOTESTARCH == "386" ]; then @@ -880,19 +1201,30 @@ jobs: command: | set -x - os="linux" - if [[ "$OSTYPE" == "darwin"* ]] - then - os="darwin" - fi - echo installing golang ${GOLANG_VERSION} - sudo rm -rf /usr/local/go - sudo mkdir -p /usr/local - curl -SL --fail -o /tmp/golang.tar.gz https://dl.google.com/go/go${GOLANG_VERSION}.${os}-amd64.tar.gz - sudo tar -C /usr/local -xzf /tmp/golang.tar.gz - rm -rf /tmp/golang.tar.gz - name: install golang + + 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 /usr/local/go + sudo mkdir -p /usr/local + curl -SL --fail -o /tmp/golang.tar.gz https://dl.google.com/go/go${GOLANG_VERSION}.${os}-amd64.tar.gz + sudo tar -C /usr/local -xzf /tmp/golang.tar.gz + rm -rf /tmp/golang.tar.gz + else + rm -rf /usr/local/go + mkdir -p /usr/local + curl -SL --fail -o /tmp/go.zip https://dl.google.com/go/go${GOLANG_VERSION}.windows-amd64.zip + unzip -q -o /tmp/go.zip -d /usr/local + rm -rf /tmp/go.zip + fi + name: Install golang - run: command: | sudo rm -rf /usr/bin/protoc @@ -906,10 +1238,26 @@ jobs: name: Install Consul 1.6.4 - run: command: | - curl -SL --fail -o /tmp/vault.zip https://releases.hashicorp.com/vault/1.2.4/vault_1.2.4_linux_amd64.zip - sudo unzip -d /usr/local/bin /tmp/vault.zip - rm -rf /tmp/vault* - name: Install Vault 1.2.4 + set -x + + 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/"1.2.4"/vault_"1.2.4"_"${os}"_amd64.zip + + if [[ "${os}" != "windows" ]]; then + sudo unzip -d /usr/local/bin /tmp/vault.zip + rm -rf /tmp/vault* + else + rm -rf c:\Windows\vault.exe + unzip /tmp/vault.zip -d "/c/Windows" + rm -rf /tmp/vault* + fi + name: Install Vault - run: command: | if [ ! -z $GOTESTARCH ] && [ $GOTESTARCH == "386" ]; then @@ -966,6 +1314,13 @@ workflows: - /^.-ui\b.*/ - /^docs-.*/ - stable-website + - test-windows: + filters: + branches: + ignore: + - /^.-ui\b.*/ + - /^docs-.*/ + - stable-website - test-client: filters: branches: diff --git a/.circleci/config/commands/install-golang.yml b/.circleci/config/commands/install-golang.yml index 4f0771fd7..00de89328 100644 --- a/.circleci/config/commands/install-golang.yml +++ b/.circleci/config/commands/install-golang.yml @@ -2,22 +2,32 @@ parameters: target_directory: type: string default: /usr/local - steps: - run: - name: install golang + name: Install golang command: | set -x - os="linux" - if [[ "$OSTYPE" == "darwin"* ]] - then - os="darwin" - fi - echo installing golang ${GOLANG_VERSION} - 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}.${os}-amd64.tar.gz - sudo tar -C << parameters.target_directory >> -xzf /tmp/golang.tar.gz - rm -rf /tmp/golang.tar.gz + + 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}.${os}-amd64.tar.gz + sudo tar -C << parameters.target_directory >> -xzf /tmp/golang.tar.gz + rm -rf /tmp/golang.tar.gz + else + rm -rf << parameters.target_directory >>/go + mkdir -p <> + curl -SL --fail -o /tmp/go.zip https://dl.google.com/go/go${GOLANG_VERSION}.windows-amd64.zip + unzip -q -o /tmp/go.zip -d << parameters.target_directory >> + rm -rf /tmp/go.zip + fi diff --git a/.circleci/config/commands/install-vault.yml b/.circleci/config/commands/install-vault.yml index 264fbb4b0..ba325b4c6 100644 --- a/.circleci/config/commands/install-vault.yml +++ b/.circleci/config/commands/install-vault.yml @@ -4,8 +4,24 @@ parameters: default: 1.2.4 steps: - run: - name: Install Vault << parameters.version >> + name: Install Vault command: | - curl -SL --fail -o /tmp/vault.zip https://releases.hashicorp.com/vault/<< parameters.version >>/vault_<< parameters.version>>_linux_amd64.zip - sudo unzip -d /usr/local/bin /tmp/vault.zip - rm -rf /tmp/vault* + set -x + + 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 [[ "${os}" != "windows" ]]; then + sudo unzip -d /usr/local/bin /tmp/vault.zip + rm -rf /tmp/vault* + else + rm -rf c:\Windows\vault.exe + unzip /tmp/vault.zip -d "/c/Windows" + rm -rf /tmp/vault* + fi diff --git a/.circleci/config/config.yml b/.circleci/config/config.yml index 45de96c04..3173eba09 100644 --- a/.circleci/config/config.yml +++ b/.circleci/config/config.yml @@ -6,6 +6,8 @@ references: circleci/classic:201808-01 go-machine-recent-image: &go_machine_recent_image ubuntu-1604:201903-01 + go-windows-image: &go_windows_image + windows-server-2019-vs2019:stable # common references common_envs: &common_envs @@ -52,3 +54,17 @@ executors: <<: *common_envs GOPATH: /Users/distiller/go GOLANG_VERSION: 1.14 + + go-windows: + machine: + image: *go_windows_image + resource_class: windows.medium + shell: bash --login -eo pipefail + working_directory: c:\gopath\src\github.com\hashicorp\nomad + environment: + GOPATH: c:\gopath + GOBIN: c:\gopath\bin + GOTESTSUM_PATH: c:\tmp\test-reports + GOLANG_VERSION: 1.14.1 + GOTESTSUM_VERSION: 0.4.2 + VAULT_VERSION: 1.4.1 diff --git a/.circleci/config/jobs/test-windows.yml b/.circleci/config/jobs/test-windows.yml new file mode 100644 index 000000000..40642d46d --- /dev/null +++ b/.circleci/config/jobs/test-windows.yml @@ -0,0 +1,45 @@ +executor: go-windows + +steps: + - run: git config --global core.autocrlf false + - checkout + - run: + name: Setup + command: | + mkdir -p $GOBIN + mkdir -p $GOTESTSUM_PATH + - install-golang: + target_directory: "c:" + - run: go version + - install-vault: + version: $VAULT_VERSION + - run: vault version + - run: choco install make + - run: + name: Install golang dependencies + command: | + export PATH=$PATH:/c/go/bin:/c/gopath/bin + make deps + - run: + name: Pre-download docker test image + command: docker pull hashicorpnomad/busybox-windows:server2016-0.1 + - run: + name: Build nomad + command: | + export PATH=$PATH:/c/go/bin:/c/gopath/bin + go build -o $GOBIN\nomad.exe + - run: + name: Run tests with gotestsum + command: | + # Only test docker driver tests for now + 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: + path: c:\tmp\test-reports diff --git a/.circleci/config/workflows/build-test.yml b/.circleci/config/workflows/build-test.yml index 6184f1713..edc16ecb7 100644 --- a/.circleci/config/workflows/build-test.yml +++ b/.circleci/config/workflows/build-test.yml @@ -1,75 +1,75 @@ jobs: -- build-binaries: - # almost always build binaries as they may be needed - # for e2e tests - filters: - branches: - ignore: - - stable-website - - /^.-ui\b.*/ -- lint-go: - filters: &backend_branches_filter - branches: - ignore: - - /^.-ui\b.*/ - - /^docs-.*/ - - stable-website + - build-binaries: + # almost always build binaries as they may be needed + # for e2e tests + filters: + branches: + ignore: + - stable-website + - /^.-ui\b.*/ + - lint-go: + filters: &backend_branches_filter + branches: + ignore: + - /^.-ui\b.*/ + - /^docs-.*/ + - stable-website -- build-darwin-binaries: - # almost always build binaries as they may be needed - # for e2e tests - filters: *backend_branches_filter + - build-darwin-binaries: + filters: *backend_branches_filter + - test-windows: + filters: *backend_branches_filter -- test-machine: - name: "test-client" - test_packages: "./client/..." - filters: *backend_branches_filter -- test-machine: - name: "test-nomad" - test_packages: "./nomad/..." - filters: *backend_branches_filter -- test-machine: - # API Tests run in a VM rather than container due to the FS tests - # requiring `mount` priviliges. - name: "test-api" - test_packages: "./api/..." - filters: *backend_branches_filter -- test-container: - name: "test-devices" - test_packages: "./devices/..." - filters: *backend_branches_filter -- test-machine: - name: "test-other" - exclude_packages: "./api|./client|./drivers/docker|./drivers/exec|./drivers/shared/executor|./nomad|./devices" - filters: *backend_branches_filter -- test-machine: - name: "test-docker" - test_packages: "./drivers/docker" - # docker is misbehaving in docker-machine-recent image - # and we get unexpected failures - # e.g. https://circleci.com/gh/hashicorp/nomad/3854 - executor: go-machine - filters: *backend_branches_filter -- test-machine: - name: "test-exec" - test_packages: "./drivers/exec" - filters: *backend_branches_filter -- test-machine: - name: "test-shared-exec" - test_packages: "./drivers/shared/executor" - filters: *backend_branches_filter -- test-machine: - name: "test-32bit" - # Currently we only explicitly test fingerprinting on 32bit - # architectures. - test_packages: "./client/fingerprint" - goarch: "386" - filters: *backend_branches_filter -- test-e2e: - filters: *backend_branches_filter -- test-ui: - filters: - branches: - ignore: - - stable-website - - /^docs-.*/ + - test-machine: + name: "test-client" + test_packages: "./client/..." + filters: *backend_branches_filter + - test-machine: + name: "test-nomad" + test_packages: "./nomad/..." + filters: *backend_branches_filter + - test-machine: + # API Tests run in a VM rather than container due to the FS tests + # requiring `mount` priviliges. + name: "test-api" + test_packages: "./api/..." + filters: *backend_branches_filter + - test-container: + name: "test-devices" + test_packages: "./devices/..." + filters: *backend_branches_filter + - test-machine: + name: "test-other" + exclude_packages: "./api|./client|./drivers/docker|./drivers/exec|./drivers/shared/executor|./nomad|./devices" + filters: *backend_branches_filter + - test-machine: + name: "test-docker" + test_packages: "./drivers/docker" + # docker is misbehaving in docker-machine-recent image + # and we get unexpected failures + # e.g. https://circleci.com/gh/hashicorp/nomad/3854 + executor: go-machine + filters: *backend_branches_filter + - test-machine: + name: "test-exec" + test_packages: "./drivers/exec" + filters: *backend_branches_filter + - test-machine: + name: "test-shared-exec" + test_packages: "./drivers/shared/executor" + filters: *backend_branches_filter + - test-machine: + name: "test-32bit" + # Currently we only explicitly test fingerprinting on 32bit + # architectures. + test_packages: "./client/fingerprint" + goarch: "386" + filters: *backend_branches_filter + - test-e2e: + filters: *backend_branches_filter + - test-ui: + filters: + branches: + ignore: + - stable-website + - /^docs-.*/ diff --git a/GNUmakefile b/GNUmakefile index 34eaca9bc..311faf6f0 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,6 +1,6 @@ SHELL = bash PROJECT_ROOT := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST))))) -THIS_OS := $(shell uname) +THIS_OS := $(shell uname | cut -d- -f1) GIT_COMMIT := $(shell git rev-parse HEAD) GIT_DIRTY := $(if $(shell git status --porcelain),+CHANGES) @@ -8,7 +8,7 @@ GIT_DIRTY := $(if $(shell git status --porcelain),+CHANGES) GO_LDFLAGS := "-X github.com/hashicorp/nomad/version.GitCommit=$(GIT_COMMIT)$(GIT_DIRTY)" GO_TAGS ?= codegen_generated -GO_TEST_CMD = $(if $(shell which gotestsum),gotestsum --,go test) +GO_TEST_CMD = $(if $(shell command -v gotestsum 2>/dev/null),gotestsum --,go test) ifeq ($(origin GOTEST_PKGS_EXCLUDE), undefined) GOTEST_PKGS ?= "./..." @@ -18,8 +18,8 @@ endif default: help -ifeq (,$(findstring $(THIS_OS),Darwin Linux FreeBSD Windows)) -$(error Building Nomad is currently only supported on Darwin and Linux.) +ifeq (,$(findstring $(THIS_OS),Darwin Linux FreeBSD Windows MSYS_NT)) +$(error Building Nomad is currently only supported on Darwin and Linux; not $(THIS_OS)) endif # On Linux we build for Linux and Windows @@ -242,8 +242,7 @@ command/job_init.bindata_assetfs.go: command/assets/* .PHONY: vendorfmt vendorfmt: @echo "--> Formatting vendor/vendor.json" - test -x $(GOPATH)/bin/vendorfmt || go get -u github.com/magiconair/vendorfmt/cmd/vendorfmt - vendorfmt + vendorfmt .PHONY: changelogfmt changelogfmt: diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index d0b7ca171..000000000 --- a/appveyor.yml +++ /dev/null @@ -1,67 +0,0 @@ -version: "build-{branch}-{build}" -image: Visual Studio 2017 - -clone_folder: c:\gopath\src\github.com\hashicorp\nomad - -branches: - except: - - /^.-ui\b/ - -environment: - GOPATH: c:\gopath - GOBIN: c:\gopath\bin - GOMAXPROCS: 1 - -install: - # do basic docker smoke test, and pull image in preparation for tests - - cmd: docker info - - cmd: docker run --rm dantoml/busybox-windows:08012019 echo hi there - - - cmd: | - cd C:\go - del /F/Q/S *.* > NUL - cd %APPVEYOR_BUILD_FOLDER% - rmdir /Q/S C:\go - - # install the go version used for cutting a release - - cmd: | - mkdir c:\go - appveyor DownloadFile "https://dl.google.com/go/go1.14.1.windows-amd64.zip" -FileName "%TEMP%\\go.zip" - - - ps: Expand-Archive $Env:TEMP\go.zip -DestinationPath C:\ - - - cmd: set PATH=%GOBIN%;c:\go\bin;%PATH% - - cmd: echo %Path% - - cmd: go version - - cmd: go env - - ps: mkdir C:\gopath\bin - - ps: appveyor DownloadFile "https://releases.hashicorp.com/vault/0.10.2/vault_0.10.2_windows_amd64.zip" -FileName "C:\\gopath\\bin\\vault.zip" - - ps: Expand-Archive C:\gopath\bin\vault.zip -DestinationPath C:\gopath\bin - # - ps: appveyor DownloadFile "https://releases.hashicorp.com/consul/1.0.0/consul_1.0.0_windows_amd64.zip" -FileName "C:\\gopath\\bin\\consul.zip" - # - ps: Expand-Archive C:\gopath\bin\consul.zip -DestinationPath C:\gopath\bin - - ps: choco install make - - ps: | - 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 -build_script: - - cmd: | - set PATH=%GOPATH%/bin;%PATH% - go build -o %GOPATH%\bin\nomad.exe -test_script: - # only test docker driver tests for now - - cmd: - gotestsum --junitfile results.xml - github.com/hashicorp/nomad/drivers/docker - github.com/hashicorp/nomad/client/lib/fifo - github.com/hashicorp/nomad/client/logmon -# on_finish: -# - ps: | -# Push-AppveyorArtifact (Resolve-Path .\results.xml) -# $wc = New-Object 'System.Net.WebClient' -# $wc.UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\results.xml)) diff --git a/drivers/docker/docklog/docker_logger_test.go b/drivers/docker/docklog/docker_logger_test.go index 172f49546..012d066fb 100644 --- a/drivers/docker/docklog/docker_logger_test.go +++ b/drivers/docker/docklog/docker_logger_test.go @@ -18,9 +18,9 @@ import ( func testContainerDetails() (image string, imageName string, imageTag string) { if runtime.GOOS == "windows" { - return "dantoml/busybox-windows:08012019", - "dantoml/busybox-windows", - "08012019" + return "hashicorpnomad/busybox-windows:server2016-0.1", + "hashicorpnomad/busybox-windows", + "server2016-0.1" } return "busybox:1", "busybox", "1" diff --git a/drivers/docker/driver_test.go b/drivers/docker/driver_test.go index deb3d4b2a..eeee19607 100644 --- a/drivers/docker/driver_test.go +++ b/drivers/docker/driver_test.go @@ -455,7 +455,7 @@ func TestDockerDriver_Start_StoppedContainer(t *testing.T) { if runtime.GOOS != "windows" { imageID, err = d.Impl().(*Driver).loadImage(task, &taskCfg, client) } else { - image, lErr := client.InspectImage("dantoml/busybox-windows:08012019") + image, lErr := client.InspectImage("hashicorpnomad/busybox-windows:server2016-0.1") err = lErr if image != nil { imageID = image.ID diff --git a/drivers/docker/driver_windows_test.go b/drivers/docker/driver_windows_test.go index ffec23a5f..b7b722bb9 100644 --- a/drivers/docker/driver_windows_test.go +++ b/drivers/docker/driver_windows_test.go @@ -11,8 +11,7 @@ import ( func newTaskConfig(variant string, command []string) TaskConfig { // busyboxImageID is an id of an image containing nanoserver windows and // a busybox exe. - // See https://github.com/dantoml/windows/blob/81cff1ed77729d1fa36721abd6cb6efebff2f8ef/docker/busybox/Dockerfile - busyboxImageID := "dantoml/busybox-windows:08012019" + busyboxImageID := "hashicorpnomad/busybox-windows:server2016-0.1" return TaskConfig{ Image: busyboxImageID, diff --git a/scripts/update_golang_version.sh b/scripts/update_golang_version.sh index f281c11ec..3ed80e874 100755 --- a/scripts/update_golang_version.sh +++ b/scripts/update_golang_version.sh @@ -16,9 +16,6 @@ sed -i'' -e "s|GOLANG_VERSION:[ \"]*[.0-9]*\"*|GOLANG_VERSION: ${golang_version} sed -i'' -e "s|\\(golang.org.*version\\) [.0-9]*|\\1 ${golang_version}|g" \ README.md -sed -i'' -e "s|go[.0-9]*.windows-amd64.zip|go${golang_version}.windows-amd64.zip|g" \ - appveyor.yml - sed -i'' -e "s|go_version=\"*[^\"]*\"*$|go_version=\"${golang_version}\"|g" \ scripts/vagrant-linux-priv-go.sh scripts/release/mac-remote-build