version: 2.1 references: GO_VERSION: &GOVERSION 1.12.7 workflows: build-test: jobs: - lint - test-machine: name: "test-client" test_packages: "./client/..." - test-machine: name: "test-nomad" test_packages: "./nomad/..." - 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/..." - 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 docker: - image: hashicorpnomad/ci-build-image:20190812 go-machine: working_directory: ~/go/src/github.com/hashicorp/nomad machine: image: circleci/classic:201808-01 docker-builder: working_directory: ~/go/src/github.com/hashicorp/nomad machine: true # TODO: Find latest docker image id jobs: build-deps-image: executor: docker-builder steps: - checkout - run: docker build -t hashicorpnomad/ci-build-image:$CIRCLE_SHA1 . -f ./Dockerfile.ci - run: docker push hashicorpnomad/ci-build-image:$CIRCLE_SHA1 lint: executor: go environment: GOPATH: /go steps: - checkout - run: make check test-container: executor: go parameters: test_packages: type: string default: "" exclude_packages: type: string default: "" environment: GOTEST_PKGS: "<< parameters.test_packages >>" GOTEST_PKGS_EXCLUDE: "<< parameters.exclude_packages >>" GOPATH: /go GOTESTSUM_JUNITFILE: /tmp/results.xml GOMAXPROCS: 1 NOMAD_SLOW_TEST: 1 steps: - checkout - run-tests - store_test_results: path: /tmp test-rkt: executor: go-machine environment: GOTEST_PKGS: "./drivers/rkt" GOTESTSUM_JUNITFILE: /tmp/results.xml GOPATH: /home/circleci/go GOVERSION: *GOVERSION GOMAXPROCS: 1 NOMAD_SLOW_TEST: 1 RKT_VERSION: 1.29.0 steps: - checkout - run: name: install go command: | 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 - install-protoc - run: name: install rkt command: | gpg --recv-key 18AD5014C99EF7E3BA5F6CE950BDD3E0FC8A365E wget https://github.com/rkt/rkt/releases/download/v$RKT_VERSION/rkt_$RKT_VERSION-1_amd64.deb wget https://github.com/rkt/rkt/releases/download/v$RKT_VERSION/rkt_$RKT_VERSION-1_amd64.deb.asc 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-tests - store_test_results: path: /tmp test-machine: executor: go-machine parameters: test_packages: type: string default: "" exclude_packages: type: string default: "" environment: GOTEST_PKGS_EXCLUDE: "<< parameters.exclude_packages >>" GOTEST_PKGS: "<< parameters.test_packages >>" GOTESTSUM_JUNITFILE: /tmp/results.xml GOPATH: /home/circleci/go GOVERSION: *GOVERSION GOMAXPROCS: 1 NOMAD_SLOW_TEST: 1 steps: - checkout - run: name: install go command: | 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 - install-protoc - install-consul - install-vault - run: PATH="$GOPATH/bin:/usr/local/go/bin:$PATH" make bootstrap - run-tests - store_test_results: path: /tmp build-website: # setting the working_directory along with the checkout path allows us to not have # to cd into the website/ directory for commands working_directory: ~/project/website docker: - image: hashicorp/middleman-hashicorp:0.3.35 steps: - checkout: path: ~/project # restores gem cache - restore_cache: key: static-site-gems-v1-{{ checksum "Gemfile.lock" }} - run: name: install gems command: bundle check || bundle install --path vendor/bundle --retry=3 # saves gem cache if we have changed the Gemfile - save_cache: key: static-site-gems-v1-{{ checksum "Gemfile.lock" }} paths: - ~/project/website/vendor/bundle - run: name: middleman build command: bundle exec middleman build - run: name: website deploy command: ./scripts/deploy.sh 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* 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: steps: - run: name: install protoc command: | sudo rm -rf /usr/bin/protoc sudo ./scripts/vagrant-linux-priv-protoc.sh 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 generate-structs sudo -E PATH="$GOPATH/bin:/usr/local/go/bin:$PATH" make test-nomad