open-consul/.circleci/config.yml

280 lines
7.4 KiB
YAML
Raw Normal View History

2019-03-08 20:33:03 +00:00
---
version: 2
2019-01-28 16:18:30 +00:00
2019-03-08 20:33:03 +00:00
references:
images:
go: &GOLANG_IMAGE circleci/golang:1.12.1
2019-03-08 20:33:03 +00:00
middleman: &MIDDLEMAN_IMAGE hashicorp/middleman-hashicorp:0.3.35
ember: &EMBER_IMAGE circleci/node:8-browsers
paths:
test-results: &TEST_RESULTS_DIR /tmp/test-results
2019-01-28 16:18:30 +00:00
2019-03-08 20:33:03 +00:00
cache:
yarn: &YARN_CACHE_KEY consul-ui-v1-{{ checksum "ui-v2/yarn.lock" }}
rubygem: &RUBYGEM_CACHE_KEY static-site-gems-v1-{{ checksum "Gemfile.lock" }}
environment: &ENVIRONMENT
TEST_RESULTS_DIR: *TEST_RESULTS_DIR
GOTESTSUM_RELEASE: 0.3.3
EMAIL: noreply@hashicorp.com
GIT_AUTHOR_NAME: circleci-consul
GIT_COMMITTER_NAME: circleci-consul
2019-04-02 16:24:48 +00:00
S3_ARTIFACT_BUCKET: consul-dev-artifacts
S3_ARTIFACT_PATH: consul-oss
2019-01-28 16:18:30 +00:00
jobs:
2019-03-20 19:24:17 +00:00
# build all distros
build-distros: &build-distros
2019-03-08 20:33:03 +00:00
docker:
- image: *GOLANG_IMAGE
2019-03-20 19:24:17 +00:00
environment: &build-env
GOXPARALLEL: 2 # CircleCI containers are 2 CPU x 4GB RAM
2019-01-28 16:18:30 +00:00
working_directory: /go/src/github.com/hashicorp/consul
steps:
- checkout
2019-03-20 19:24:17 +00:00
- run: make tools
- run: ./build-support/scripts/build-local.sh
2019-01-28 16:18:30 +00:00
# save dev build to CircleCI
- store_artifacts:
2019-03-20 19:24:17 +00:00
path: ./pkg/bin
2019-04-02 16:24:48 +00:00
# build all 386 architecture supported OS binaries
2019-03-20 19:24:17 +00:00
build-386:
<<: *build-distros
environment:
<<: *build-env
XC_OS: "darwin freebsd linux windows"
XC_ARCH: "386"
2019-04-02 16:24:48 +00:00
# build all amd64 architecture supported OS binaries
2019-03-20 19:24:17 +00:00
build-amd64:
<<: *build-distros
environment:
<<: *build-env
XC_OS: "darwin freebsd linux solaris windows"
XC_ARCH: "amd64"
2019-04-02 16:24:48 +00:00
# build all arm/arm64 architecture supported OS binaries
2019-03-20 19:24:17 +00:00
build-arm-arm64:
<<: *build-distros
environment:
<<: *build-env
XC_OS: linux
XC_ARCH: "arm arm64"
2019-04-02 16:24:48 +00:00
# create a development build
2019-03-20 19:24:17 +00:00
dev-build:
docker:
- image: *GOLANG_IMAGE
working_directory: /go/src/github.com/hashicorp/consul
steps:
- checkout
- run: make dev
2019-01-28 16:18:30 +00:00
# save dev build to pass to downstream jobs
- persist_to_workspace:
root: /go/bin
paths:
- consul
2019-04-02 16:24:48 +00:00
# upload development build to s3
dev-upload-s3:
docker:
- image: circleci/python:stretch
environment:
<<: *ENVIRONMENT
steps:
- run:
name: Install awscli
command: sudo pip install awscli
# get consul binary
- attach_workspace:
at: bin/
- run:
name: package binary
command: tar -czf consul.tar.gz -C bin/ .
- run:
name: Upload to s3
command: |
aws s3 cp \
--metadata "CIRCLECI=${CIRCLECI},CIRCLE_BUILD_URL=${CIRCLE_BUILD_URL},CIRCLE_BRANCH=${CIRCLE_BRANCH}" \
"consul.tar.gz" "s3://${S3_ARTIFACT_BUCKET}/${S3_ARTIFACT_PATH}/${CIRCLE_SHA1}.tar.gz"
2019-01-28 16:18:30 +00:00
# Nomad 0.8 builds on go0.10
# Run integration tests on nomad/v0.8.7
nomad-integration-0_8:
2019-03-08 20:33:03 +00:00
docker:
- image: circleci/golang:1.10
environment:
<<: *ENVIRONMENT
NOMAD_WORKING_DIR: &NOMAD_WORKING_DIR /go/src/github.com/hashicorp/nomad
NOMAD_VERSION: v0.8.7
steps: &NOMAD_INTEGRATION_TEST_STEPS
- run: git clone https://github.com/hashicorp/nomad.git --branch ${NOMAD_VERSION} ${NOMAD_WORKING_DIR}
# get consul binary
- attach_workspace:
at: /go/bin
# make test result directory
- run: mkdir -p $TEST_RESULTS_DIR
# make dev build of nomad
- run:
command: make dev
working_directory: *NOMAD_WORKING_DIR
# update gotestsum
- run: curl -sSL "https://github.com/gotestyourself/gotestsum/releases/download/v${GOTESTSUM_RELEASE}/gotestsum_${GOTESTSUM_RELEASE}_linux_amd64.tar.gz" | sudo tar --overwrite -xz -C /usr/local/bin gotestsum
2019-03-08 20:33:03 +00:00
# run integration tests
- run:
command: gotestsum --format=short-verbose --junitfile $TEST_RESULTS_DIR/results.xml -- ./command/agent/consul -run TestConsul
working_directory: *NOMAD_WORKING_DIR
# store test results for CircleCI
- store_test_results:
path: *TEST_RESULTS_DIR
- store_artifacts:
path: *TEST_RESULTS_DIR
2019-01-28 16:18:30 +00:00
# run integration tests on nomad/master
nomad-integration-master:
2019-03-08 20:33:03 +00:00
docker:
- image: *GOLANG_IMAGE
environment:
<<: *ENVIRONMENT
NOMAD_WORKING_DIR: /go/src/github.com/hashicorp/nomad
NOMAD_VERSION: master
steps: *NOMAD_INTEGRATION_TEST_STEPS
2019-01-28 16:18:30 +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:
2019-03-08 20:33:03 +00:00
- image: *MIDDLEMAN_IMAGE
steps:
- checkout:
path: ~/project
# restores gem cache
- restore_cache:
2019-03-08 20:33:03 +00:00
key: *RUBYGEM_CACHE_KEY
- 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:
2019-03-08 20:33:03 +00:00
key: *RUBYGEM_CACHE_KEY
paths:
- ~/project/website/vendor/bundle
- run:
name: middleman build
command: bundle exec middleman build
- run:
name: website deploy
command: ./scripts/deploy.sh
2019-01-04 03:57:40 +00:00
# build frontend yarn cache
2018-12-20 18:51:48 +00:00
frontend-cache:
docker:
2019-03-08 20:33:03 +00:00
- image: *EMBER_IMAGE
2018-12-20 18:51:48 +00:00
steps:
- checkout
2019-03-08 20:33:03 +00:00
2018-12-20 18:51:48 +00:00
# cache yarn deps
- restore_cache:
2019-03-08 20:33:03 +00:00
key: *YARN_CACHE_KEY
2018-12-20 18:51:48 +00:00
- run:
name: install yarn packages
command: cd ui-v2 && yarn install
2019-03-08 20:33:03 +00:00
2018-12-20 18:51:48 +00:00
- save_cache:
2019-03-08 20:33:03 +00:00
key: *YARN_CACHE_KEY
2018-12-20 18:51:48 +00:00
paths:
- ui-v2/node_modules
2019-03-08 20:33:03 +00:00
2018-12-20 18:51:48 +00:00
# build ember so frontend tests run faster
ember-build:
docker:
2019-03-08 20:33:03 +00:00
- image: *EMBER_IMAGE
2018-12-20 18:51:48 +00:00
steps:
- checkout
- restore_cache:
2019-03-08 20:33:03 +00:00
key: *YARN_CACHE_KEY
2019-01-03 17:56:54 +00:00
- run: cd ui-v2 && yarn build-ci --output-path=dist
2018-12-20 18:51:48 +00:00
# saves the build to a workspace to be passed to a downstream job
- persist_to_workspace:
root: ui-v2
paths:
- dist
2019-01-04 03:57:40 +00:00
# run ember frontend tests
2018-12-20 18:51:48 +00:00
ember-test:
docker:
2019-03-08 20:33:03 +00:00
- image: *EMBER_IMAGE
2018-12-20 18:51:48 +00:00
environment:
EMBER_TEST_PARALLEL: true #enables test parallelization with ember-exam
EMBER_TEST_REPORT: test-results/report.xml #outputs test report for CircleCI test summary
parallelism: 4
steps:
- checkout
- restore_cache:
2019-03-08 20:33:03 +00:00
key: *YARN_CACHE_KEY
2018-12-20 18:51:48 +00:00
- attach_workspace:
at: ui-v2
- run:
working_directory: ui-v2
command: node_modules/ember-cli/bin/ember exam --split=$CIRCLE_NODE_TOTAL --partition=`expr $CIRCLE_NODE_INDEX + 1` --path dist --silent -r xunit
- store_test_results:
path: ui-v2/test-results
workflows:
version: 2
2019-03-20 19:24:17 +00:00
build-distros:
jobs:
- build-386
- build-amd64
- build-arm-arm64
2019-03-08 20:33:03 +00:00
test-integrations:
2019-01-28 16:18:30 +00:00
jobs:
- dev-build
2019-04-02 16:24:48 +00:00
- dev-upload-s3:
requires:
- dev-build
filters:
branches:
ignore:
- /^pull\/.*$/ # only push dev builds from non forks
2019-01-28 16:18:30 +00:00
- nomad-integration-master:
requires:
2019-03-08 20:33:03 +00:00
- dev-build
2019-01-28 16:18:30 +00:00
- nomad-integration-0_8:
requires:
- dev-build
website:
jobs:
- build-website:
context: static-sites
filters:
branches:
only: stable-website
2018-12-20 18:51:48 +00:00
frontend:
jobs:
- frontend-cache
- ember-build:
requires:
- frontend-cache
- ember-test:
requires:
- ember-build