Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport of ci: remove go-tests workflow from CircleCI into release/1.15.x #16948

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
331 changes: 1 addition & 330 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,76 +169,6 @@ commands:
- run: *notify-slack-failure

jobs:
# lint consul tests
lint-consul-retry:
docker:
- image: *GOLANG_IMAGE
steps:
- checkout
- 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-container-test-deps:
docker:
- image: *GOLANG_IMAGE
steps:
- checkout
- run: make lint-container-test-deps
- run: *notify-slack-failure

lint:
description: "Run golangci-lint"
parameters:
go-arch:
type: string
default: ""
docker:
- image: *GOLANG_IMAGE
resource_class: xlarge
environment:
GOTAGS: "" # No tags for OSS but there are for enterprise
GOARCH: "<<parameters.go-arch>>"
steps:
- checkout
- run: go env
- run:
name: Install golangci-lint
command: make lint-tools
- run: go mod download
- run:
name: lint
command: &lintcmd |
golangci-lint run --build-tags="$GOTAGS" -v
- run:
name: lint api
working_directory: api
command: *lintcmd
- run:
name: lint sdk
working_directory: sdk
command: *lintcmd
- run:
name: lint envoyextensions
working_directory: envoyextensions
command: *lintcmd
- run:
name: lint troubleshoot
working_directory: troubleshoot
command: *lintcmd
- run:
name: lint container tests
working_directory: test/integration/consul-container
command: *lintcmd
- run: *notify-slack-failure

check-go-mod:
docker:
- image: *GOLANG_IMAGE
Expand All @@ -255,213 +185,6 @@ jobs:
fi
- run: *notify-slack-failure

check-generated-protobuf:
docker:
- image: *GOLANG_IMAGE
environment:
<<: *ENVIRONMENT
# tput complains if this isn't set to something.
TERM: ansi
steps:
- checkout
- run:
name: Install protobuf
command: make proto-tools
- run:
name: "Protobuf Format"
command: make proto-format
- run:
command: make --always-make proto
- run: |
if ! git diff --exit-code; then
echo "Generated code was not updated correctly"
exit 1
fi
- run:
name: "Protobuf Lint"
command: make proto-lint

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

go-test-arm64:
machine:
image: *UBUNTU_CI_IMAGE
resource_class: arm.large
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:
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
- run: *install-gotestsum
- run: go mod download
- run:
name: make dev
command: |
if [[ "$CIRCLE_BRANCH" =~ ^main$|^release/ ]]; then
make dev
mkdir -p /home/circleci/bin
cp ./bin/consul /home/circleci/bin/consul
fi
- run-go-test-full:
go_test_flags: 'if ! [[ "$CIRCLE_BRANCH" =~ ^main$|^release/ ]]; then export GO_TEST_FLAGS="-short"; fi'

go-test:
docker:
- image: *GOLANG_IMAGE
resource_class: large
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-go-test-full

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: |
mkdir -p $TEST_RESULTS_DIR /tmp/jsonfile
pkgs="$(go list ./... | \
grep -E -v '^github.com/hashicorp/consul/agent(/consul|/local|/routine-leak-checker)?$' | \
grep -E -v '^github.com/hashicorp/consul/command/')"
gotestsum \
--jsonfile /tmp/jsonfile/go-test-race.log \
--junitfile $TEST_RESULTS_DIR/gotestsum-report.xml -- \
-tags="$GOTAGS" -p 2 \
-race -gcflags=all=-d=checkptr=0 \
$pkgs

- store_test_results:
path: *TEST_RESULTS_DIR
- store_artifacts:
path: *TEST_RESULTS_DIR
- store_artifacts:
path: /tmp/jsonfile
- run: *notify-slack-failure

# go-test-32bit is to catch problems where 64-bit ints must be 64-bit aligned
# to use them with sync/atomic. See https://golang.org/pkg/sync/atomic/#pkg-note-BUG.
# Running tests with GOARCH=386 seems to be the best way to detect this
# problem. Only runs tests that are -short to limit the time we spend checking
# for these bugs.
go-test-32bit:
docker:
- image: *GOLANG_IMAGE
resource_class: large
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
PACKAGE_NAMES=$(go list -tags "$GOTAGS" ./...)
gotestsum \
--jsonfile /tmp/jsonfile/go-test-32bit.log \
--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 \
-short

- store_test_results:
path: *TEST_RESULTS_DIR
- store_artifacts:
path: *TEST_RESULTS_DIR
- run: *notify-slack-failure

go-test-lib:
description: "test a library against a specific Go version"
parameters:
go-version:
type: string
path:
type: string
docker:
- image: "docker.mirror.hashicorp.services/cimg/go:<<parameters.go-version>>"
environment:
<<: *ENVIRONMENT
GOTAGS: "" # No tags for OSS but there are for enterprise
steps:
- checkout
- attach_workspace:
at: /home/circleci/go/bin
- run:
working_directory: <<parameters.path>>
command: go mod download
- run:
working_directory: <<parameters.path>>
name: go test
command: |
mkdir -p $TEST_RESULTS_DIR /tmp/jsonfile
gotestsum \
--format=short-verbose \
--jsonfile /tmp/jsonfile/go-test-<<parameters.path>>.log \
--junitfile $TEST_RESULTS_DIR/gotestsum-report.xml -- \
-tags="$GOTAGS" -cover -coverprofile=coverage.txt \
./...

- store_test_results:
path: *TEST_RESULTS_DIR
- store_artifacts:
path: *TEST_RESULTS_DIR
- store_artifacts:
path: /tmp/jsonfile
- run: *notify-slack-failure

# build is a templated job for build-x
build-distros: &build-distros
docker:
Expand Down Expand Up @@ -997,7 +720,7 @@ jobs:
- run: "echo ok"

workflows:
go-tests:
build-distros:
jobs:
- check-go-mod: &filter-ignore-non-go-branches
filters:
Expand All @@ -1010,58 +733,6 @@ workflows:
- /^backport\/docs\/.*/
- /^backport\/ui\/.*/
- /^backport\/mktg-.*/
- check-generated-protobuf: *filter-ignore-non-go-branches
- check-generated-deep-copy: *filter-ignore-non-go-branches
- lint-enums: *filter-ignore-non-go-branches
- lint-container-test-deps: *filter-ignore-non-go-branches
- lint-consul-retry: *filter-ignore-non-go-branches
- lint: *filter-ignore-non-go-branches
- lint:
name: "lint-32bit"
go-arch: "386"
<<: *filter-ignore-non-go-branches
- go-test-arm64: *filter-ignore-non-go-branches
- dev-build: *filter-ignore-non-go-branches
- go-test:
requires: [dev-build]
- go-test-lib:
name: "go-test-envoyextensions"
path: envoyextensions
go-version: "1.20"
requires: [dev-build]
<<: *filter-ignore-non-go-branches
- go-test-lib:
name: "go-test-troubleshoot"
path: troubleshoot
go-version: "1.20"
requires: [dev-build]
<<: *filter-ignore-non-go-branches
- go-test-lib:
name: "go-test-api go1.19"
path: api
go-version: "1.19"
requires: [dev-build]
- go-test-lib:
name: "go-test-api go1.20"
path: api
go-version: "1.20"
requires: [dev-build]
- go-test-lib:
name: "go-test-sdk go1.19"
path: sdk
go-version: "1.19"
<<: *filter-ignore-non-go-branches
- go-test-lib:
name: "go-test-sdk go1.20"
path: sdk
go-version: "1.20"
<<: *filter-ignore-non-go-branches
- go-test-race: *filter-ignore-non-go-branches
- go-test-32bit: *filter-ignore-non-go-branches
- noop
build-distros:
jobs:
- check-go-mod: *filter-ignore-non-go-branches
- build-386: &require-check-go-mod
requires:
- check-go-mod
Expand Down