ci: small improvements

Run 'go mod download' first so that dependencies are pulled in a
separate step. This makes the test splitting and test output easier
to scroll through.

Remove test splitting from the api/sdk test runs. These jobs do not
use parallelism, so there is no test timing data injected into the
job. They can't be split.

Remove the dependencies from the go-test job, so that we can start
the slowest test job earlier in the workflow.
This commit is contained in:
Daniel Nephin 2020-03-31 11:32:48 -04:00
parent 9d959907a4
commit a79417f973
1 changed files with 55 additions and 35 deletions

View File

@ -89,14 +89,21 @@ jobs:
- checkout - checkout
- attach_workspace: - attach_workspace:
at: /go/bin at: /go/bin
- run: mkdir -p $TEST_RESULTS_DIR
- run: sudo apt-get update && sudo apt-get install -y rsyslog - run: sudo apt-get update && sudo apt-get install -y rsyslog
- run: sudo service rsyslog start - run: sudo service rsyslog start
- run: | - run: go mod download
- run:
name: go test
command: |
mkdir -p $TEST_RESULTS_DIR
PACKAGE_NAMES=$(go list ./... | circleci tests split --split-by=timings --timings-type=classname) PACKAGE_NAMES=$(go list ./... | circleci tests split --split-by=timings --timings-type=classname)
echo "Running $(echo $PACKAGE_NAMES | wc -w) packages" echo "Running $(echo $PACKAGE_NAMES | wc -w) packages"
echo $PACKAGE_NAMES echo $PACKAGE_NAMES
gotestsum --format=short-verbose --junitfile $TEST_RESULTS_DIR/gotestsum-report.xml -- -tags="$GOTAGS" -p 2 -cover -coverprofile=cov_$CIRCLE_NODE_INDEX.part $PACKAGE_NAMES gotestsum --format=short-verbose \
--junitfile $TEST_RESULTS_DIR/gotestsum-report.xml -- \
-tags="$GOTAGS" -p 2 \
-cover -coverprofile=cov_$CIRCLE_NODE_INDEX.part \
$PACKAGE_NAMES
# save coverage report parts # save coverage report parts
- persist_to_workspace: - persist_to_workspace:
@ -120,12 +127,17 @@ jobs:
- checkout - checkout
- attach_workspace: - attach_workspace:
at: /go/bin at: /go/bin
- run: mkdir -p $TEST_RESULTS_DIR - run: go mod download
- run: - run:
working_directory: api working_directory: api
name: go test
command: | command: |
PACKAGE_NAMES=$(go list ./... | circleci tests split --split-by=timings --timings-type=classname) mkdir -p $TEST_RESULTS_DIR
gotestsum --format=short-verbose --junitfile $TEST_RESULTS_DIR/gotestsum-report.xml -- -tags="$GOTAGS" -cover -coverprofile=cov_api.part $PACKAGE_NAMES gotestsum \
--format=short-verbose \
--junitfile $TEST_RESULTS_DIR/gotestsum-report.xml -- \
-tags="$GOTAGS" -cover -coverprofile=cov_api.part \
./...
# save coverage report parts # save coverage report parts
- persist_to_workspace: - persist_to_workspace:
@ -149,12 +161,17 @@ jobs:
- checkout - checkout
- attach_workspace: - attach_workspace:
at: /go/bin at: /go/bin
- run: mkdir -p $TEST_RESULTS_DIR - run: go mod download
- run: - run:
working_directory: sdk working_directory: sdk
name: go test
command: | command: |
PACKAGE_NAMES=$(go list ./... | circleci tests split --split-by=timings --timings-type=classname) mkdir -p $TEST_RESULTS_DIR
gotestsum --format=short-verbose --junitfile $TEST_RESULTS_DIR/gotestsum-report.xml -- -tags=$GOTAGS -cover -coverprofile=cov_sdk.part $PACKAGE_NAMES gotestsum \
--format=short-verbose \
--junitfile $TEST_RESULTS_DIR/gotestsum-report.xml -- \
-tags=$GOTAGS -cover -coverprofile=cov_sdk.part \
./...
# save coverage report parts # save coverage report parts
- persist_to_workspace: - persist_to_workspace:
@ -177,10 +194,10 @@ jobs:
- checkout - checkout
- attach_workspace: - attach_workspace:
at: . at: .
- run: mkdir -p $TEST_RESULTS_DIR
- run: - run:
name: merge coverage reports name: merge coverage reports
command: | command: |
mkdir -p $TEST_RESULTS_DIR
echo "mode: set" > coverage.out echo "mode: set" > coverage.out
grep -h -v "mode: set" cov_*.part >> coverage.out grep -h -v "mode: set" cov_*.part >> coverage.out
go tool cover -html=coverage.out -o $TEST_RESULTS_DIR/coverage.html go tool cover -html=coverage.out -o $TEST_RESULTS_DIR/coverage.html
@ -328,9 +345,6 @@ jobs:
- attach_workspace: - attach_workspace:
at: /go/bin at: /go/bin
# make test result directory
- run: mkdir -p $TEST_RESULTS_DIR
# make dev build of nomad # make dev build of nomad
- run: - run:
command: make pkg/linux_amd64/nomad command: make pkg/linux_amd64/nomad
@ -341,7 +355,13 @@ jobs:
# run integration tests # run integration tests
- run: - run:
command: gotestsum --format=short-verbose --junitfile $TEST_RESULTS_DIR/results.xml -- ./command/agent/consul -run TestConsul name: go test
command: |
mkdir -p $TEST_RESULTS_DIR
gotestsum \
--format=short-verbose \
--junitfile $TEST_RESULTS_DIR/results.xml -- \
./command/agent/consul -run TestConsul
working_directory: *NOMAD_WORKING_DIR working_directory: *NOMAD_WORKING_DIR
# store test results for CircleCI # store test results for CircleCI
@ -612,17 +632,19 @@ jobs:
environment: environment:
<<: *ENVIRONMENT <<: *ENVIRONMENT
steps: steps:
# Install vault - run:
- run: | name: Install vault
command: |
wget -q -O /tmp/vault.zip https://releases.hashicorp.com/vault/${VAULT_BINARY_VERSION}/vault_${VAULT_BINARY_VERSION}_linux_amd64.zip wget -q -O /tmp/vault.zip https://releases.hashicorp.com/vault/${VAULT_BINARY_VERSION}/vault_${VAULT_BINARY_VERSION}_linux_amd64.zip
sudo unzip -d /usr/local/bin /tmp/vault.zip sudo unzip -d /usr/local/bin /tmp/vault.zip
rm -rf /tmp/vault* rm -rf /tmp/vault*
# Create directory to store test results
- run: mkdir -p $TEST_RESULTS_DIR
# Gather deps to run go tests
- checkout - checkout
# Run go tests - run: go mod download
- run: make test-connect-ca-providers - run:
name: go test
command: |
mkdir -p $TEST_RESULTS_DIR
make test-connect-ca-providers
- store_test_results: - store_test_results:
path: *TEST_RESULTS_DIR path: *TEST_RESULTS_DIR
@ -658,19 +680,17 @@ workflows:
- /^ui\/.*/ - /^ui\/.*/
- lint - lint
- dev-build - dev-build
- go-test: &go-test - go-test:
requires: requires: [dev-build]
- dev-build - go-test-api:
- lint requires: [dev-build]
- check-vendor - go-test-sdk
- go-test-api: *go-test
- go-test-sdk: *go-test
- coverage-merge: - coverage-merge:
requires: requires:
- go-test - go-test
- go-test-api - go-test-api
- go-test-sdk - go-test-sdk
- test-connect-ca-providers: *go-test - test-connect-ca-providers
build-distros: build-distros:
jobs: jobs: