From 08d1eb585d84552e63c42da99e8e53f965626cfb Mon Sep 17 00:00:00 2001 From: odidev Date: Thu, 9 Dec 2021 19:25:10 +0530 Subject: [PATCH] Add test jobs for arm64 in CircleCI --- .circleci/config.yml | 96 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 95 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 02fb797700..2ddd1fcd08 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -39,8 +39,14 @@ steps: environment: GOTESTSUM_RELEASE: 1.6.4 command: | + ARCH=`uname -m` + if [[ "$ARCH" == "aarch64" ]]; then + ARCH="arm64" + else + ARCH="amd64" + fi url=https://github.com/gotestyourself/gotestsum/releases/download - curl -sSL "${url}/v${GOTESTSUM_RELEASE}/gotestsum_${GOTESTSUM_RELEASE}_linux_amd64.tar.gz" | \ + curl -sSL "${url}/v${GOTESTSUM_RELEASE}/gotestsum_${GOTESTSUM_RELEASE}_linux_${ARCH}.tar.gz" | \ sudo tar -xz --overwrite -C /usr/local/bin gotestsum get-aws-cli: &get-aws-cli @@ -194,6 +200,66 @@ jobs: exit 1 fi + go-test-arm64: + machine: + image: ubuntu-2004:202101-01 + resource_class: arm.medium + 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 + # 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 + - attach_workspace: + at: ./bin + - run: sudo apt-get update && sudo apt-get install -y rsyslog + - run: *install-gotestsum + - run: sudo service rsyslog start + - run: + command: | + sudo rm -rf /usr/local/go + wget https://golang.org/dl/go1.17.3.linux-arm64.tar.gz + sudo tar -C /usr/local -xzvf go1.17.3.linux-arm64.tar.gz + sudo cp ./bin/consul /usr/local/bin/consul + export PATH=$PATH:/usr/local/go/bin + - run: go mod download + - run: + name: go test + command: | + mkdir -p $TEST_RESULTS_DIR /tmp/jsonfile + 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 + umask 0022 + 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 \ + -cover -coverprofile=coverage.txt + - store_test_results: + path: *TEST_RESULTS_DIR + - store_artifacts: + path: *TEST_RESULTS_DIR + - store_artifacts: + path: /tmp/jsonfile + - run: &rerun-fails-report + name: "Re-run fails report" + command: | + .circleci/scripts/rerun-fails-report.sh /tmp/gotestsum-rerun-fails + - run: *notify-slack-failure + go-test: docker: - image: *GOLANG_IMAGE @@ -428,6 +494,31 @@ jobs: path: ./pkg/bin - run: *notify-slack-failure + dev-build-arm64: + machine: + image: ubuntu-2004:202101-01 + resource_class: arm.medium + environment: + <<: *ENVIRONMENT + steps: + - checkout + - attach_workspace: # this normally runs as the first job and has nothing to attach; only used in main branch after rebuilding UI + at: . + - run: + command: | + sudo rm -rf /usr/local/go + wget https://golang.org/dl/go1.17.3.linux-arm64.tar.gz + sudo tar -C /usr/local -xzvf go1.17.3.linux-arm64.tar.gz + export PATH=$PATH:/usr/local/go/bin + make dev + + # save dev build to pass to downstream jobs + - persist_to_workspace: + root: ./bin + paths: + - consul + - run: *notify-slack-failure + # create a development build dev-build: docker: @@ -1016,6 +1107,9 @@ workflows: go-arch: "386" <<: *filter-ignore-non-go-branches - test-connect-ca-providers: *filter-ignore-non-go-branches + - dev-build-arm64: *filter-ignore-non-go-branches + - go-test-arm64: + requires: [dev-build-arm64] - dev-build: *filter-ignore-non-go-branches - go-test: requires: [dev-build]