2019-03-08 20:33:03 +00:00
---
2021-01-14 04:25:21 +00:00
version : 2.1
2019-01-28 16:18:30 +00:00
2021-01-14 04:30:00 +00:00
parameters :
commit :
type : string
default : ""
description : "Commit to run load tests against"
trigger-load-test :
type : boolean
default : false
description : "Boolean whether to run the load test workflow"
2019-03-08 20:33:03 +00:00
references :
paths :
test-results : &TEST_RESULTS_DIR /tmp/test-results
environment : &ENVIRONMENT
TEST_RESULTS_DIR : *TEST_RESULTS_DIR
EMAIL : noreply@hashicorp.com
GIT_AUTHOR_NAME : circleci-consul
GIT_COMMITTER_NAME : circleci-consul
2020-09-04 03:40:23 +00:00
S3_ARTIFACT_BUCKET : consul-dev-artifacts-v2
2019-08-02 19:15:59 +00:00
BASH_ENV : .circleci/bash_env.sh
2022-04-08 22:33:45 +00:00
VAULT_BINARY_VERSION : 1.9 .4
2022-10-21 14:31:09 +00:00
GO_VERSION : 1.19 .2
2022-06-28 12:15:45 +00:00
envoy-versions : &supported_envoy_versions
2022-10-31 15:50:45 +00:00
- &default_envoy_version "1.21.5"
2022-10-04 20:15:01 +00:00
- "1.22.5"
2022-10-31 15:50:45 +00:00
- "1.23.2"
- "1.24.0"
2022-08-16 22:33:33 +00:00
nomad-versions : &supported_nomad_versions
- &default_nomad_version "1.3.3"
- "1.2.10"
- "1.1.16"
2022-04-25 14:41:36 +00:00
images :
# When updating the Go version, remember to also update the versions in the
# workflows section for go-test-lib jobs.
2022-10-21 14:31:09 +00:00
go : &GOLANG_IMAGE docker.mirror.hashicorp.services/cimg/go:1.19.2
2022-04-25 14:41:36 +00:00
ember : &EMBER_IMAGE docker.mirror.hashicorp.services/circleci/node:14-browsers
2022-05-17 15:25:38 +00:00
ubuntu : &UBUNTU_CI_IMAGE ubuntu-2004:202201-02
2022-04-25 14:41:36 +00:00
cache :
2022-07-14 10:22:45 +00:00
yarn : &YARN_CACHE_KEY consul-ui-v9-{{ checksum "ui/yarn.lock" }}
2019-01-28 16:18:30 +00:00
2020-07-17 17:00:31 +00:00
steps :
install-gotestsum : &install-gotestsum
name : install gotestsum
environment :
2021-05-10 17:25:18 +00:00
GOTESTSUM_RELEASE : 1.6 .4
2020-07-17 17:00:31 +00:00
command : |
2021-12-09 13:55:10 +00:00
ARCH=`uname -m`
if [[ "$ARCH" == "aarch64" ]]; then
ARCH="arm64"
else
ARCH="amd64"
fi
2020-07-17 17:00:31 +00:00
url=https://github.com/gotestyourself/gotestsum/releases/download
2021-12-09 13:55:10 +00:00
curl -sSL "${url}/v${GOTESTSUM_RELEASE}/gotestsum_${GOTESTSUM_RELEASE}_linux_${ARCH}.tar.gz" | \
2020-07-17 17:00:31 +00:00
sudo tar -xz --overwrite -C /usr/local/bin gotestsum
2020-09-04 03:40:23 +00:00
get-aws-cli : &get-aws-cli
run :
name : download and install AWS CLI
command : |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
echo -e "${AWS_CLI_GPG_KEY}" | gpg --import
curl -o awscliv2.sig https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip.sig
gpg --verify awscliv2.sig awscliv2.zip
unzip awscliv2.zip
sudo ./aws/install
2020-07-28 18:54:48 +00:00
# This step MUST be at the end of any set of steps due to the 'when' condition
notify-slack-failure : ¬ify-slack-failure
name : notify-slack-failure
when : on_fail
command : |
2021-06-29 21:04:24 +00:00
if [[ $CIRCLE_BRANCH == "main" ]]; then
2020-07-28 18:54:48 +00:00
CIRCLE_ENDPOINT="https://app.circleci.com/pipelines/github/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}?branch=${CIRCLE_BRANCH}"
GITHUB_ENDPOINT="https://github.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/commit/${CIRCLE_SHA1}"
COMMIT_MESSAGE=$(git log -1 --pretty=%B | head -n1)
SHORT_REF=$(git rev-parse --short "${CIRCLE_SHA1}")
curl -X POST -H 'Content-type : application/json' \
--data \
"{ \
\"attachments\": [ \
{ \
\"fallback\": \"CircleCI job failed!\", \
\"text\": \"❌ Failed: \`${CIRCLE_USERNAME}\`'s <${CIRCLE_BUILD_URL}|${CIRCLE_STAGE}> job failed for commit <${GITHUB_ENDPOINT}|${SHORT_REF}> on \`${CIRCLE_BRANCH}\`!\n\n- <${COMMIT_MESSAGE}\", \
\"footer\": \"${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}\", \
\"ts\": \"$(date +%s)\", \
\"color\": \"danger\" \
} \
] \
}" " ${FEED_CONSUL_GH_URL}"
else
2021-06-29 21:04:24 +00:00
echo "Not posting slack failure notifications for non-main branch"
2020-07-28 18:54:48 +00:00
fi
2021-01-14 04:25:21 +00:00
commands :
assume-role :
description : "Assume role to an ARN"
parameters :
access-key :
type : env_var_name
default : AWS_ACCESS_KEY_ID
secret-key :
type : env_var_name
default : AWS_SECRET_ACCESS_KEY
role-arn :
type : env_var_name
default : ROLE_ARN
steps :
2022-08-18 23:06:20 +00:00
# Only run the assume-role command for the main repo. The AWS credentials aren't available for forks.
2021-01-14 04:25:21 +00:00
- run : |
2022-08-18 23:06:20 +00:00
if [[ "${CIRCLE_BRANCH%%/*}/" != "pull/" ]]; then
export AWS_ACCESS_KEY_ID="${<< parameters.access-key >>}"
export AWS_SECRET_ACCESS_KEY="${<< parameters.secret-key >>}"
export ROLE_ARN="${<< parameters.role-arn >>}"
# assume role has duration of 15 min (the minimum allowed)
CREDENTIALS="$(aws sts assume-role --duration-seconds 900 --role-arn ${ROLE_ARN} --role-session-name build-${CIRCLE_SHA1} | jq '.Credentials')"
echo "export AWS_ACCESS_KEY_ID=$(echo $CREDENTIALS | jq -r '.AccessKeyId')" >> $BASH_ENV
echo "export AWS_SECRET_ACCESS_KEY=$(echo $CREDENTIALS | jq -r '.SecretAccessKey')" >> $BASH_ENV
echo "export AWS_SESSION_TOKEN=$(echo $CREDENTIALS | jq -r '.SessionToken')" >> $BASH_ENV
fi
2021-12-22 00:00:28 +00:00
run-go-test-full :
2022-02-03 22:58:59 +00:00
parameters :
go_test_flags :
type : string
default : ""
2021-12-22 00:00:28 +00:00
steps :
- attach_workspace :
at : /home/circleci/go/bin
- run : go mod download
- run :
name : go test
command : |
2022-11-10 20:43:37 +00:00
mkdir -p $TEST_RESULTS_DIR /tmp/jsonfile /tmp/coverage
2021-12-22 00:00:28 +00:00
PACKAGE_NAMES=$(go list -tags "$GOTAGS" ./... | circleci tests split --split-by=timings --timings-type=classname)
echo "Running $(echo $PACKAGE_NAMES | wc -w) packages"
echo $PACKAGE_NAMES
# some tests expect this umask, and arm images have a different default
umask 0022
2022-02-03 22:58:59 +00:00
<< parameters.go_test_flags >>
2021-12-22 00:00:28 +00:00
gotestsum \
--format=short-verbose \
--jsonfile /tmp/jsonfile/go-test-${CIRCLE_NODE_INDEX}.log \
--debug \
--rerun-fails=3 \
--rerun-fails-max-failures=40 \
--rerun-fails-report=/tmp/gotestsum-rerun-fails \
--packages="$PACKAGE_NAMES" \
--junitfile $TEST_RESULTS_DIR/gotestsum-report.xml -- \
-tags="$GOTAGS" -p 2 \
2022-02-03 22:58:59 +00:00
${GO_TEST_FLAGS-} \
2022-11-10 20:43:37 +00:00
-cover -coverprofile=/tmp/coverage/test-coverage-$CIRCLE_NODE_INDEX || true
2021-12-22 00:00:28 +00:00
- store_test_results :
path : *TEST_RESULTS_DIR
- store_artifacts :
path : *TEST_RESULTS_DIR
- store_artifacts :
path : /tmp/jsonfile
2022-11-10 20:43:37 +00:00
- persist_to_workspace :
root : /tmp
paths :
- coverage
2021-12-22 00:00:28 +00:00
- run : &rerun-fails-report
name : "Re-run fails report"
command : |
.circleci/scripts/rerun-fails-report.sh /tmp/gotestsum-rerun-fails
- run : *notify-slack-failure
2018-11-16 19:01:02 +00:00
jobs :
2019-07-16 22:52:24 +00:00
# lint consul tests
lint-consul-retry :
docker :
- image : *GOLANG_IMAGE
steps :
- checkout
2021-11-16 18:04:49 +00:00
- run : go install github.com/hashicorp/lint-consul-retry@master && lint-consul-retry
2020-07-28 18:54:48 +00:00
- run : *notify-slack-failure
2019-07-16 22:52:24 +00:00
2022-05-25 18:43:35 +00:00
lint-enums :
docker :
- image : *GOLANG_IMAGE
steps :
- checkout
- run : go install github.com/reillywatson/enumcover/cmd/enumcover@master && enumcover ./...
- run : *notify-slack-failure
2020-03-12 01:18:03 +00:00
lint :
2021-06-28 22:39:30 +00:00
description : "Run golangci-lint"
parameters :
go-arch :
type : string
default : ""
2019-04-25 16:26:33 +00:00
docker :
2019-05-17 15:42:56 +00:00
- image : *GOLANG_IMAGE
2022-05-05 17:42:52 +00:00
resource_class : xlarge
2020-03-24 20:14:12 +00:00
environment :
GOTAGS : "" # No tags for OSS but there are for enterprise
2021-06-28 22:39:30 +00:00
GOARCH : "<<parameters.go-arch>>"
2019-04-25 16:26:33 +00:00
steps :
2019-05-17 15:42:56 +00:00
- checkout
2021-06-28 22:39:30 +00:00
- run : go env
2019-05-17 15:42:56 +00:00
- run :
2020-03-12 01:18:03 +00:00
name : Install golangci-lint
2022-05-23 15:50:45 +00:00
command : make lint-tools
2020-03-12 01:18:03 +00:00
- run : go mod download
2019-05-17 15:42:56 +00:00
- run :
2020-03-12 01:18:03 +00:00
name : lint
command : &lintcmd |
2022-05-05 17:42:52 +00:00
golangci-lint run --build-tags="$GOTAGS" -v
2020-03-12 01:18:03 +00:00
- run :
name : lint api
working_directory : api
command : *lintcmd
- run :
name : lint sdk
working_directory : sdk
command : *lintcmd
2020-07-28 18:54:48 +00:00
- run : *notify-slack-failure
2019-05-17 15:42:56 +00:00
2021-07-21 22:39:07 +00:00
check-go-mod :
2019-07-25 15:17:07 +00:00
docker :
- image : *GOLANG_IMAGE
environment :
<< : *ENVIRONMENT
steps :
- checkout
2021-07-21 22:39:07 +00:00
- run : go mod tidy
2019-07-25 15:17:07 +00:00
- run : |
2021-01-22 16:36:35 +00:00
if [[ -n $(git status -s) ]]; then
2021-01-21 23:29:26 +00:00
echo "Git directory has changes"
git status -s
2019-07-25 15:17:07 +00:00
exit 1
fi
2020-07-28 18:54:48 +00:00
- run : *notify-slack-failure
2019-07-25 15:17:07 +00:00
2020-07-27 18:18:09 +00:00
check-generated-protobuf :
docker :
- image : *GOLANG_IMAGE
environment :
<< : *ENVIRONMENT
2022-04-14 22:51:00 +00:00
# tput complains if this isn't set to something.
TERM : ansi
2020-07-27 18:18:09 +00:00
steps :
- checkout
- run :
2022-03-28 21:17:50 +00:00
name : Install protobuf
2022-03-29 20:18:05 +00:00
command : make proto-tools
2022-07-11 18:44:51 +00:00
- run :
name : "Protobuf Format"
command : make proto-format
2020-07-27 18:18:09 +00:00
- run :
command : make --always-make proto
- run : |
if ! git diff --exit-code; then
echo "Generated code was not updated correctly"
exit 1
fi
2022-07-11 18:44:51 +00:00
- run :
2022-05-23 14:37:52 +00:00
name : "Protobuf Lint"
command : make proto-lint
2020-07-27 18:18:09 +00:00
2022-10-14 09:26:42 +00:00
check-generated-deep-copy :
docker :
- image : *GOLANG_IMAGE
environment :
<< : *ENVIRONMENT
# tput complains if this isn't set to something.
TERM : ansi
steps :
- checkout
- run :
name : Install deep-copy
command : make codegen-tools
- run :
command : make --always-make deep-copy
- run : |
if ! git diff --exit-code; then
echo "Generated code was not updated correctly"
exit 1
fi
2021-12-09 13:55:10 +00:00
go-test-arm64 :
machine :
2022-05-17 15:25:38 +00:00
image : *UBUNTU_CI_IMAGE
2022-04-11 19:40:57 +00:00
resource_class : arm.large
2021-12-09 13:55:10 +00:00
parallelism : 4
environment :
<< : *ENVIRONMENT
GOTAGS : "" # No tags for OSS but there are for enterprise
# GOMAXPROCS defaults to number of cores on underlying hardware, set
# explicitly to avoid OOM issues https://support.circleci.com/hc/en-us/articles/360034684273-common-GoLang-memory-issues
GOMAXPROCS : 4
steps :
- checkout
- run :
2022-05-23 14:37:52 +00:00
command : |
2021-12-09 13:55:10 +00:00
sudo rm -rf /usr/local/go
2022-04-25 14:41:36 +00:00
wget https://dl.google.com/go/go${GO_VERSION}.linux-arm64.tar.gz
sudo tar -C /usr/local -xzvf go${GO_VERSION}.linux-arm64.tar.gz
2021-12-22 00:00:28 +00:00
- run : *install-gotestsum
2022-02-03 23:24:20 +00:00
- run : go mod download
- run :
name : make dev
2022-02-07 21:40:39 +00:00
command : |
if [[ "$CIRCLE_BRANCH" =~ ^main$|^release/ ]]; then
make dev
mkdir -p /home/circleci/bin
cp ./bin/consul /home/circleci/bin/consul
fi
2022-02-03 22:58:59 +00:00
- run-go-test-full :
go_test_flags : 'if ! [[ "$CIRCLE_BRANCH" =~ ^main$|^release/ ]]; then export GO_TEST_FLAGS="-short"; fi'
2022-03-25 13:30:30 +00:00
2019-05-17 15:42:56 +00:00
go-test :
docker :
- image : *GOLANG_IMAGE
2022-04-11 19:40:57 +00:00
resource_class : large
2020-01-28 17:21:55 +00:00
parallelism : 4
2019-05-17 15:42:56 +00:00
environment :
<< : *ENVIRONMENT
2019-08-21 19:56:27 +00:00
GOTAGS : "" # No tags for OSS but there are for enterprise
2020-03-31 16:32:23 +00:00
# GOMAXPROCS defaults to number of cores on underlying hardware, set
# explicitly to avoid OOM issues https://support.circleci.com/hc/en-us/articles/360034684273-common-GoLang-memory-issues
GOMAXPROCS : 4
2019-05-17 15:42:56 +00:00
steps :
- checkout
2021-12-22 00:00:28 +00:00
- run-go-test-full
2019-05-17 15:42:56 +00:00
2020-07-08 22:41:15 +00:00
go-test-race :
docker :
- image : *GOLANG_IMAGE
environment :
<< : *ENVIRONMENT
GOTAGS : "" # No tags for OSS but there are for enterprise
# GOMAXPROCS defaults to number of cores on underlying hardware, set
# explicitly to avoid OOM issues https://support.circleci.com/hc/en-us/articles/360034684273-common-GoLang-memory-issues
GOMAXPROCS : 4
# The medium resource class (default) boxes are 2 vCPUs, 4GB RAM
# https://circleci.com/docs/2.0/configuration-reference/#docker-executor
# but we can run a little over that limit.
steps :
- checkout
- run : go mod download
- run :
name : go test -race
command : |
2020-07-20 22:34:45 +00:00
mkdir -p $TEST_RESULTS_DIR /tmp/jsonfile
2020-11-11 18:15:33 +00:00
pkgs="$(go list ./... | \
2020-12-23 17:59:05 +00:00
grep -E -v '^github.com/hashicorp/consul/agent(/consul|/local|/routine-leak-checker)?$' | \
2020-11-11 18:15:33 +00:00
grep -E -v '^github.com/hashicorp/consul/command/')"
2020-07-08 22:41:15 +00:00
gotestsum \
2020-07-20 22:34:45 +00:00
--jsonfile /tmp/jsonfile/go-test-race.log \
2020-07-08 22:41:15 +00:00
--junitfile $TEST_RESULTS_DIR/gotestsum-report.xml -- \
-tags="$GOTAGS" -p 2 \
-race -gcflags=all=-d=checkptr=0 \
2020-11-11 18:15:33 +00:00
$pkgs
2020-07-08 22:41:15 +00:00
- store_test_results :
path : *TEST_RESULTS_DIR
- store_artifacts :
path : *TEST_RESULTS_DIR
2020-07-20 22:34:45 +00:00
- store_artifacts :
path : /tmp/jsonfile
2020-07-28 18:54:48 +00:00
- run : *notify-slack-failure
2020-07-08 22:41:15 +00:00
2022-03-25 13:30:30 +00:00
# go-test-32bit is to catch problems where 64-bit ints must be 64-bit aligned
2021-06-28 22:39:30 +00:00
# to use them with sync/atomic. See https://golang.org/pkg/sync/atomic/#pkg-note-BUG.
2022-03-25 13:30:30 +00:00
# Running tests with GOARCH=386 seems to be the best way to detect this
2021-06-28 22:39:30 +00:00
# problem. Only runs tests that are -short to limit the time we spend checking
# for these bugs.
go-test-32bit :
docker :
- image : *GOLANG_IMAGE
2022-04-11 19:40:57 +00:00
resource_class : large
2021-06-28 22:39:30 +00:00
environment :
<< : *ENVIRONMENT
GOTAGS : "" # No tags for OSS but there are for enterprise
steps :
- checkout
- run : go mod download
- run :
name : go test 32-bit
environment :
GOARCH : 386
command : |
mkdir -p $TEST_RESULTS_DIR /tmp/jsonfile
go env
2021-09-20 20:04:59 +00:00
PACKAGE_NAMES=$(go list -tags "$GOTAGS" ./...)
2021-06-28 22:39:30 +00:00
gotestsum \
--jsonfile /tmp/jsonfile/go-test-32bit.log \
2021-09-20 20:04:59 +00:00
--rerun-fails=3 \
--rerun-fails-max-failures=40 \
--rerun-fails-report=/tmp/gotestsum-rerun-fails \
--packages="$PACKAGE_NAMES" \
2021-06-28 22:39:30 +00:00
--junitfile $TEST_RESULTS_DIR/gotestsum-report.xml -- \
-tags="$GOTAGS" -p 2 \
2021-09-20 20:04:59 +00:00
-short
2021-06-28 22:39:30 +00:00
- store_test_results :
path : *TEST_RESULTS_DIR
- store_artifacts :
path : *TEST_RESULTS_DIR
- run : *notify-slack-failure
2021-06-24 16:24:12 +00:00
go-test-lib :
description : "test a library against a specific Go version"
parameters :
go-version :
type : string
path :
type : string
2019-05-17 15:42:56 +00:00
docker :
2021-12-10 19:04:56 +00:00
- image : "docker.mirror.hashicorp.services/cimg/go:<<parameters.go-version>>"
2019-04-25 16:26:33 +00:00
environment :
<< : *ENVIRONMENT
2019-08-21 19:56:27 +00:00
GOTAGS : "" # No tags for OSS but there are for enterprise
2019-05-17 15:42:56 +00:00
steps :
- checkout
- attach_workspace :
2021-12-10 19:04:56 +00:00
at : /home/circleci/go/bin
2020-04-01 21:02:15 +00:00
- run :
2021-06-24 16:24:12 +00:00
working_directory : <<parameters.path>>
2020-04-01 21:02:15 +00:00
command : go mod download
2019-05-17 15:42:56 +00:00
- run :
2021-06-24 16:24:12 +00:00
working_directory : <<parameters.path>>
2020-03-31 15:32:48 +00:00
name : go test
2019-05-17 15:42:56 +00:00
command : |
2020-05-02 20:42:39 +00:00
mkdir -p $TEST_RESULTS_DIR /tmp/jsonfile
2020-03-31 15:32:48 +00:00
gotestsum \
--format=short-verbose \
2021-06-24 16:24:12 +00:00
--jsonfile /tmp/jsonfile/go-test-<<parameters.path>>.log \
2020-03-31 15:32:48 +00:00
--junitfile $TEST_RESULTS_DIR/gotestsum-report.xml -- \
2020-03-31 17:09:17 +00:00
-tags="$GOTAGS" -cover -coverprofile=coverage.txt \
2020-03-31 15:32:48 +00:00
./...
2019-05-17 15:42:56 +00:00
- store_test_results :
2019-12-17 23:18:10 +00:00
path : *TEST_RESULTS_DIR
2019-05-17 15:42:56 +00:00
- store_artifacts :
2019-12-17 23:18:10 +00:00
path : *TEST_RESULTS_DIR
2020-05-02 20:42:39 +00:00
- store_artifacts :
path : /tmp/jsonfile
2020-07-28 18:54:48 +00:00
- run : *notify-slack-failure
2019-04-25 16:26:33 +00:00
2021-09-08 23:50:42 +00:00
# build is a templated job for build-x
2019-03-20 19:24:17 +00:00
build-distros : &build-distros
2019-03-08 20:33:03 +00:00
docker :
- image : *GOLANG_IMAGE
2022-04-11 19:40:57 +00:00
resource_class : large
2019-03-20 19:24:17 +00:00
environment : &build-env
2019-08-02 19:15:59 +00:00
<< : *ENVIRONMENT
2019-01-28 16:18:30 +00:00
steps :
- checkout
2021-09-08 23:50:42 +00:00
- run :
name : Build
command : |
for os in $XC_OS; do
target="./pkg/bin/${GOOS}_${GOARCH}/"
2022-05-04 17:45:23 +00:00
GOOS="$os" CGO_ENABLED=0 go build -o "${target}" -ldflags "${GOLDFLAGS}" -tags "${GOTAGS}"
2021-09-08 23:50:42 +00:00
done
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
2020-07-28 18:54:48 +00:00
- run : *notify-slack-failure
2019-03-20 19:24:17 +00:00
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
2020-11-13 18:02:59 +00:00
XC_OS : "freebsd linux windows"
2021-09-08 23:50:42 +00:00
GOARCH : "386"
2019-03-20 19:24:17 +00:00
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"
2021-09-08 23:50:42 +00:00
GOARCH : "amd64"
2019-03-20 19:24:17 +00:00
2019-04-02 16:24:48 +00:00
# build all arm/arm64 architecture supported OS binaries
2019-08-02 19:15:59 +00:00
build-arm :
docker :
- image : *GOLANG_IMAGE
2022-04-11 19:40:57 +00:00
resource_class : large
2019-03-20 19:24:17 +00:00
environment :
2019-08-02 19:15:59 +00:00
<< : *ENVIRONMENT
CGO_ENABLED : 1
GOOS : linux
steps :
- checkout
2021-11-05 20:38:23 +00:00
- run : sudo apt-get update --allow-releaseinfo-change-suite --allow-releaseinfo-change-version && sudo apt-get install -y gcc-arm-linux-gnueabi gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu
2019-08-02 19:15:59 +00:00
- run :
environment :
GOARM : 5
CC : arm-linux-gnueabi-gcc
GOARCH : arm
2020-06-05 18:21:57 +00:00
command : go build -o ./pkg/bin/linux_armel/consul -ldflags="-linkmode=external ${GOLDFLAGS}"
2019-08-02 19:15:59 +00:00
- run :
environment :
GOARM : 6
CC : arm-linux-gnueabihf-gcc
GOARCH : arm
2020-06-05 18:21:57 +00:00
command : go build -o ./pkg/bin/linux_armhf/consul -ldflags="-linkmode=external ${GOLDFLAGS}"
2019-08-02 19:15:59 +00:00
- run :
environment :
CC : aarch64-linux-gnu-gcc
GOARCH : arm64
2020-06-05 18:21:57 +00:00
command : go build -o ./pkg/bin/linux_aarch64/consul -ldflags="-linkmode=external ${GOLDFLAGS}"
2019-08-02 19:15:59 +00:00
- store_artifacts :
path : ./pkg/bin
2020-07-28 18:54:48 +00:00
- run : *notify-slack-failure
2019-03-20 19:24:17 +00:00
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
2022-04-11 19:40:57 +00:00
resource_class : large
2019-08-02 19:15:59 +00:00
environment :
<< : *ENVIRONMENT
2019-03-20 19:24:17 +00:00
steps :
- checkout
2021-06-29 21:04:24 +00:00
- attach_workspace : # this normally runs as the first job and has nothing to attach; only used in main branch after rebuilding UI
2020-03-27 19:33:49 +00:00
at : .
2019-05-17 15:42:56 +00:00
- run :
2021-09-08 23:50:42 +00:00
name : Build
command : |
make dev
mkdir -p /home/circleci/go/bin
cp ./bin/consul /home/circleci/go/bin/consul
2019-01-28 16:18:30 +00:00
# save dev build to pass to downstream jobs
- persist_to_workspace :
2021-12-10 19:04:56 +00:00
root : /home/circleci/go/bin
2019-01-28 16:18:30 +00:00
paths :
- consul
2020-07-28 18:54:48 +00:00
- run : *notify-slack-failure
2019-01-28 16:18:30 +00:00
2019-04-02 16:24:48 +00:00
# upload development build to s3
dev-upload-s3 :
docker :
2020-09-04 03:40:23 +00:00
- image : *GOLANG_IMAGE
2019-04-02 16:24:48 +00:00
environment :
<< : *ENVIRONMENT
steps :
2020-09-04 14:42:18 +00:00
- checkout
2020-09-04 03:40:23 +00:00
- *get-aws-cli
2021-01-14 04:25:21 +00:00
- assume-role :
access-key : AWS_ACCESS_KEY_ID_S3_UPLOAD
secret-key : AWS_SECRET_ACCESS_KEY_S3_UPLOAD
role-arn : ROLE_ARN_S3_UPLOAD
2019-04-02 16:24:48 +00:00
# get consul binary
- attach_workspace :
at : bin/
- run :
name : package binary
2021-01-14 04:27:17 +00:00
command : zip -j consul.zip bin/consul
2019-04-02 16:24:48 +00:00
- run :
name : Upload to s3
command : |
2019-04-04 20:03:07 +00:00
if [ -n "${S3_ARTIFACT_PATH}" ]; then
aws s3 cp \
--metadata "CIRCLECI=${CIRCLECI},CIRCLE_BUILD_URL=${CIRCLE_BUILD_URL},CIRCLE_BRANCH=${CIRCLE_BRANCH}" \
2021-01-14 04:27:17 +00:00
"consul.zip" "s3://${S3_ARTIFACT_BUCKET}/${S3_ARTIFACT_PATH}/${CIRCLE_SHA1}.zip" --acl public-read
2019-04-04 20:03:07 +00:00
else
echo "CircleCI - S3_ARTIFACT_PATH was not set"
exit 1
fi
2020-07-28 18:54:48 +00:00
- run : *notify-slack-failure
2019-04-02 16:24:48 +00:00
2019-07-25 13:19:09 +00:00
# upload dev docker image
dev-upload-docker :
docker :
2020-10-30 21:59:13 +00:00
- image : *GOLANG_IMAGE # use a circleci image so the attach_workspace step works (has ca-certs installed)
2019-07-25 13:19:09 +00:00
environment :
<< : *ENVIRONMENT
steps :
- checkout
# get consul binary
- attach_workspace :
at : bin/
2020-02-12 18:56:16 +00:00
- setup_remote_docker
2019-07-25 13:19:09 +00:00
- run : make ci.dev-docker
2020-07-28 18:54:48 +00:00
- run : *notify-slack-failure
2019-07-25 13:19:09 +00:00
2022-08-16 22:33:33 +00:00
nomad-integration-test : &NOMAD_TESTS
2019-03-08 20:33:03 +00:00
docker :
2022-08-16 22:33:33 +00:00
- image : docker.mirror.hashicorp.services/cimg/go:1.19
parameters :
nomad-version :
type : enum
enum : *supported_nomad_versions
default : *default_nomad_version
2019-03-08 20:33:03 +00:00
environment :
<< : *ENVIRONMENT
2022-06-01 18:34:44 +00:00
NOMAD_WORKING_DIR : &NOMAD_WORKING_DIR /home/circleci/go/src/github.com/hashicorp/nomad
2022-08-16 22:33:33 +00:00
NOMAD_VERSION : << parameters.nomad-version >>
2019-03-08 20:33:03 +00:00
steps : &NOMAD_INTEGRATION_TEST_STEPS
2022-08-16 22:33:33 +00:00
- run : git clone https://github.com/hashicorp/nomad.git --branch v${NOMAD_VERSION} ${NOMAD_WORKING_DIR}
2019-03-08 20:33:03 +00:00
# get consul binary
- attach_workspace :
2022-06-01 18:34:44 +00:00
at : /home/circleci/go/bin
2019-03-08 20:33:03 +00:00
# make dev build of nomad
- run :
2019-10-15 20:58:50 +00:00
command : make pkg/linux_amd64/nomad
2019-03-08 20:33:03 +00:00
working_directory : *NOMAD_WORKING_DIR
2020-07-17 17:00:31 +00:00
- run : *install-gotestsum
2019-03-08 20:33:03 +00:00
# run integration tests
- run :
2020-03-31 15:32:48 +00:00
name : go test
command : |
mkdir -p $TEST_RESULTS_DIR
gotestsum \
--format=short-verbose \
--junitfile $TEST_RESULTS_DIR/results.xml -- \
./command/agent/consul -run TestConsul
2019-03-08 20:33:03 +00:00
working_directory : *NOMAD_WORKING_DIR
# store test results for CircleCI
- store_test_results :
path : *TEST_RESULTS_DIR
- store_artifacts :
path : *TEST_RESULTS_DIR
2020-07-28 18:54:48 +00:00
- run : *notify-slack-failure
2019-01-28 16:18:30 +00:00
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
2021-10-14 14:14:26 +00:00
command : cd ui && make deps
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 :
2020-10-21 14:23:16 +00:00
- ui/node_modules
- ui/packages/consul-ui/node_modules
2020-07-28 18:54:48 +00:00
- run : *notify-slack-failure
2019-03-08 20:33:03 +00:00
2018-12-20 18:51:48 +00:00
# build ember so frontend tests run faster
2020-06-16 18:19:43 +00:00
ember-build-oss : &ember-build-oss
2018-12-20 18:51:48 +00:00
docker :
2019-03-08 20:33:03 +00:00
- image : *EMBER_IMAGE
2020-05-19 17:00:35 +00:00
environment :
JOBS : 2 # limit parallelism for broccoli-babel-transpiler
2020-06-16 18:19:43 +00:00
CONSUL_NSPACES_ENABLED : 0
2018-12-20 18:51:48 +00:00
steps :
- checkout
- restore_cache :
2019-03-08 20:33:03 +00:00
key : *YARN_CACHE_KEY
2020-10-21 14:23:16 +00:00
- run : cd ui/packages/consul-ui && make build-ci
2018-12-20 18:51:48 +00:00
# saves the build to a workspace to be passed to a downstream job
- persist_to_workspace :
2020-10-21 14:23:16 +00:00
root : ui
2018-12-20 18:51:48 +00:00
paths :
2020-10-21 14:23:16 +00:00
- packages/consul-ui/dist
2020-07-28 18:54:48 +00:00
- run : *notify-slack-failure
2019-01-04 03:57:40 +00:00
2020-06-16 18:19:43 +00:00
# build ember so frontend tests run faster
ember-build-ent :
<< : *ember-build-oss
environment :
JOBS : 2 # limit parallelism for broccoli-babel-transpiler
CONSUL_NSPACES_ENABLED : 1
2020-03-27 19:33:49 +00:00
# rebuild UI for packaging
ember-build-prod :
docker :
- image : *EMBER_IMAGE
2020-05-19 17:00:35 +00:00
environment :
JOBS : 2 # limit parallelism for broccoli-babel-transpiler
2020-03-27 19:33:49 +00:00
steps :
- checkout
- restore_cache :
key : *YARN_CACHE_KEY
2020-10-21 14:23:16 +00:00
- run : cd ui && make
2020-03-27 19:33:49 +00:00
# saves the build to a workspace to be passed to a downstream job
- persist_to_workspace :
2020-10-21 14:23:16 +00:00
root : ui
2020-03-27 19:33:49 +00:00
paths :
2020-10-21 14:23:16 +00:00
- packages/consul-ui/dist
2020-07-28 18:54:48 +00:00
- run : *notify-slack-failure
2020-03-27 19:33:49 +00:00
2020-09-29 21:03:45 +00:00
# commits static assets to git
publish-static-assets :
docker :
- image : *GOLANG_IMAGE
steps :
- checkout
- add_ssh_keys : # needs a key to push updated static asset commit back to github
fingerprints :
2021-04-22 14:08:55 +00:00
- "fc:55:84:15:0a:1d:c8:e9:06:d0:e8:9c:7b:a9:b7:31"
2020-09-29 21:03:45 +00:00
- attach_workspace :
at : .
- run :
2022-05-31 19:33:56 +00:00
name : move compiled ui files to agent/uiserver
command : |
rm -rf agent/uiserver/dist
2022-05-31 20:58:17 +00:00
mv packages/consul-ui/dist agent/uiserver
2022-05-31 19:33:56 +00:00
- run :
name : commit agent/uiserver/dist/ if there are UI changes
2020-09-29 21:03:45 +00:00
command : |
2020-10-21 14:23:16 +00:00
# check if there are any changes in ui/
2020-10-02 19:23:38 +00:00
# if there are, we commit the ui static asset file
# HEAD^! is shorthand for HEAD^..HEAD (parent of HEAD and HEAD)
2020-10-21 14:23:16 +00:00
if ! git diff --quiet --exit-code HEAD^! ui/; then
2021-04-22 14:08:55 +00:00
git config --local user.email "github-team-consul-core@hashicorp.com"
git config --local user.name "hc-github-team-consul-core"
2022-02-15 04:12:36 +00:00
# -B resets the CI branch to main which may diverge history
# but we will force push anyways.
git checkout -B ci/main-assetfs-build main
2020-09-30 15:12:36 +00:00
short_sha=$(git rev-parse --short HEAD)
2022-05-31 19:33:56 +00:00
git add agent/uiserver/dist/
git commit -m "auto-updated agent/uiserver/dist/ from commit ${short_sha}"
2022-02-15 04:12:36 +00:00
git push --force origin ci/main-assetfs-build
2020-09-29 21:03:45 +00:00
else
2020-10-02 19:23:38 +00:00
echo "no UI changes so no static assets to publish"
2020-09-29 21:03:45 +00:00
fi
- run : *notify-slack-failure
2020-10-06 19:58:12 +00:00
# run node tests
node-tests :
docker :
- image : *EMBER_IMAGE
steps :
- checkout
- restore_cache :
key : *YARN_CACHE_KEY
- attach_workspace :
2020-10-21 14:23:16 +00:00
at : ui
2020-10-06 19:58:12 +00:00
- run :
2020-10-21 14:23:16 +00:00
working_directory : ui/packages/consul-ui
2020-10-06 19:58:12 +00:00
command : make test-node
- run : *notify-slack-failure
2021-01-06 18:37:21 +00:00
# run yarn workspace wide checks/tests
workspace-tests :
docker :
- image : *EMBER_IMAGE
steps :
- checkout
- restore_cache :
key : *YARN_CACHE_KEY
- attach_workspace :
at : ui
- run :
working_directory : ui
command : make test-workspace
- run : *notify-slack-failure
2020-10-06 19:58:12 +00:00
2019-01-04 03:57:40 +00:00
# run ember frontend tests
2020-02-07 11:02:53 +00:00
ember-test-oss :
2018-12-20 18:51:48 +00:00
docker :
2019-03-08 20:33:03 +00:00
- image : *EMBER_IMAGE
2018-12-20 18:51:48 +00:00
environment :
2020-02-07 11:02:53 +00:00
EMBER_TEST_REPORT : test-results/report-oss.xml #outputs test report for CircleCI test summary
2020-02-10 13:41:02 +00:00
EMBER_TEST_PARALLEL : true #enables test parallelization with ember-exam
CONSUL_NSPACES_ENABLED : 0
2020-06-16 18:19:43 +00:00
parallelism : 4
2020-02-07 11:02:53 +00:00
steps :
- checkout
- restore_cache :
key : *YARN_CACHE_KEY
- attach_workspace :
2020-10-21 14:23:16 +00:00
at : ui
2020-02-07 11:02:53 +00:00
- run :
2020-10-21 14:23:16 +00:00
working_directory : ui/packages/consul-ui
2020-02-19 19:10:02 +00:00
command : node_modules/.bin/ember exam --split=$CIRCLE_NODE_TOTAL --partition=`expr $CIRCLE_NODE_INDEX + 1` --path dist --silent -r xunit
2020-02-07 11:02:53 +00:00
- store_test_results :
2020-10-21 14:23:16 +00:00
path : ui/packages/consul-ui/test-results
2020-07-28 18:54:48 +00:00
- run : *notify-slack-failure
2020-02-07 11:02:53 +00:00
# run ember frontend tests
ember-test-ent :
docker :
- image : *EMBER_IMAGE
environment :
EMBER_TEST_REPORT : test-results/report-ent.xml #outputs test report for CircleCI test summary
2020-02-10 13:41:02 +00:00
EMBER_TEST_PARALLEL : true #enables test parallelization with ember-exam
2020-10-19 16:29:43 +00:00
CONSUL_NSPACES_ENABLED : 1
2020-06-16 18:19:43 +00:00
parallelism : 4
2018-12-20 18:51:48 +00:00
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 :
2020-10-21 14:23:16 +00:00
at : ui
2018-12-20 18:51:48 +00:00
- run :
2020-10-21 14:23:16 +00:00
working_directory : ui/packages/consul-ui
2020-02-19 19:10:02 +00:00
command : node_modules/.bin/ember exam --split=$CIRCLE_NODE_TOTAL --partition=`expr $CIRCLE_NODE_INDEX + 1` --path dist --silent -r xunit
2018-12-20 18:51:48 +00:00
- store_test_results :
2020-10-21 14:23:16 +00:00
path : ui/packages/consul-ui/test-results
2020-07-28 18:54:48 +00:00
- run : *notify-slack-failure
2020-02-10 10:04:55 +00:00
# run ember frontend unit tests to produce coverage report
ember-coverage :
docker :
- image : *EMBER_IMAGE
steps :
- checkout
- restore_cache :
key : *YARN_CACHE_KEY
- attach_workspace :
2020-10-21 14:23:16 +00:00
at : ui
2020-02-10 10:04:55 +00:00
- run :
2020-10-21 14:23:16 +00:00
working_directory : ui/packages/consul-ui
2020-02-21 13:44:25 +00:00
command : make test-coverage-ci
2020-07-28 18:54:48 +00:00
- run : *notify-slack-failure
2022-05-23 14:37:52 +00:00
2022-04-25 14:41:36 +00:00
compatibility-integration-test :
machine :
2022-05-17 15:25:38 +00:00
image : *UBUNTU_CI_IMAGE
2022-04-25 14:41:36 +00:00
docker_layer_caching : true
parallelism : 1
steps :
- checkout
# Get go binary from workspace
- attach_workspace :
at : .
2022-08-29 23:13:49 +00:00
# Build the consul:local image from the already built binary
2022-04-25 14:41:36 +00:00
- run :
command : |
sudo rm -rf /usr/local/go
wget https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz
sudo tar -C /usr/local -xzvf go${GO_VERSION}.linux-amd64.tar.gz
environment :
<< : *ENVIRONMENT
- run : *install-gotestsum
- run : docker build -t consul:local -f ./build-support/docker/Consul-Dev.dockerfile .
- run :
name : Compatibility Integration Tests
command : |
mkdir -p /tmp/test-results/
cd ./test/integration/consul-container
2022-06-06 21:06:55 +00:00
docker run --rm consul:local consul version
gotestsum \
--format=short-verbose \
--debug \
--rerun-fails=3 \
--packages="./..." \
-- \
-timeout=30m \
./... \
--target-version local \
--latest-version latest
2022-04-25 14:41:36 +00:00
ls -lrt
environment :
# this is needed because of incompatibility between RYUK container and circleci
GOTESTSUM_JUNITFILE : /tmp/test-results/results.xml
GOTESTSUM_FORMAT : standard-verbose
COMPOSE_INTERACTIVE_NO_CLI : 1
# tput complains if this isn't set to something.
TERM : ansi
- store_artifacts :
2022-11-01 19:03:23 +00:00
path : ./test/integration/consul-container/test/upgrade/workdir/logs
2022-04-25 14:41:36 +00:00
destination : container-logs
- store_test_results :
path : *TEST_RESULTS_DIR
- store_artifacts :
path : *TEST_RESULTS_DIR
- run : *notify-slack-failure
2022-05-23 14:37:52 +00:00
2022-06-28 12:15:45 +00:00
envoy-integration-test : &ENVOY_TESTS
2022-04-07 16:25:10 +00:00
machine :
2022-05-17 15:25:38 +00:00
image : *UBUNTU_CI_IMAGE
2022-04-07 16:25:10 +00:00
parallelism : 4
resource_class : medium
2022-06-28 12:15:45 +00:00
parameters :
envoy-version :
type : enum
enum : *supported_envoy_versions
default : *default_envoy_version
xds-target :
type : enum
enum : [ "server" , "client" ]
default : "server"
2019-04-29 16:27:57 +00:00
environment :
2022-06-28 12:15:45 +00:00
ENVOY_VERSION : << parameters.envoy-version >>
XDS_TARGET : << parameters.xds-target >>
2022-07-21 16:54:56 +00:00
AWS_LAMBDA_REGION : us-west-2
2019-08-21 19:56:27 +00:00
steps : &ENVOY_INTEGRATION_TEST_STEPS
2019-04-29 16:27:57 +00:00
- checkout
2022-07-21 16:54:56 +00:00
- assume-role :
access-key : AWS_ACCESS_KEY_ID_LAMBDA
secret-key : AWS_SECRET_ACCESS_KEY_LAMBDA
role-arn : ROLE_ARN_LAMBDA
2019-04-29 16:27:57 +00:00
# Get go binary from workspace
- attach_workspace :
at : .
2022-04-07 16:25:10 +00:00
- run : *install-gotestsum
2022-08-29 23:13:49 +00:00
# Build the consul:local image from the already built binary
- run : docker build -t consul:local -f ./build-support/docker/Consul-Dev.dockerfile .
2019-04-29 16:27:57 +00:00
- run :
name : Envoy Integration Tests
2020-05-19 18:00:00 +00:00
command : |
2020-10-23 15:53:24 +00:00
subtests=$(ls -d test/integration/connect/envoy/*/ | xargs -n 1 basename | circleci tests split)
echo "Running $(echo $subtests | wc -w) subtests"
echo "$subtests"
subtests_pipe_sepr=$(echo "$subtests" | xargs | sed 's/ /|/g')
2020-05-19 18:00:00 +00:00
mkdir -p /tmp/test-results/
2020-10-23 15:53:24 +00:00
gotestsum -- -timeout=30m -tags integration ./test/integration/connect/envoy -run="TestEnvoy/($subtests_pipe_sepr)"
2019-04-29 16:27:57 +00:00
environment :
2020-05-19 18:00:00 +00:00
GOTESTSUM_JUNITFILE : /tmp/test-results/results.xml
GOTESTSUM_FORMAT : standard-verbose
COMPOSE_INTERACTIVE_NO_CLI : 1
2022-08-29 23:13:49 +00:00
LAMBDA_TESTS_ENABLED : "true"
2019-04-29 16:27:57 +00:00
# tput complains if this isn't set to something.
TERM : ansi
- store_artifacts :
path : ./test/integration/connect/envoy/workdir/logs
destination : container-logs
2020-05-19 18:00:00 +00:00
- store_test_results :
path : *TEST_RESULTS_DIR
- store_artifacts :
path : *TEST_RESULTS_DIR
2020-07-28 18:54:48 +00:00
- run : *notify-slack-failure
2019-04-29 16:27:57 +00:00
2020-03-24 19:16:13 +00:00
# run integration tests for the connect ca providers
test-connect-ca-providers :
2019-12-17 21:22:32 +00:00
docker :
- image : *GOLANG_IMAGE
environment :
<< : *ENVIRONMENT
steps :
2020-03-31 15:32:48 +00:00
- run :
name : Install vault
command : |
wget -q -O /tmp/vault.zip https://releases.hashicorp.com/vault/${VAULT_BINARY_VERSION}/vault_${VAULT_BINARY_VERSION}_linux_amd64.zip
sudo unzip -d /usr/local/bin /tmp/vault.zip
rm -rf /tmp/vault*
2019-12-17 21:22:32 +00:00
- checkout
2020-03-31 15:32:48 +00:00
- run : go mod download
- run :
name : go test
command : |
mkdir -p $TEST_RESULTS_DIR
make test-connect-ca-providers
2019-12-17 21:22:32 +00:00
- store_test_results :
2019-12-17 23:18:10 +00:00
path : *TEST_RESULTS_DIR
2020-07-28 18:54:48 +00:00
- run : *notify-slack-failure
2019-12-17 21:22:32 +00:00
2021-01-14 04:30:00 +00:00
# Run load tests against a commit
load-test :
docker :
- image : hashicorp/terraform:latest
environment :
AWS_DEFAULT_REGION : us-east-2
BUCKET : consul-ci-load-tests
2021-05-21 18:19:26 +00:00
BASH_ENV : /etc/profile
shell : /bin/sh -leo pipefail
2021-01-14 04:30:00 +00:00
steps :
- checkout
- run : apk add jq curl bash
- run :
name : export load-test credentials
command : |
echo "export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID_LOAD_TEST" >> $BASH_ENV
echo "export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY_LOAD_TEST" >> $BASH_ENV
- run :
name : export role arn
command : |
echo "export TF_VAR_role_arn=$ROLE_ARN_LOAD_TEST" >> $BASH_ENV
- run :
name : setup TF_VARs
command : |
2021-02-03 20:59:37 +00:00
# if pipeline.parameters.commit="" it was not triggered/set through the API
# so we use the latest commit from _this_ branch. This is the case for nightly tests.
if [ "<< pipeline.parameters.commit >>" = "" ]; then
LOCAL_COMMIT_SHA=$(git rev-parse HEAD)
else
LOCAL_COMMIT_SHA="<< pipeline.parameters.commit >>"
fi
echo "export LOCAL_COMMIT_SHA=${LOCAL_COMMIT_SHA}" >> $BASH_ENV
2022-05-27 18:49:39 +00:00
git checkout ${LOCAL_COMMIT_SHA}
2021-02-03 20:59:37 +00:00
short_ref=$(git rev-parse --short ${LOCAL_COMMIT_SHA})
2021-01-14 04:30:00 +00:00
echo "export TF_VAR_ami_owners=$LOAD_TEST_AMI_OWNERS" >> $BASH_ENV
echo "export TF_VAR_vpc_name=$short_ref" >> $BASH_ENV
echo "export TF_VAR_cluster_name=$short_ref" >> $BASH_ENV
2021-02-03 20:59:37 +00:00
echo "export TF_VAR_consul_download_url=https://${S3_ARTIFACT_BUCKET}.s3.${AWS_DEFAULT_REGION}.amazonaws.com/${S3_ARTIFACT_PATH}/${LOCAL_COMMIT_SHA}.zip" >> $BASH_ENV
2021-01-14 04:30:00 +00:00
- run :
name : wait for dev build from test-integrations workflow
command : |
2021-02-03 20:59:37 +00:00
echo "curl-ing https://${S3_ARTIFACT_BUCKET}.s3.${AWS_DEFAULT_REGION}.amazonaws.com/${S3_ARTIFACT_PATH}/${LOCAL_COMMIT_SHA}.zip"
2021-01-14 04:30:00 +00:00
until [ $SECONDS -ge 300 ] && exit 1; do
2021-02-03 20:59:37 +00:00
curl -o /dev/null --fail --silent "https://${S3_ARTIFACT_BUCKET}.s3.${AWS_DEFAULT_REGION}.amazonaws.com/${S3_ARTIFACT_PATH}/${LOCAL_COMMIT_SHA}.zip" && exit
2021-01-14 04:30:00 +00:00
echo -n "."
sleep 2
done
- run :
working_directory : .circleci/terraform/load-test
name : terraform init
command : |
2022-05-27 18:49:39 +00:00
short_ref=$(git rev-parse --short HEAD)
echo "Testing commit id: $short_ref"
2021-01-14 04:30:00 +00:00
terraform init \
-backend-config="bucket=${BUCKET}" \
2021-02-03 20:59:37 +00:00
-backend-config="key=${LOCAL_COMMIT_SHA}" \
2021-01-14 04:30:00 +00:00
-backend-config="region=${AWS_DEFAULT_REGION}" \
-backend-config="role_arn=${ROLE_ARN_LOAD_TEST}"
- run :
working_directory : .circleci/terraform/load-test
name : run terraform apply
command : |
terraform apply -auto-approve
- run :
working_directory : .circleci/terraform/load-test
when : always
name : terraform destroy
command : |
2022-05-27 18:49:39 +00:00
for i in $(seq 1 5); do terraform destroy -auto-approve && s=0 && break || s=$? && sleep 20; done; (exit $s)
2021-02-03 20:59:37 +00:00
- run : *notify-slack-failure
2021-01-14 04:30:00 +00:00
2021-05-06 16:26:10 +00:00
# The noop job is a used as a very fast job in the verify-ci workflow because every workflow
# requires at least one job. It does nothing.
noop :
docker :
- image : docker.mirror.hashicorp.services/alpine:latest
steps :
2021-05-21 18:19:26 +00:00
- run : "echo ok"
2021-05-06 16:26:10 +00:00
2022-11-10 20:43:37 +00:00
show-coverage :
docker :
- image : *GOLANG_IMAGE
steps :
- checkout
- attach_workspace :
at : /tmp
- run :
name : collate coverage output into single file and convert to readable format
command : |
mkdir -p /tmp/output
echo "mode: set" > cov.txt
for f in /tmp/coverage/*; do tail -n +2 $f >> cov.txt; done
go tool cover -func=cov.txt -o /tmp/output/coverage_by_function.txt
cp cov.txt /tmp/output/cov.txt
- run : sudo apt-get install jq
- run :
name : get diff of test coverage from changes
command : |
repository="consul"
file_url_response=$(curl --location --request GET "https://api.github.com/repos/hashicorp/$repository/contents/.github/cover.out?ref=$TEST_COVERAGE_GOLDEN_BRANCH" \
-u $GH_USER:$GH_TOKEN)
if [ $(echo $file_url_response | jq length) -eq 0 ]; then
echo "No coverage report file found"
exit 1
else
file_download_url=$(echo $file_url_response | jq -r '.download_url')
fi
echo "Downloading $file_download_url"
curl "$file_download_url" > main_cov.txt
echo "mode: set" > diff_cov.txt
comm -13 <(sort main_cov.txt) <(sort cov.txt) >> diff_cov.txt
go tool cover -html=diff_cov.txt -o /tmp/output/diff_coverage_heatmap.html
- store_artifacts :
path : /tmp/output
- run :
name : post results to GitHub PR
command : |
repository="consul"
pr_response=$(curl --location --request GET "https://api.github.com/repos/hashicorp/$repository/pulls?head=hashicorp:$CIRCLE_BRANCH&state=open" \
-u $GH_USER:$GH_TOKEN)
if [ $(echo $pr_response | jq length) -eq 0 ]; then
echo "No PR found to update"
exit 1
else
pr_comment_url=$(echo $pr_response | jq -r ".[]._links.comments.href")
fi
new_cov_percent=$(tail -1 /tmp/output/coverage_by_function.txt | awk -F' ' '{print $NF}')
go tool cover -func=main_cov.txt -o main_cov_by_func.txt
main_go_test_cov_percent=$(tail -1 main_cov_by_func.txt | awk -F' ' '{print $NF}')
artifacts=$(curl -X GET "https://circleci.com/api/v2/project/github/hashicorp/$repository/$CIRCLE_BUILD_NUM/artifacts" \
-H "Accept: application/json" \
-u "$CIRCLE_API_TOKEN:")
heatmap_url=$(echo $artifacts | jq -r '.items|.[]|select(.path | endswith("heatmap.html"))|.url')
message="All unit tests passed! Your changes bring test coverage over affected code to $new_cov_percent. Total coverage in main is $main_go_test_cov_percent. [See coverage delta for your changes]($heatmap_url)"
curl --location --request POST "$pr_comment_url" \
-u hc-github-team-consul-core:$HC_GITHUB_TEAM_CONSUL_CORE_GITHUB_TOKEN \
--header 'Content-Type : application/json' \
--data-raw '{
"body": "'" $message"'"
}'
- add_ssh_keys :
fingerprints :
- "b1:4d:ed:a5:4f:e1:39:28:37:ab:bd:4d:06:e5:24:ca"
- run :
name : push latest coverage results to github
command : |
cp cov.txt .github/go_test_coverage.txt
git config user.email "github-team-consul-core@hashicorp.com"
git config user.name "hc-github-team-consul-core"
git add .github/go_test_coverage.txt
git commit -m "[skip ci] update test coverage"
git push --set-upstream origin $CIRCLE_BRANCH
2018-11-16 19:01:02 +00:00
workflows :
version : 2
2021-05-06 16:26:10 +00:00
# verify-ci is a no-op workflow that must run on every PR. It is used in a
# branch protection rule to detect when CI workflows are not running.
verify-ci :
2022-05-23 14:37:52 +00:00
jobs : [ noop]
2021-05-06 16:26:10 +00:00
2019-07-22 22:08:54 +00:00
go-tests :
2021-01-14 04:30:00 +00:00
unless : << pipeline.parameters.trigger-load-test >>
2019-03-20 19:24:17 +00:00
jobs :
2021-07-21 22:39:07 +00:00
- check-go-mod : &filter-ignore-non-go-branches
2019-11-08 17:55:56 +00:00
filters :
branches :
ignore :
- stable-website
2020-02-14 02:41:37 +00:00
- /^docs\/.*/
2020-02-14 14:40:02 +00:00
- /^ui\/.*/
2020-07-27 18:18:09 +00:00
- check-generated-protobuf : *filter-ignore-non-go-branches
2022-10-14 09:26:42 +00:00
- check-generated-deep-copy : *filter-ignore-non-go-branches
2022-05-25 18:43:35 +00:00
- lint-enums : *filter-ignore-non-go-branches
2020-04-07 19:39:23 +00:00
- lint-consul-retry : *filter-ignore-non-go-branches
- lint : *filter-ignore-non-go-branches
2021-06-28 22:39:30 +00:00
- lint :
name : "lint-32bit"
go-arch : "386"
<< : *filter-ignore-non-go-branches
2020-04-07 19:39:23 +00:00
- test-connect-ca-providers : *filter-ignore-non-go-branches
2021-12-22 00:00:28 +00:00
- go-test-arm64 : *filter-ignore-non-go-branches
2020-04-07 19:39:23 +00:00
- dev-build : *filter-ignore-non-go-branches
2020-03-31 15:32:48 +00:00
- go-test :
2022-05-23 14:37:52 +00:00
requires : [ dev-build]
2021-06-24 16:24:12 +00:00
- go-test-lib :
2022-04-14 20:55:10 +00:00
name : "go-test-api go1.18"
2021-06-24 16:24:12 +00:00
path : api
2022-04-14 20:55:10 +00:00
go-version : "1.18"
2022-05-23 14:37:52 +00:00
requires : [ dev-build]
2021-06-24 16:24:12 +00:00
- go-test-lib :
2022-10-21 14:31:09 +00:00
name : "go-test-api go1.19"
path : api
go-version : "1.19"
requires : [ dev-build ]
2021-06-24 16:24:12 +00:00
- go-test-lib :
2022-04-14 20:55:10 +00:00
name : "go-test-sdk go1.18"
2021-06-24 16:24:12 +00:00
path : sdk
2022-04-14 20:55:10 +00:00
go-version : "1.18"
2021-06-24 16:24:12 +00:00
<< : *filter-ignore-non-go-branches
2022-10-21 14:31:09 +00:00
- go-test-lib :
name : "go-test-sdk go1.19"
path : sdk
go-version : "1.19"
<< : *filter-ignore-non-go-branches
2020-07-08 22:41:15 +00:00
- go-test-race : *filter-ignore-non-go-branches
2021-06-28 22:39:30 +00:00
- go-test-32bit : *filter-ignore-non-go-branches
2022-11-10 20:43:37 +00:00
- show-coverage :
requires :
- go-test
filters :
branches :
ignore :
- main # we don't want tests run in main to overwrite coverage reports from the latest merge
- /^release\/.*$/ # we don't want to compare coverage on release branches
2022-05-26 20:14:35 +00:00
- noop
2019-07-22 22:08:54 +00:00
build-distros :
2021-01-14 04:30:00 +00:00
unless : << pipeline.parameters.trigger-load-test >>
2019-07-22 22:08:54 +00:00
jobs :
2021-07-21 22:39:07 +00:00
- check-go-mod : *filter-ignore-non-go-branches
- build-386 : &require-check-go-mod
2019-10-08 19:55:36 +00:00
requires :
2021-07-21 22:39:07 +00:00
- check-go-mod
- build-amd64 : *require-check-go-mod
- build-arm : *require-check-go-mod
2021-06-29 21:04:24 +00:00
# every commit on main will have a rebuilt UI
2020-03-27 19:33:49 +00:00
- frontend-cache :
filters :
branches :
only :
2021-06-29 21:04:24 +00:00
- main
2020-03-27 19:33:49 +00:00
- ember-build-prod :
requires :
- frontend-cache
2020-09-29 21:03:45 +00:00
- publish-static-assets :
requires :
2022-05-31 19:33:56 +00:00
- ember-build-prod
2020-03-27 19:33:49 +00:00
- dev-build :
requires :
2022-05-31 19:33:56 +00:00
- ember-build-prod
2020-03-27 19:33:49 +00:00
- dev-upload-s3 :
requires :
- dev-build
- dev-upload-docker :
requires :
- dev-build
context : consul-ci
2022-05-26 20:14:35 +00:00
- noop
2019-07-22 22:08:54 +00:00
test-integrations :
2021-01-14 04:30:00 +00:00
unless : << pipeline.parameters.trigger-load-test >>
2019-07-22 22:08:54 +00:00
jobs :
2020-04-07 19:39:23 +00:00
- dev-build : *filter-ignore-non-go-branches
2019-07-25 13:19:09 +00:00
- dev-upload-s3 : &dev-upload
2019-04-02 16:24:48 +00:00
requires :
- dev-build
filters :
branches :
ignore :
- /^pull\/.*$/ # only push dev builds from non forks
2021-06-29 21:04:24 +00:00
- main # all main dev uploads will include a UI rebuild in build-distros
2019-07-25 13:19:09 +00:00
- dev-upload-docker :
<< : *dev-upload
context : consul-ci
2022-08-16 22:33:33 +00:00
- nomad-integration-test :
2019-01-28 16:18:30 +00:00
requires :
- dev-build
2022-08-16 22:33:33 +00:00
matrix :
parameters :
nomad-version : *supported_nomad_versions
2022-06-28 12:15:45 +00:00
- envoy-integration-test :
2022-04-18 16:36:07 +00:00
requires :
- dev-build
2022-06-28 12:15:45 +00:00
matrix :
parameters :
envoy-version : *supported_envoy_versions
xds-target : [ "server" , "client" ]
2022-04-25 14:41:36 +00:00
- compatibility-integration-test :
requires :
- dev-build
2022-05-26 20:14:35 +00:00
- noop
2018-12-20 18:51:48 +00:00
frontend :
2021-01-14 04:30:00 +00:00
unless : << pipeline.parameters.trigger-load-test >>
2018-12-20 18:51:48 +00:00
jobs :
2019-11-08 17:55:56 +00:00
- frontend-cache :
filters :
branches :
2020-05-13 19:40:30 +00:00
only :
2021-06-29 21:04:24 +00:00
- main
2020-05-13 19:40:30 +00:00
- /^ui\/.*/
2021-01-06 18:37:21 +00:00
- workspace-tests :
requires :
- frontend-cache
2020-10-06 19:58:12 +00:00
- node-tests :
requires :
- frontend-cache
2020-06-16 18:19:43 +00:00
- ember-build-oss :
requires :
- frontend-cache
- ember-build-ent :
2018-12-20 18:51:48 +00:00
requires :
- frontend-cache
2020-02-07 11:02:53 +00:00
- ember-test-oss :
requires :
2020-06-16 18:19:43 +00:00
- ember-build-oss
2020-02-07 11:02:53 +00:00
- ember-test-ent :
2018-12-20 18:51:48 +00:00
requires :
2020-06-16 18:19:43 +00:00
- ember-build-ent
2021-01-06 18:37:51 +00:00
# ember-coverage in CI uses the dist/ folder to run tests so it requires
# either/or ent/oss to be built first
2020-02-10 10:04:55 +00:00
- ember-coverage :
requires :
2020-06-16 18:19:43 +00:00
- ember-build-ent
2022-05-26 20:14:35 +00:00
- noop
2022-05-06 19:38:02 +00:00
2021-01-14 04:30:00 +00:00
load-test :
when : << pipeline.parameters.trigger-load-test >>
jobs :
- load-test
2021-02-03 20:59:37 +00:00
nightly-jobs :
triggers :
- schedule :
cron : "0 4 * * *" # 4AM UTC <> 12AM EST <> 9PM PST should have no impact
filters :
branches :
only :
2021-06-29 21:04:24 +00:00
- main
2021-02-03 20:59:37 +00:00
jobs :
2022-11-10 20:43:37 +00:00
- load-test