diff --git a/.circleci/config.yml b/.circleci/config.yml index 4f04f89f3..00ff80d2e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,5 +1,49 @@ version: 2.1 +references: + GO_VERSION: &GOVERSION 1.12.1 +workflows: + build-test: + jobs: + - lint + - test-machine: + name: "test-client" + test_packages: "./client/..." + - test-machine: + name: "test-nomad" + test_packages: "./nomad/..." + - test-container: + name: "test-api" + test_packages: "./api/..." + - test-container: + name: "test-devices" + test_packages: "./devices/..." + - test-machine: + name: "test-other" + exclude_packages: "./api|./client|./drivers/docker|./drivers/exec|./drivers/rkt|./drivers/shared/executor|./nomad|./devices" + - test-machine: + name: "test-docker" + test_packages: "./drivers/docker" + - test-machine: + name: "test-exec" + test_packages: "./drivers/exec" + - test-machine: + name: "test-shared-exec" + test_packages: "./drivers/shared/executor" + - test-rkt + # - build-deps-image: + # context: dani-test + # filters: + # branches: + # only: dani/circleci + + website: + jobs: + - build-website: + context: static-sites + filters: + branches: + only: stable-website executors: go: working_directory: ~/go/src/github.com/hashicorp/nomad @@ -48,14 +92,7 @@ jobs: NOMAD_SLOW_TEST: 1 steps: - checkout - - run: | - if [ -z $GOTEST_PKGS_EXCLUDE ]; - then - unset GOTEST_PKGS_EXCLUDE - else - unset GOTEST_PKGS - fi - make test-nomad + - run-tests - store_test_results: path: /tmp @@ -65,8 +102,7 @@ jobs: GOTEST_PKGS: "./drivers/rkt" GOTESTSUM_JUNITFILE: /tmp/results.xml GOPATH: /home/circleci/go - GOVERSION: 1.12.1 - PROTOC_VERSION: 3.6.1 + GOVERSION: *GOVERSION GOMAXPROCS: 1 NOMAD_SLOW_TEST: 1 RKT_VERSION: 1.29.0 @@ -78,17 +114,7 @@ jobs: sudo rm -rf /usr/local/go wget https://dl.google.com/go/go$GOVERSION.linux-amd64.tar.gz sudo tar -C /usr/local -xzf go$GOVERSION.linux-amd64.tar.gz - - run: - name: install protoc - command: | - sudo rm -rf /usr/bin/protoc - wget -q -O /tmp/protoc.zip https://github.com/google/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip \ - && unzip /tmp/protoc.zip -d /tmp/protoc3 \ - && sudo mv /tmp/protoc3/bin/* /usr/local/bin/ \ - && sudo mv /tmp/protoc3/include/* /usr/local/include/ \ - && sudo ln -s /usr/local/bin/protoc /usr/bin/protoc \ - && rm -rf /tmp/protoc* - + - install-protoc - run: name: install rkt command: | @@ -98,8 +124,7 @@ jobs: gpg --verify rkt_$RKT_VERSION-1_amd64.deb.asc sudo dpkg -i rkt_$RKT_VERSION-1_amd64.deb - run: PATH="$GOPATH/bin:/usr/local/go/bin:$PATH" make bootstrap - - run: | - sudo -E PATH="$GOPATH/bin:/usr/local/go/bin:$PATH" make test-nomad + - run-tests - store_test_results: path: /tmp @@ -117,8 +142,7 @@ jobs: GOTEST_PKGS: "<< parameters.test_packages >>" GOTESTSUM_JUNITFILE: /tmp/results.xml GOPATH: /home/circleci/go - GOVERSION: 1.11.5 - PROTOC_VERSION: 3.6.1 + GOVERSION: *GOVERSION GOMAXPROCS: 1 NOMAD_SLOW_TEST: 1 steps: @@ -129,40 +153,11 @@ jobs: sudo rm -rf /usr/local/go wget https://dl.google.com/go/go$GOVERSION.linux-amd64.tar.gz sudo tar -C /usr/local -xzf go$GOVERSION.linux-amd64.tar.gz - - run: - name: install protoc - command: | - sudo rm -rf /usr/bin/protoc - - wget -q -O /tmp/protoc.zip https://github.com/google/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip \ - && unzip /tmp/protoc.zip -d /tmp/protoc3 \ - && sudo mv /tmp/protoc3/bin/* /usr/local/bin/ \ - && sudo mv /tmp/protoc3/include/* /usr/local/include/ \ - && sudo ln -s /usr/local/bin/protoc /usr/bin/protoc \ - && rm -rf /tmp/protoc* - - run: - name: Install Vault/Consul - command: | - export VAULT_VERSION="1.1.0" - export CONSUL_VERSION="1.4.0" - - wget -q -O /tmp/vault.zip https://releases.hashicorp.com/vault/${VAULT_VERSION}/vault_${VAULT_VERSION}_linux_amd64.zip \ - && sudo unzip -d /usr/local/bin /tmp/vault.zip \ - && rm -rf /tmp/vault* - - wget -q -O /tmp/consul.zip https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip \ - && sudo unzip -d /usr/local/bin /tmp/consul.zip \ - && rm -rf /tmp/consul* + - install-protoc + - install-consul + - install-vault - run: PATH="$GOPATH/bin:/usr/local/go/bin:$PATH" make bootstrap - - run: | - if [ -z $GOTEST_PKGS_EXCLUDE ]; - then - unset GOTEST_PKGS_EXCLUDE - else - unset GOTEST_PKGS - fi - - sudo -E PATH="$GOPATH/bin:/usr/local/go/bin:$PATH" make test-nomad + - run-tests - store_test_results: path: /tmp @@ -198,45 +193,62 @@ jobs: name: website deploy command: ./scripts/deploy.sh -workflows: - build-test: - jobs: - - lint - - test-machine: - name: "test-client" - test_packages: "./client/..." - - test-machine: - name: "test-nomad" - test_packages: "./nomad/..." - - test-container: - name: "test-api" - test_packages: "./api/..." - - test-container: - name: "test-devices" - test_packages: "./devices/..." - - test-machine: - name: "test-other" - exclude_packages: "./api|./client|./drivers/docker|./drivers/exec|./drivers/rkt|./drivers/shared/executor|./nomad|./devices" - - test-machine: - name: "test-docker" - test_packages: "./drivers/docker" - - test-machine: - name: "test-exec" - test_packages: "./drivers/exec" - - test-machine: - name: "test-shared-exec" - test_packages: "./drivers/shared/executor" - - test-rkt - # - build-deps-image: - # context: dani-test - # filters: - # branches: - # only: dani/circleci +commands: + install-vault: + parameters: + version: + type: string + default: 1.0.0 + steps: + - run: + name: Install Vault << parameters.version >> + command: | + wget -q -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* - website: - jobs: - - build-website: - context: static-sites - filters: - branches: - only: stable-website + install-consul: + parameters: + version: + type: string + default: 1.0.0 + steps: + - run: + name: Install Consul << parameters.version >> + command: | + wget -q -O /tmp/consul.zip https://releases.hashicorp.com/consul/<< parameters.version >>/consul_<< parameters.version >>_linux_amd64.zip \ + && sudo unzip -d /usr/local/bin /tmp/consul.zip \ + && rm -rf /tmp/consul* + + install-protoc: + parameters: + version: + type: string + default: 3.6.1 + steps: + - run: + name: install protoc + command: | + sudo rm -rf /usr/bin/protoc + + wget -q -O /tmp/protoc.zip https://github.com/google/protobuf/releases/download/v<< parameters.version >>/protoc-<< parameters.version >>-linux-x86_64.zip \ + && unzip /tmp/protoc.zip -d /tmp/protoc3 \ + && sudo mv /tmp/protoc3/bin/* /usr/local/bin/ \ + && sudo mv /tmp/protoc3/include/* /usr/local/include/ \ + && sudo ln -s /usr/local/bin/protoc /usr/bin/protoc \ + && rm -rf /tmp/protoc* + + + run-tests: + steps: + - run: + name: Running Nomad Tests + command: | + if [ -z $GOTEST_PKGS_EXCLUDE ]; + then + unset GOTEST_PKGS_EXCLUDE + else + unset GOTEST_PKGS + fi + + sudo -E PATH="$GOPATH/bin:/usr/local/go/bin:$PATH" make test-nomad