blob: 360b220efc3b858616aa80ec20649a501ec26521 [file] [log] [blame]
William Kurkianea869482019-04-09 15:16:11 -04001export GO111MODULE=on
2
Abhilash S.L3b494632019-07-16 15:51:09 +05303default: fmt vet errcheck test lint
William Kurkianea869482019-04-09 15:16:11 -04004
5# Taken from https://github.com/codecov/example-go#caveat-multiple-files
Abhilash S.L3b494632019-07-16 15:51:09 +05306.PHONY: test
William Kurkianea869482019-04-09 15:16:11 -04007test:
8 echo "" > coverage.txt
Abhilash S.L3b494632019-07-16 15:51:09 +05309 for d in `go list ./...`; do \
William Kurkianea869482019-04-09 15:16:11 -040010 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
Abhilash S.L3b494632019-07-16 15:51:09 +053017GOLINT := $(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
William Kurkianea869482019-04-09 15:16:11 -040027vet:
28 go vet ./...
29
Abhilash S.L3b494632019-07-16 15:51:09 +053030ERRCHECK := $(shell command -v errcheck)
William Kurkianea869482019-04-09 15:16:11 -040031# See https://github.com/kisielk/errcheck/pull/141 for details on ignorepkg
Abhilash S.L3b494632019-07-16 15:51:09 +053032.PHONY: errcheck
William Kurkianea869482019-04-09 15:16:11 -040033errcheck:
Abhilash S.L3b494632019-07-16 15:51:09 +053034ifndef ERRCHECK
35 go get github.com/kisielk/errcheck
36endif
William Kurkianea869482019-04-09 15:16:11 -040037 errcheck -ignorepkg fmt github.com/Shopify/sarama/...
38
Abhilash S.L3b494632019-07-16 15:51:09 +053039.PHONY: fmt
William Kurkianea869482019-04-09 15:16:11 -040040fmt:
41 @if [ -n "$$(go fmt ./...)" ]; then echo 'Please run go fmt on your code.' && exit 1; fi
42
Abhilash S.L3b494632019-07-16 15:51:09 +053043.PHONY : install_dependencies
44install_dependencies: get
William Kurkianea869482019-04-09 15:16:11 -040045
Abhilash S.L3b494632019-07-16 15:51:09 +053046.PHONY: get
William Kurkianea869482019-04-09 15:16:11 -040047get:
Abhilash S.L3b494632019-07-16 15:51:09 +053048 go get -t -v ./...
49
50.PHONY: clean
51clean:
52 go clean ./...