William Kurkian | ea86948 | 2019-04-09 15:16:11 -0400 | [diff] [blame] | 1 | export GO111MODULE=on |
| 2 | |
Abhilash S.L | 3b49463 | 2019-07-16 15:51:09 +0530 | [diff] [blame^] | 3 | default: fmt vet errcheck test lint |
William Kurkian | ea86948 | 2019-04-09 15:16:11 -0400 | [diff] [blame] | 4 | |
| 5 | # Taken from https://github.com/codecov/example-go#caveat-multiple-files |
Abhilash S.L | 3b49463 | 2019-07-16 15:51:09 +0530 | [diff] [blame^] | 6 | .PHONY: test |
William Kurkian | ea86948 | 2019-04-09 15:16:11 -0400 | [diff] [blame] | 7 | test: |
| 8 | echo "" > coverage.txt |
Abhilash S.L | 3b49463 | 2019-07-16 15:51:09 +0530 | [diff] [blame^] | 9 | for d in `go list ./...`; do \ |
William Kurkian | ea86948 | 2019-04-09 15:16:11 -0400 | [diff] [blame] | 10 | 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.L | 3b49463 | 2019-07-16 15:51:09 +0530 | [diff] [blame^] | 17 | GOLINT := $(shell command -v golint) |
| 18 | |
| 19 | .PHONY: lint |
| 20 | lint: |
| 21 | ifndef GOLINT |
| 22 | go get golang.org/x/lint/golint |
| 23 | endif |
| 24 | go list ./... | xargs golint |
| 25 | |
| 26 | .PHONY: vet |
William Kurkian | ea86948 | 2019-04-09 15:16:11 -0400 | [diff] [blame] | 27 | vet: |
| 28 | go vet ./... |
| 29 | |
Abhilash S.L | 3b49463 | 2019-07-16 15:51:09 +0530 | [diff] [blame^] | 30 | ERRCHECK := $(shell command -v errcheck) |
William Kurkian | ea86948 | 2019-04-09 15:16:11 -0400 | [diff] [blame] | 31 | # See https://github.com/kisielk/errcheck/pull/141 for details on ignorepkg |
Abhilash S.L | 3b49463 | 2019-07-16 15:51:09 +0530 | [diff] [blame^] | 32 | .PHONY: errcheck |
William Kurkian | ea86948 | 2019-04-09 15:16:11 -0400 | [diff] [blame] | 33 | errcheck: |
Abhilash S.L | 3b49463 | 2019-07-16 15:51:09 +0530 | [diff] [blame^] | 34 | ifndef ERRCHECK |
| 35 | go get github.com/kisielk/errcheck |
| 36 | endif |
William Kurkian | ea86948 | 2019-04-09 15:16:11 -0400 | [diff] [blame] | 37 | errcheck -ignorepkg fmt github.com/Shopify/sarama/... |
| 38 | |
Abhilash S.L | 3b49463 | 2019-07-16 15:51:09 +0530 | [diff] [blame^] | 39 | .PHONY: fmt |
William Kurkian | ea86948 | 2019-04-09 15:16:11 -0400 | [diff] [blame] | 40 | fmt: |
| 41 | @if [ -n "$$(go fmt ./...)" ]; then echo 'Please run go fmt on your code.' && exit 1; fi |
| 42 | |
Abhilash S.L | 3b49463 | 2019-07-16 15:51:09 +0530 | [diff] [blame^] | 43 | .PHONY : install_dependencies |
| 44 | install_dependencies: get |
William Kurkian | ea86948 | 2019-04-09 15:16:11 -0400 | [diff] [blame] | 45 | |
Abhilash S.L | 3b49463 | 2019-07-16 15:51:09 +0530 | [diff] [blame^] | 46 | .PHONY: get |
William Kurkian | ea86948 | 2019-04-09 15:16:11 -0400 | [diff] [blame] | 47 | get: |
Abhilash S.L | 3b49463 | 2019-07-16 15:51:09 +0530 | [diff] [blame^] | 48 | go get -t -v ./... |
| 49 | |
| 50 | .PHONY: clean |
| 51 | clean: |
| 52 | go clean ./... |