open-vault/.circleci/config/commands/go_test.yml

52 lines
1.6 KiB
YAML
Raw Normal View History

description: run go tests
parameters:
extra_flags:
type: string
default: ""
log_dir:
type: string
default: "/tmp/testlogs"
steps:
- run:
name: Run Go tests
2019-11-12 14:03:42 +00:00
no_output_timeout: 60m
command: |
set -x
# 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}" \
2019-10-14 15:51:53 +00:00
-timeout=60m \
-parallel=20 \
<< parameters.extra_flags >> \
${package_names}