Skip to content

Commit

Permalink
updating config to consolidate jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
cotarg committed Oct 8, 2019
1 parent bf36132 commit a85ee06
Showing 1 changed file with 9 additions and 21 deletions.
30 changes: 9 additions & 21 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,25 @@ version: 2.1
references:
images:
go: &GOLANG_IMAGE circleci/golang:latest
environments:
tmp: &TEST_RESULTS_PATH /tmp/test-results # path to where test results are saved

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

jobs:
go-fmt-and-vet:
go-test:
executor: go
steps:
- checkout
- run: mkdir -p $TEST_RESULTS

# Restore go module cache if there is one
- restore_cache:
- restore_cache: # restore cache from dev-build job
keys:
- go-version-modcache-v1-{{ checksum "go.mod" }}

Expand All @@ -41,32 +43,18 @@ jobs:
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-version-modcache-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
path: *TEST_RESULTS_PATH
- store_artifacts:
path: /tmp/test-results
path: *TEST_RESULTS_PATH

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

0 comments on commit a85ee06

Please sign in to comment.