2019-05-03 23:05:10 +00:00
|
|
|
version: 2
|
|
|
|
|
|
|
|
references:
|
|
|
|
images:
|
|
|
|
go: &GOLANG_IMAGE golang:1.12.4-stretch # Pin Go to patch version (ex: 1.2.3)
|
|
|
|
node: &NODE_IMAGE node:10-stretch # Pin Node.js to major version (ex: 10)
|
|
|
|
|
|
|
|
environment: &ENVIRONMENT
|
|
|
|
CIRCLECI_CLI_VERSION: 0.1.5546 # Pin CircleCI CLI to patch version (ex: 1.2.3)
|
|
|
|
GO_VERSION: 1.12.4 # Pin Go to patch version (ex: 1.2.3)
|
|
|
|
GOTESTSUM_VERSION: 0.3.3 # Pin gotestsum to patch version (ex: 1.2.3)
|
|
|
|
|
2019-05-14 20:27:34 +00:00
|
|
|
cache:
|
|
|
|
go-sum: &GO_SUM_CACHE_KEY go-sum-v1-{{ checksum "go.sum" }}
|
|
|
|
yarn-lock: &YARN_LOCK_CACHE_KEY yarn-lock-v1-{{ checksum "ui/yarn.lock" }}
|
|
|
|
|
2019-05-03 23:05:10 +00:00
|
|
|
jobs:
|
|
|
|
install-ui-dependencies:
|
|
|
|
docker:
|
|
|
|
- image: *NODE_IMAGE
|
2019-05-14 20:27:34 +00:00
|
|
|
working_directory: /src
|
2019-05-03 23:05:10 +00:00
|
|
|
steps:
|
2019-05-14 20:27:34 +00:00
|
|
|
- checkout
|
2019-05-03 23:05:10 +00:00
|
|
|
- restore_cache:
|
2019-05-14 20:27:34 +00:00
|
|
|
key: *YARN_LOCK_CACHE_KEY
|
2019-05-03 23:05:10 +00:00
|
|
|
- run:
|
|
|
|
name: Install UI dependencies
|
|
|
|
command: |
|
|
|
|
set -eux -o pipefail
|
|
|
|
|
2019-05-14 20:27:34 +00:00
|
|
|
cd ui
|
2019-05-03 23:05:10 +00:00
|
|
|
yarn install --ignore-optional
|
|
|
|
npm rebuild node-sass
|
|
|
|
- save_cache:
|
2019-05-14 20:27:34 +00:00
|
|
|
key: *YARN_LOCK_CACHE_KEY
|
2019-05-03 23:05:10 +00:00
|
|
|
paths:
|
|
|
|
- ui/node_modules
|
|
|
|
|
2019-05-14 20:27:34 +00:00
|
|
|
go-mod-download:
|
2019-05-07 18:58:52 +00:00
|
|
|
docker:
|
|
|
|
- image: *GOLANG_IMAGE
|
2019-05-14 20:27:34 +00:00
|
|
|
working_directory: /src
|
2019-05-07 18:58:52 +00:00
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
- restore_cache:
|
2019-05-14 20:27:34 +00:00
|
|
|
key: *GO_SUM_CACHE_KEY
|
2019-05-07 18:58:52 +00:00
|
|
|
- run:
|
2019-05-14 20:27:34 +00:00
|
|
|
name: Download Go modules
|
|
|
|
command: go mod download
|
2019-05-07 18:58:52 +00:00
|
|
|
- run:
|
2019-05-14 20:27:34 +00:00
|
|
|
name: Verify checksums of Go modules
|
|
|
|
command: go mod verify
|
2019-05-07 18:58:52 +00:00
|
|
|
- save_cache:
|
2019-05-14 20:27:34 +00:00
|
|
|
key: *GO_SUM_CACHE_KEY
|
2019-05-07 18:58:52 +00:00
|
|
|
paths:
|
2019-05-14 20:27:34 +00:00
|
|
|
- /go/pkg/mod
|
2019-05-07 18:58:52 +00:00
|
|
|
|
2019-05-03 23:05:10 +00:00
|
|
|
build-go-dev:
|
|
|
|
docker:
|
|
|
|
- image: *GOLANG_IMAGE
|
2019-05-14 20:27:34 +00:00
|
|
|
working_directory: /src
|
2019-05-03 23:05:10 +00:00
|
|
|
steps:
|
|
|
|
- checkout
|
2019-05-14 20:27:34 +00:00
|
|
|
- restore_cache:
|
|
|
|
key: *GO_SUM_CACHE_KEY
|
2019-05-03 23:05:10 +00:00
|
|
|
- run:
|
|
|
|
name: Build dev binary
|
|
|
|
command: |
|
|
|
|
set -eux -o pipefail
|
|
|
|
|
|
|
|
# Move dev UI assets to expected location
|
|
|
|
rm -rf ./pkg
|
|
|
|
mkdir ./pkg
|
|
|
|
|
|
|
|
# Build dev binary
|
|
|
|
make bootstrap dev
|
|
|
|
- persist_to_workspace:
|
|
|
|
root: .
|
|
|
|
paths:
|
|
|
|
- bin
|
|
|
|
|
|
|
|
test-ui:
|
|
|
|
docker:
|
|
|
|
- image: *NODE_IMAGE
|
2019-05-14 20:27:34 +00:00
|
|
|
working_directory: /src
|
2019-05-03 23:05:10 +00:00
|
|
|
resource_class: medium+
|
|
|
|
steps:
|
2019-05-14 20:27:34 +00:00
|
|
|
- checkout
|
|
|
|
- restore_cache:
|
|
|
|
key: *YARN_LOCK_CACHE_KEY
|
2019-05-03 23:05:10 +00:00
|
|
|
- attach_workspace:
|
2019-05-14 20:27:34 +00:00
|
|
|
at: .
|
2019-05-03 23:05:10 +00:00
|
|
|
- run:
|
|
|
|
name: Test UI
|
|
|
|
command: |
|
|
|
|
set -eux -o pipefail
|
|
|
|
|
|
|
|
# Install Chrome
|
|
|
|
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub \
|
|
|
|
| apt-key add -
|
|
|
|
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" \
|
|
|
|
| tee /etc/apt/sources.list.d/google-chrome.list
|
|
|
|
apt-get update
|
|
|
|
apt-get -y install google-chrome-stable
|
|
|
|
rm /etc/apt/sources.list.d/google-chrome.list
|
|
|
|
rm -rf /var/lib/apt/lists/* /var/cache/apt/*
|
|
|
|
|
|
|
|
# Add ./bin to the PATH so vault binary can be run by Ember tests
|
2019-05-14 20:27:34 +00:00
|
|
|
export PATH="${PWD}"/bin:${PATH}
|
2019-05-03 23:05:10 +00:00
|
|
|
|
|
|
|
# Run Ember tests
|
2019-05-14 20:27:34 +00:00
|
|
|
cd ui
|
2019-05-03 23:05:10 +00:00
|
|
|
mkdir -p test-results/qunit
|
|
|
|
yarn run test-oss
|
|
|
|
- store_artifacts:
|
2019-05-14 20:27:34 +00:00
|
|
|
path: ui/test-results
|
2019-05-03 23:05:10 +00:00
|
|
|
- store_test_results:
|
2019-05-14 20:27:34 +00:00
|
|
|
path: ui/test-results
|
2019-05-03 23:05:10 +00:00
|
|
|
|
2019-05-24 12:02:51 +00:00
|
|
|
test-ui-browserstack:
|
|
|
|
docker:
|
|
|
|
- image: *NODE_IMAGE
|
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
- restore_cache:
|
|
|
|
key: *YARN_LOCK_CACHE_KEY
|
|
|
|
- attach_workspace:
|
|
|
|
at: .
|
|
|
|
- run:
|
|
|
|
name: Run BrowserStack tests
|
|
|
|
command: |
|
|
|
|
set -eux -o pipefail
|
|
|
|
|
|
|
|
# Add ./bin to the PATH so vault binary can be run by Ember tests
|
|
|
|
export PATH="${PWD}"/bin:${PATH}
|
|
|
|
|
|
|
|
make test-ui-browserstack
|
|
|
|
|
2019-05-03 23:05:10 +00:00
|
|
|
test-go:
|
|
|
|
machine: true
|
|
|
|
environment:
|
|
|
|
<<: *ENVIRONMENT
|
|
|
|
GO_TAGS:
|
|
|
|
parallelism: 2
|
2019-05-14 20:27:34 +00:00
|
|
|
working_directory: ~/src
|
2019-05-03 23:05:10 +00:00
|
|
|
steps:
|
|
|
|
- checkout
|
2019-05-14 20:27:34 +00:00
|
|
|
- run:
|
|
|
|
name: Allow circleci user to restore Go modules cache
|
|
|
|
command: |
|
|
|
|
set -eux -o pipefail
|
|
|
|
|
|
|
|
sudo mkdir /go
|
|
|
|
sudo chown -R circleci:circleci /go
|
|
|
|
- restore_cache:
|
|
|
|
key: *GO_SUM_CACHE_KEY
|
2019-05-03 23:05:10 +00:00
|
|
|
- run:
|
|
|
|
name: Run Go tests
|
2019-05-22 15:09:24 +00:00
|
|
|
no_output_timeout: 20m
|
2019-05-03 23:05:10 +00:00
|
|
|
command: |
|
|
|
|
set -eux -o pipefail
|
|
|
|
|
|
|
|
# Install Go
|
|
|
|
curl -sSLO "https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz"
|
|
|
|
sudo rm -rf /usr/local/go
|
|
|
|
sudo tar -C /usr/local -xzf "go${GO_VERSION}.linux-amd64.tar.gz"
|
|
|
|
rm -f "go${GO_VERSION}.linux-amd64.tar.gz"
|
2019-05-14 20:27:34 +00:00
|
|
|
export GOPATH=/go
|
2019-05-03 23:05:10 +00:00
|
|
|
export PATH="${PATH}:${GOPATH}/bin:/usr/local/go/bin"
|
|
|
|
|
|
|
|
# Install CircleCI CLI
|
|
|
|
curl -sSL \
|
|
|
|
"https://github.com/CircleCI-Public/circleci-cli/releases/download/v${CIRCLECI_CLI_VERSION}/circleci-cli_${CIRCLECI_CLI_VERSION}_linux_amd64.tar.gz" \
|
|
|
|
| sudo tar --overwrite -xz \
|
|
|
|
-C /usr/local/bin \
|
|
|
|
"circleci-cli_${CIRCLECI_CLI_VERSION}_linux_amd64/circleci"
|
|
|
|
|
|
|
|
# Split Go tests by prior test times
|
|
|
|
package_names=$(go list \
|
|
|
|
-tags "${GO_TAGS}" \
|
|
|
|
./... \
|
|
|
|
| grep -v /vendor/ \
|
|
|
|
| sort \
|
|
|
|
| circleci tests split --split-by=timings --timings-type=classname)
|
|
|
|
|
|
|
|
# Install gotestsum
|
|
|
|
curl -sSL "https://github.com/gotestyourself/gotestsum/releases/download/v${GOTESTSUM_VERSION}/gotestsum_${GOTESTSUM_VERSION}_linux_amd64.tar.gz" \
|
|
|
|
| sudo tar --overwrite -xz -C /usr/local/bin gotestsum
|
|
|
|
|
|
|
|
# Run tests
|
|
|
|
make prep
|
|
|
|
mkdir -p test-results/go-test
|
|
|
|
CGO_ENABLED= \
|
|
|
|
VAULT_ADDR= \
|
|
|
|
VAULT_TOKEN= \
|
|
|
|
VAULT_DEV_ROOT_TOKEN_ID= \
|
|
|
|
VAULT_ACC= \
|
|
|
|
gotestsum --format=short-verbose --junitfile test-results/go-test/results.xml -- \
|
|
|
|
-tags "${GO_TAGS}" \
|
|
|
|
-timeout=40m \
|
|
|
|
-parallel=20 \
|
|
|
|
${package_names}
|
|
|
|
- store_artifacts:
|
|
|
|
path: test-results
|
|
|
|
- store_test_results:
|
|
|
|
path: test-results
|
|
|
|
|
|
|
|
workflows:
|
|
|
|
version: 2
|
|
|
|
|
|
|
|
ci:
|
|
|
|
jobs:
|
|
|
|
- install-ui-dependencies
|
2019-05-14 20:27:34 +00:00
|
|
|
- go-mod-download
|
2019-05-07 18:58:52 +00:00
|
|
|
- build-go-dev:
|
|
|
|
requires:
|
2019-05-14 20:27:34 +00:00
|
|
|
- go-mod-download
|
2019-05-03 23:05:10 +00:00
|
|
|
- test-ui:
|
|
|
|
requires:
|
|
|
|
- install-ui-dependencies
|
|
|
|
- build-go-dev
|
|
|
|
- test-go:
|
|
|
|
requires:
|
|
|
|
- build-go-dev
|
2019-05-24 12:02:51 +00:00
|
|
|
- test-ui-browserstack:
|
|
|
|
requires:
|
|
|
|
- install-ui-dependencies
|
|
|
|
- build-go-dev
|