blob: 360b220efc3b858616aa80ec20649a501ec26521 [file] [log] [blame]
Scott Bakere7144bc2019-10-01 14:16:47 -07001export GO111MODULE=on
2
Scott Bakerf579f132019-10-24 14:31:41 -07003default: fmt vet errcheck test lint
Scott Bakere7144bc2019-10-01 14:16:47 -07004
5# Taken from https://github.com/codecov/example-go#caveat-multiple-files
Scott Bakerf579f132019-10-24 14:31:41 -07006.PHONY: test
Scott Bakere7144bc2019-10-01 14:16:47 -07007test:
8 echo "" > coverage.txt
Scott Bakerf579f132019-10-24 14:31:41 -07009 for d in `go list ./...`; do \
Scott Bakere7144bc2019-10-01 14:16:47 -070010 go test -p 1 -v -timeout 240s -race -coverprofile=profile.out -covermode=atomic $$d || exit 1; \
11 if [ -f profile.out ]; then \
12 cat profile.out >> coverage.txt; \
13 rm profile.out; \
14 fi \
15 done
16
Scott Bakerf579f132019-10-24 14:31:41 -070017GOLINT := $(shell command -v golint)
18
19.PHONY: lint
20lint:
21ifndef GOLINT
22 go get golang.org/x/lint/golint
23endif
24 go list ./... | xargs golint
25
26.PHONY: vet
Scott Bakere7144bc2019-10-01 14:16:47 -070027vet:
28 go vet ./...
29
Scott Bakerf579f132019-10-24 14:31:41 -070030ERRCHECK := $(shell command -v errcheck)
Scott Bakere7144bc2019-10-01 14:16:47 -070031# See https://github.com/kisielk/errcheck/pull/141 for details on ignorepkg
Scott Bakerf579f132019-10-24 14:31:41 -070032.PHONY: errcheck
Scott Bakere7144bc2019-10-01 14:16:47 -070033errcheck:
Scott Bakerf579f132019-10-24 14:31:41 -070034ifndef ERRCHECK
35 go get github.com/kisielk/errcheck
36endif
Scott Bakere7144bc2019-10-01 14:16:47 -070037 errcheck -ignorepkg fmt github.com/Shopify/sarama/...
38
Scott Bakerf579f132019-10-24 14:31:41 -070039.PHONY: fmt
Scott Bakere7144bc2019-10-01 14:16:47 -070040fmt:
41 @if [ -n "$$(go fmt ./...)" ]; then echo 'Please run go fmt on your code.' && exit 1; fi
42
Scott Bakerf579f132019-10-24 14:31:41 -070043.PHONY : install_dependencies
44install_dependencies: get
Scott Bakere7144bc2019-10-01 14:16:47 -070045
Scott Bakerf579f132019-10-24 14:31:41 -070046.PHONY: get
Scott Bakere7144bc2019-10-01 14:16:47 -070047get:
Scott Bakerf579f132019-10-24 14:31:41 -070048 go get -t -v ./...
49
50.PHONY: clean
51clean:
52 go clean ./...