open-nomad/.circleci/config.yml

365 lines
10 KiB
YAML
Raw Normal View History

version: 2.1
2019-05-16 13:14:34 +00:00
references:
common_envs: &COMMON_ENVS
GOMAXPROCS: 1
NOMAD_SLOW_TEST: 1
GOTESTSUM_JUNITFILE: /tmp/test-reports/results.xml
ignore_for_ui_branches: &IGNORE_FOR_UI_BRANCHES
filters:
branches:
ignore: /^.-ui\b.*/
2019-05-16 13:14:34 +00:00
workflows:
build-test:
jobs:
- lint-go:
<<: *IGNORE_FOR_UI_BRANCHES
2019-05-16 13:14:34 +00:00
- test-machine:
name: "test-client"
test_packages: "./client/..."
<<: *IGNORE_FOR_UI_BRANCHES
2019-05-16 13:14:34 +00:00
- test-machine:
name: "test-nomad"
test_packages: "./nomad/..."
<<: *IGNORE_FOR_UI_BRANCHES
2019-08-12 16:48:25 +00:00
- test-machine:
# API Tests run in a VM rather than container due to the FS tests
# requiring `mount` priviliges.
2019-05-16 13:14:34 +00:00
name: "test-api"
test_packages: "./api/..."
<<: *IGNORE_FOR_UI_BRANCHES
2019-05-16 13:14:34 +00:00
- test-container:
name: "test-devices"
test_packages: "./devices/..."
<<: *IGNORE_FOR_UI_BRANCHES
2019-05-16 13:14:34 +00:00
- test-machine:
name: "test-other"
exclude_packages: "./api|./client|./drivers/docker|./drivers/exec|./drivers/rkt|./drivers/shared/executor|./nomad|./devices"
<<: *IGNORE_FOR_UI_BRANCHES
2019-05-16 13:14:34 +00:00
- 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
<<: *IGNORE_FOR_UI_BRANCHES
2019-05-16 13:14:34 +00:00
- test-machine:
name: "test-exec"
test_packages: "./drivers/exec"
<<: *IGNORE_FOR_UI_BRANCHES
2019-05-16 13:14:34 +00:00
- test-machine:
name: "test-shared-exec"
test_packages: "./drivers/shared/executor"
<<: *IGNORE_FOR_UI_BRANCHES
2019-08-31 16:34:22 +00:00
- test-machine:
name: "test-32bit"
# Currently we only explicitly test fingerprinting on 32bit
# architectures.
test_packages: "./client/fingerprint"
goarch: "386"
<<: *IGNORE_FOR_UI_BRANCHES
- test-rkt:
<<: *IGNORE_FOR_UI_BRANCHES
2019-08-30 11:44:23 +00:00
- test-e2e:
<<: *IGNORE_FOR_UI_BRANCHES
- test-ui
- test-website:
<<: *IGNORE_FOR_UI_BRANCHES
2019-05-16 13:14:34 +00:00
website:
jobs:
- build-website:
context: static-sites
filters:
branches:
only: stable-website
executors:
go:
2019-08-12 16:34:06 +00:00
working_directory: /go/src/github.com/hashicorp/nomad
docker:
- image: circleci/golang:1.12.10
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
# uses a more recent image with unattended upgrades disabled properly
# but seems to break docker builds
go-machine-recent:
working_directory: ~/go/src/github.com/hashicorp/nomad
machine:
image: ubuntu-1604:201903-01
2018-11-20 21:49:40 +00:00
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-go:
executor: go
environment:
<<: *COMMON_ENVS
2019-08-12 16:34:06 +00:00
GOPATH: /go
steps:
- checkout
- install-protoc
2019-08-30 11:44:23 +00:00
- run: sudo apt-get update && sudo apt-get install shellcheck
- run: make deps lint-deps
- run: make check
2019-08-30 11:44:23 +00:00
- run: make checkscripts
test-container:
executor: go
parameters:
test_packages:
type: string
default: ""
exclude_packages:
type: string
default: ""
goarch:
type: string
default: "amd64"
environment:
<<: *COMMON_ENVS
GOTEST_PKGS: "<< parameters.test_packages >>"
GOTEST_PKGS_EXCLUDE: "<< parameters.exclude_packages >>"
2019-08-12 16:34:06 +00:00
GOPATH: /go
2019-08-31 16:34:22 +00:00
GOTESTARCH: "<< parameters.goarch >>"
steps:
- checkout
- run: make deps
- install-protoc
- install-consul
- install-vault
2019-05-16 13:14:34 +00:00
- run-tests
- store_test_results:
path: /tmp/test-reports
- store_artifacts:
path: /tmp/test-reports
2019-08-30 11:44:23 +00:00
test-e2e:
executor: go
environment:
<<: *COMMON_ENVS
GOPATH: /go
steps:
- checkout
- run: make deps
- run: make e2e-test
test-website:
executor: go-machine-recent
environment:
<<: *COMMON_ENVS
steps:
- checkout
- run: make test-website
2019-04-17 11:37:16 +00:00
test-rkt:
executor: go-machine-recent
2019-04-17 11:37:16 +00:00
environment:
<<: *COMMON_ENVS
2019-04-17 11:37:16 +00:00
GOTEST_PKGS: "./drivers/rkt"
GOPATH: /home/circleci/go
RKT_VERSION: 1.29.0
steps:
- checkout
- install-golang
2019-05-16 13:14:34 +00:00
- install-protoc
2019-04-17 11:37:16 +00:00
- 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
2019-05-16 13:14:34 +00:00
- run-tests
2019-04-17 11:37:16 +00:00
- store_test_results:
path: /tmp/test-reports
- store_artifacts:
path: /tmp/test-reports
2019-04-17 11:37:16 +00:00
test-machine:
executor: "<< parameters.executor >>"
parameters:
test_packages:
type: string
default: ""
exclude_packages:
type: string
default: ""
executor:
type: string
default: "go-machine-recent"
2019-08-31 16:34:22 +00:00
goarch:
type: string
default: "amd64"
environment:
<<: *COMMON_ENVS
GOTEST_PKGS_EXCLUDE: "<< parameters.exclude_packages >>"
GOTEST_PKGS: "<< parameters.test_packages >>"
GOPATH: /home/circleci/go
2019-08-31 16:34:22 +00:00
GOTESTARCH: "<< parameters.goarch >>"
steps:
- checkout
- install-golang
2019-05-16 13:14:34 +00:00
- install-protoc
- install-consul
- install-vault
2019-08-31 16:34:22 +00:00
- run:
name: Install 32bit gcc libs
command: |
if [ ! -z $GOTESTARCH ] && [ $GOTESTARCH == "386" ]; then
sudo apt-get update
sudo apt-get install -y gcc-multilib
else
echo "Skipping 32bit lib installation while building for not 386"
fi
- run: PATH="$GOPATH/bin:/usr/local/go/bin:$PATH" make bootstrap
2019-05-16 13:14:34 +00:00
- run-tests
- store_test_results:
path: /tmp/test-reports
- store_artifacts:
path: /tmp/test-reports
test-ui:
docker:
- image: circleci/node:10-browsers
environment:
# See https://git.io/vdao3 for details.
JOBS: 2
steps:
- checkout
- restore_cache:
keys:
- v1-deps-{{ checksum "ui/yarn.lock" }}
- v1-deps-
- run:
name: yarn install
command: cd ui && yarn install
- save_cache:
key: v1-deps-{{ checksum "ui/yarn.lock" }}
paths:
- ./ui/node_modules
- run:
name: lint:js
command: cd ui && yarn run lint:js
- run:
name: lint:hbs
command: cd ui && yarn run lint:hbs
- run:
name: Ember tests
command: cd ui && yarn test
2018-11-20 21:49:40 +00:00
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
2019-05-16 13:14:34 +00:00
commands:
install-golang:
2019-08-13 13:22:47 +00:00
parameters:
version:
type: string
default: "1.12.10"
steps:
- run:
2019-08-13 13:22:47 +00:00
name: install golang << parameters.version >>
command: |
sudo rm -rf /usr/local/go
2019-08-13 13:22:47 +00:00
wget -q -O /tmp/golang.tar.gz https://dl.google.com/go/go<< parameters.version >>.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf /tmp/golang.tar.gz
rm -rf /tmp/golang.tar.gz
2019-05-16 13:14:34 +00:00
install-vault:
parameters:
version:
type: string
default: 1.0.0
steps:
- run:
name: Install Vault << parameters.version >>
command: |
2019-08-13 13:22:47 +00:00
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*
2019-05-16 13:14:34 +00:00
install-consul:
parameters:
version:
type: string
2019-08-20 20:23:23 +00:00
default: 1.6.0-rc1
2019-05-16 13:14:34 +00:00
steps:
- run:
name: Install Consul << parameters.version >>
command: |
2019-08-13 13:22:47 +00:00
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*
2019-05-16 13:14:34 +00:00
install-protoc:
steps:
- run:
name: install protoc
command: |
sudo rm -rf /usr/bin/protoc
2019-05-16 13:19:18 +00:00
sudo ./scripts/vagrant-linux-priv-protoc.sh
2019-05-16 13:14:34 +00:00
run-tests:
steps:
- run:
name: Running Nomad Tests
command: |
if [ -z $GOTEST_PKGS_EXCLUDE ];
then
unset GOTEST_PKGS_EXCLUDE
else
unset GOTEST_PKGS
fi
2019-08-31 16:34:22 +00:00
if [ ! -z $GOTESTARCH ]; then
export GOARCH="$GOTESTARCH";
fi
mkdir -p /tmp/test-reports
2019-05-16 13:24:07 +00:00
sudo -E PATH="$GOPATH/bin:/usr/local/go/bin:$PATH" make generate-structs
2019-05-16 13:14:34 +00:00
sudo -E PATH="$GOPATH/bin:/usr/local/go/bin:$PATH" make test-nomad