Skip to content

Commit

Permalink
add circle
Browse files Browse the repository at this point in the history
  • Loading branch information
rboyer committed Nov 2, 2020
1 parent ac7bba0 commit dc958af
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
version: 2.1

references:
images:
go: &GOLANG_IMAGE circleci/golang:1.15.3

# reusable 'executor' object for jobs
executors:
go:
docker:
- image: *GOLANG_IMAGE
environment:
- TEST_RESULTS: /tmp/test-results # path to where test results are saved

jobs:
go-fmt-and-vet:
executor: go
steps:
- checkout

# Restore go module cache if there is one
- restore_cache:
keys:
- go-mod-v1-{{ checksum "go.mod" }}

- run: go mod download

# Save go module cache if the go.mod file has changed
- save_cache:
key: go-mod-v1-{{ checksum "go.mod" }}
paths:
- "/go/pkg/mod"

# check go fmt output because it does not report non-zero when there are fmt changes
- run:
name: check go fmt
command: |
files=$(go fmt ./...)
if [ -n "$files" ]; then
echo "The following file(s) do not conform to go fmt:"
echo "$files"
exit 1
fi
- run: go vet ./...

go-test:
executor: go
steps:
- checkout
- run: mkdir -p $TEST_RESULTS

- restore_cache: # restore cache from dev-build job
keys:
- go-mod-v1-{{ checksum "go.mod" }}

# run go tests with gotestsum
- run: |
PACKAGE_NAMES=$(go list ./...)
gotestsum --format=short-verbose --junitfile $TEST_RESULTS/gotestsum-report.xml -- $PACKAGE_NAMES
- store_test_results:
path: /tmp/test-results
- store_artifacts:
path: /tmp/test-results

workflows:
version: 2
test-and-build:
jobs:
- go-fmt-and-vet
- go-test

0 comments on commit dc958af

Please sign in to comment.