Skip to content

Commit

Permalink
backport of commit 6e7a8f1
Browse files Browse the repository at this point in the history
  • Loading branch information
huikang committed Jun 2, 2022
1 parent d54199f commit 10416dd
Show file tree
Hide file tree
Showing 536 changed files with 9,534 additions and 59,283 deletions.
3 changes: 0 additions & 3 deletions .changelog/10996.txt

This file was deleted.

3 changes: 0 additions & 3 deletions .changelog/12695.txt

This file was deleted.

3 changes: 0 additions & 3 deletions .changelog/12787.txt

This file was deleted.

3 changes: 0 additions & 3 deletions .changelog/12807.txt

This file was deleted.

3 changes: 0 additions & 3 deletions .changelog/12819.txt

This file was deleted.

3 changes: 0 additions & 3 deletions .changelog/12825.txt

This file was deleted.

3 changes: 0 additions & 3 deletions .changelog/12844.txt

This file was deleted.

3 changes: 0 additions & 3 deletions .changelog/12865.txt

This file was deleted.

4 changes: 0 additions & 4 deletions .changelog/12881.txt

This file was deleted.

3 changes: 0 additions & 3 deletions .changelog/12885.txt

This file was deleted.

3 changes: 0 additions & 3 deletions .changelog/12914.txt

This file was deleted.

3 changes: 0 additions & 3 deletions .changelog/12935.txt

This file was deleted.

3 changes: 0 additions & 3 deletions .changelog/13001.txt

This file was deleted.

3 changes: 0 additions & 3 deletions .changelog/13012.txt

This file was deleted.

3 changes: 0 additions & 3 deletions .changelog/13062.txt

This file was deleted.

3 changes: 0 additions & 3 deletions .changelog/13143.txt

This file was deleted.

3 changes: 0 additions & 3 deletions .changelog/_1679.txt

This file was deleted.

156 changes: 57 additions & 99 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,18 @@ parameters:
description: "Boolean whether to run the load test workflow"

references:
images:
# When updating the Go version, remember to also update the versions in the
# workflows section for go-test-lib jobs.
go: &GOLANG_IMAGE docker.mirror.hashicorp.services/cimg/go:1.18.1
ember: &EMBER_IMAGE docker.mirror.hashicorp.services/circleci/node:14-browsers

paths:
test-results: &TEST_RESULTS_DIR /tmp/test-results

cache:
yarn: &YARN_CACHE_KEY consul-ui-v7-{{ checksum "ui/yarn.lock" }}

environment: &ENVIRONMENT
TEST_RESULTS_DIR: *TEST_RESULTS_DIR
EMAIL: noreply@hashicorp.com
Expand All @@ -22,15 +32,6 @@ references:
S3_ARTIFACT_BUCKET: consul-dev-artifacts-v2
BASH_ENV: .circleci/bash_env.sh
VAULT_BINARY_VERSION: 1.9.4
GO_VERSION: 1.18.1
images:
# When updating the Go version, remember to also update the versions in the
# workflows section for go-test-lib jobs.
go: &GOLANG_IMAGE docker.mirror.hashicorp.services/cimg/go:1.18.1
ember: &EMBER_IMAGE docker.mirror.hashicorp.services/circleci/node:14-browsers
ubuntu: &UBUNTU_CI_IMAGE ubuntu-2004:202201-02
cache:
yarn: &YARN_CACHE_KEY consul-ui-v7-{{ checksum "ui/yarn.lock" }}

steps:
install-gotestsum: &install-gotestsum
Expand Down Expand Up @@ -168,14 +169,6 @@ jobs:
- run: go install github.com/hashicorp/lint-consul-retry@master && lint-consul-retry
- run: *notify-slack-failure

lint-enums:
docker:
- image: *GOLANG_IMAGE
steps:
- checkout
- run: go install github.com/reillywatson/enumcover/cmd/enumcover@master && enumcover ./...
- run: *notify-slack-failure

lint:
description: "Run golangci-lint"
parameters:
Expand All @@ -184,7 +177,7 @@ jobs:
default: ""
docker:
- image: *GOLANG_IMAGE
resource_class: xlarge
resource_class: large
environment:
GOTAGS: "" # No tags for OSS but there are for enterprise
GOARCH: "<<parameters.go-arch>>"
Expand All @@ -193,12 +186,14 @@ jobs:
- run: go env
- run:
name: Install golangci-lint
command: make lint-tools
command: |
download=https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh
wget -O- -q $download | sh -x -s -- -d -b /home/circleci/go/bin v1.45.2
- run: go mod download
- run:
name: lint
command: &lintcmd |
golangci-lint run --build-tags="$GOTAGS" -v
golangci-lint run --build-tags="$GOTAGS" -v --concurrency 2
- run:
name: lint api
working_directory: api
Expand Down Expand Up @@ -245,13 +240,10 @@ jobs:
echo "Generated code was not updated correctly"
exit 1
fi
- run:
name: "Protobuf Lint"
command: make proto-lint
go-test-arm64:
machine:
image: *UBUNTU_CI_IMAGE
image: ubuntu-2004:202101-01
resource_class: arm.large
parallelism: 4
environment:
Expand All @@ -263,10 +255,10 @@ jobs:
steps:
- checkout
- run:
command: |
command: |
sudo rm -rf /usr/local/go
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
wget https://golang.org/dl/go1.17.5.linux-arm64.tar.gz
sudo tar -C /usr/local -xzvf go1.17.5.linux-arm64.tar.gz
- run: *install-gotestsum
- run: go mod download
- run:
Expand Down Expand Up @@ -424,7 +416,7 @@ jobs:
command: |
for os in $XC_OS; do
target="./pkg/bin/${GOOS}_${GOARCH}/"
GOOS="$os" CGO_ENABLED=0 go build -o "${target}" -ldflags "${GOLDFLAGS}" -tags "${GOTAGS}"
GOOS="$os" CGO_ENABLED=0 go build -o "$target" -ldflags "$(GOLDFLAGS)" -tags "$(GOTAGS)"
done
# save dev build to CircleCI
Expand Down Expand Up @@ -672,6 +664,23 @@ jobs:
- packages/consul-ui/dist
- run: *notify-slack-failure

# build static-assets file
build-static-assets:
docker:
- image: *GOLANG_IMAGE
steps:
- checkout
- attach_workspace:
at: ./pkg
- run: mv pkg/packages/consul-ui/dist pkg/web_ui # 'make static-assets' looks for the 'pkg/web_ui' path
- run: make tools
- run: make static-assets
- persist_to_workspace:
root: .
paths:
- ./agent/uiserver/bindata_assetfs.go
- run: *notify-slack-failure

# commits static assets to git
publish-static-assets:
docker:
Expand All @@ -684,12 +693,7 @@ jobs:
- attach_workspace:
at: .
- run:
name: move compiled ui files to agent/uiserver
command: |
rm -rf agent/uiserver/dist
mv packages/consul-ui/dist agent/uiserver
- run:
name: commit agent/uiserver/dist/ if there are UI changes
name: commit agent/uiserver/bindata_assetfs.go if there are UI changes
command: |
# check if there are any changes in ui/
# if there are, we commit the ui static asset file
Expand All @@ -703,8 +707,8 @@ jobs:
git checkout -B ci/main-assetfs-build main
short_sha=$(git rev-parse --short HEAD)
git add agent/uiserver/dist/
git commit -m "auto-updated agent/uiserver/dist/ from commit ${short_sha}"
git add agent/uiserver/bindata_assetfs.go
git commit -m "auto-updated agent/uiserver/bindata_assetfs.go from commit ${short_sha}"
git push --force origin ci/main-assetfs-build
else
echo "no UI changes so no static assets to publish"
Expand Down Expand Up @@ -799,57 +803,9 @@ jobs:
command: make test-coverage-ci
- run: *notify-slack-failure

compatibility-integration-test:
machine:
image: *UBUNTU_CI_IMAGE
docker_layer_caching: true
parallelism: 1
steps:
- checkout
# Get go binary from workspace
- attach_workspace:
at: .
# Build the consul-dev image from the already built binary
- 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: |
subtests=$(ls -d test/integration/consul-container/*/ | grep -v libs | 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')
mkdir -p /tmp/test-results/
docker run consul:local consul version
cd ./test/integration/consul-container
gotestsum -- -timeout=30m ./$subtests_pipe_sepr --target-version local --latest-version latest
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:
path: ./test/integration/consul-container/upgrade/workdir/logs
destination: container-logs
- store_test_results:
path: *TEST_RESULTS_DIR
- store_artifacts:
path: *TEST_RESULTS_DIR
- run: *notify-slack-failure

envoy-integration-test-1_19_3: &ENVOY_TESTS
machine:
image: *UBUNTU_CI_IMAGE
image: ubuntu-2004:202201-02
parallelism: 4
resource_class: medium
environment:
Expand Down Expand Up @@ -972,7 +928,6 @@ jobs:
LOCAL_COMMIT_SHA="<< pipeline.parameters.commit >>"
fi
echo "export LOCAL_COMMIT_SHA=${LOCAL_COMMIT_SHA}" >> $BASH_ENV
git checkout ${LOCAL_COMMIT_SHA}
short_ref=$(git rev-parse --short ${LOCAL_COMMIT_SHA})
echo "export TF_VAR_ami_owners=$LOAD_TEST_AMI_OWNERS" >> $BASH_ENV
Expand All @@ -992,8 +947,7 @@ jobs:
working_directory: .circleci/terraform/load-test
name: terraform init
command: |
short_ref=$(git rev-parse --short HEAD)
echo "Testing commit id: $short_ref"
echo "commit is ${LOCAL_COMMIT_SHA}"
terraform init \
-backend-config="bucket=${BUCKET}" \
-backend-config="key=${LOCAL_COMMIT_SHA}" \
Expand All @@ -1009,7 +963,7 @@ jobs:
when: always
name: terraform destroy
command: |
for i in $(seq 1 5); do terraform destroy -auto-approve && s=0 && break || s=$? && sleep 20; done; (exit $s)
terraform destroy -auto-approve
- run: *notify-slack-failure

# The noop job is a used as a very fast job in the verify-ci workflow because every workflow
Expand All @@ -1025,7 +979,7 @@ workflows:
# 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:
jobs: [noop]
jobs: [ noop ]

go-tests:
unless: << pipeline.parameters.trigger-load-test >>
Expand All @@ -1038,7 +992,6 @@ workflows:
- /^docs\/.*/
- /^ui\/.*/
- check-generated-protobuf: *filter-ignore-non-go-branches
- lint-enums: *filter-ignore-non-go-branches
- lint-consul-retry: *filter-ignore-non-go-branches
- lint: *filter-ignore-non-go-branches
- lint:
Expand All @@ -1049,17 +1002,17 @@ workflows:
- go-test-arm64: *filter-ignore-non-go-branches
- dev-build: *filter-ignore-non-go-branches
- go-test:
requires: [dev-build]
requires: [ dev-build ]
- go-test-lib:
name: "go-test-api go1.17"
path: api
go-version: "1.17"
requires: [dev-build]
requires: [ dev-build ]
- go-test-lib:
name: "go-test-api go1.18"
path: api
go-version: "1.18"
requires: [dev-build]
requires: [ dev-build ]
- go-test-lib:
name: "go-test-sdk go1.17"
path: sdk
Expand Down Expand Up @@ -1091,12 +1044,20 @@ workflows:
- ember-build-prod:
requires:
- frontend-cache
- publish-static-assets:
- build-static-assets:
requires:
- ember-build-prod
- publish-static-assets:
filters:
branches:
only:
- main
- /release\/\d+\.\d+\.x$/
requires:
- build-static-assets
- dev-build:
requires:
- ember-build-prod
- build-static-assets
- dev-upload-s3:
requires:
- dev-build
Expand Down Expand Up @@ -1138,9 +1099,6 @@ workflows:
- envoy-integration-test-1_22_0:
requires:
- dev-build
- compatibility-integration-test:
requires:
- dev-build
- noop
frontend:
unless: << pipeline.parameters.trigger-load-test >>
Expand Down
Loading

0 comments on commit 10416dd

Please sign in to comment.