Skip to content

Commit cebfae8

Browse files
committed
add circleci config
1 parent cb8f972 commit cebfae8

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

.circleci/config.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
version: 2.1
2+
3+
references:
4+
images:
5+
go: &GOLANG_IMAGE circleci/golang:latest
6+
7+
# reusable 'executor' object for jobs
8+
executors:
9+
go:
10+
docker:
11+
- image: *GOLANG_IMAGE
12+
environment:
13+
- TEST_RESULTS: /tmp/test-results # path to where test results are saved
14+
15+
jobs:
16+
go-fmt-and-vet:
17+
executor: go
18+
steps:
19+
- checkout
20+
21+
# Restore go module cache if there is one
22+
- restore_cache:
23+
keys:
24+
- go-getter-modcache-v1-{{ checksum "go.mod" }}
25+
26+
- run: go mod download
27+
28+
# Save go module cache if the go.mod file has changed
29+
- save_cache:
30+
key: go-getter-modcache-v1-{{ checksum "go.mod" }}
31+
paths:
32+
- "/go/pkg/mod"
33+
34+
# check go fmt output because it does not report non-zero when there are fmt changes
35+
- run:
36+
name: check go fmt
37+
command: |
38+
files=$(go fmt ./...)
39+
if [ -n "$files" ]; then
40+
echo "The following file(s) do not conform to go fmt:"
41+
echo "$files"
42+
exit 1
43+
fi
44+
- run: go vet ./...
45+
46+
go-build:
47+
executor: go
48+
steps:
49+
- checkout
50+
- restore_cache: # restore cache from dev-build job
51+
keys:
52+
- go-getter-modcache-v1-{{ checksum "go.mod" }}
53+
- run: go build ./cmd/go-getter
54+
55+
workflows:
56+
version: 2
57+
test-and-build:
58+
jobs:
59+
- go-fmt-and-vet
60+
- go-build:
61+
requires:
62+
- go-fmt-and-vet

0 commit comments

Comments
 (0)