Fix CircleCI config

This commit is contained in:
Alisdair McDiarmid 2020-04-15 15:16:44 -04:00
parent 10b94c0a94
commit 7098edec61

View File

@ -1,25 +1,63 @@
version: 2.1 version: 2.1
jobs:
build: executors:
branches: go:
only:
- master
- hcl2
docker: docker:
- image: circleci/golang:1.12 - image: circleci/golang:1.14
environment: environment:
GOMAXPROCS: 4
GO111MODULE: "on" GO111MODULE: "on"
GOPROXY: "https://proxy.golang.org" GOPROXY: https://proxy.golang.org/
TEST_RESULTS_DIR: &TEST_RESULTS_DIR /tmp/test-results
jobs:
go-checks:
executor:
name: go
steps: steps:
- checkout - checkout
- restore_cache: - run: go mod verify
keys: - run: make fmt
- v1-mod-cache
- run: - run:
name: "Tests" name: verify no code was generated
command: | command: |
go test ./... if [[ -z $(git status --porcelain) ]]; then
- save_cache: echo "Git directory is clean."
key: v1-mod-cache else
echo "Git is dirty. Run `make fmt` and `make generate` locally and commit any formatting fixes or generated code."
git status --porcelain
exit 1
fi
go-test:
executor:
name: go
steps:
- checkout
- attach_workspace:
at: .
- run: mkdir -p $TEST_RESULTS_DIR
- run:
name: Run Go Tests
command: |
PACKAGE_NAMES=$(go list ./... | circleci tests split --split-by=timings --timings-type=classname)
echo "Running $(echo $PACKAGE_NAMES | wc -w) packages"
echo $PACKAGE_NAMES
gotestsum --format=short-verbose --junitfile $TEST_RESULTS_DIR/gotestsum-report.xml -- -p 2 -cover -coverprofile=cov_$CIRCLE_NODE_INDEX.part $PACKAGE_NAMES
# save coverage report parts
- persist_to_workspace:
root: .
paths: paths:
- "/go/pkg/mod" - cov_*.part
- store_test_results:
path: *TEST_RESULTS_DIR
- store_artifacts:
path: *TEST_RESULTS_DIR
workflows:
version: 2
test:
jobs:
- go-test