blob: 316004400b898728e3618144bc2e9934e2168604 [file] [log] [blame]
David K. Bainbridgebd6b2882021-08-26 13:31:02 +00001# Directory to put `go install`ed binaries in.
2export GOBIN ?= $(shell pwd)/bin
divyadesai19009132020-03-04 12:58:08 +00003
4GO_FILES := $(shell \
5 find . '(' -path '*/.*' -o -path './vendor' ')' -prune \
6 -o -name '*.go' -print | cut -b3-)
7
divyadesai19009132020-03-04 12:58:08 +00008.PHONY: build
9build:
David K. Bainbridgebd6b2882021-08-26 13:31:02 +000010 go build ./...
divyadesai19009132020-03-04 12:58:08 +000011
12.PHONY: test
13test:
David K. Bainbridgebd6b2882021-08-26 13:31:02 +000014 go test -race ./...
divyadesai19009132020-03-04 12:58:08 +000015
16.PHONY: gofmt
17gofmt:
18 $(eval FMT_LOG := $(shell mktemp -t gofmt.XXXXX))
19 @gofmt -e -s -l $(GO_FILES) > $(FMT_LOG) || true
20 @[ ! -s "$(FMT_LOG)" ] || (echo "gofmt failed:" | cat - $(FMT_LOG) && false)
21
divyadesai19009132020-03-04 12:58:08 +000022.PHONY: golint
23golint:
David K. Bainbridgebd6b2882021-08-26 13:31:02 +000024 @cd tools && go install golang.org/x/lint/golint
25 @$(GOBIN)/golint ./...
divyadesai19009132020-03-04 12:58:08 +000026
27.PHONY: staticcheck
28staticcheck:
David K. Bainbridgebd6b2882021-08-26 13:31:02 +000029 @cd tools && go install honnef.co/go/tools/cmd/staticcheck
30 @$(GOBIN)/staticcheck ./...
divyadesai19009132020-03-04 12:58:08 +000031
32.PHONY: lint
David K. Bainbridgebd6b2882021-08-26 13:31:02 +000033lint: gofmt golint staticcheck
divyadesai19009132020-03-04 12:58:08 +000034
35.PHONY: cover
36cover:
David K. Bainbridgebd6b2882021-08-26 13:31:02 +000037 go test -coverprofile=cover.out -coverpkg=./... -v ./...
divyadesai19009132020-03-04 12:58:08 +000038 go tool cover -html=cover.out -o cover.html
39
40update-license:
David K. Bainbridgebd6b2882021-08-26 13:31:02 +000041 @cd tools && go install go.uber.org/tools/update-license
42 @$(GOBIN)/update-license $(GO_FILES)