description: run go tests parameters: extra_flags: type: string default: "" log_dir: type: string default: "/tmp/testlogs" steps: - run: name: Run Go tests no_output_timeout: 60m command: | set -x case "<< parameters.extra_flags >>" in *-race*) VAULT_CI_GO_TEST_RACE=1;; esac # 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 /integ \ | 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= \ VAULT_TEST_LOG_DIR=<< parameters.log_dir >> \ gotestsum --format=short-verbose --junitfile test-results/go-test/results.xml -- \ -tags "${GO_TAGS}" \ -timeout=60m \ -parallel=20 \ << parameters.extra_flags >> \ ${package_names}