diff options
author | Dan Duvall <dduvall@wikimedia.org> | 2018-07-31 16:43:05 -0700 |
---|---|---|
committer | Dan Duvall <dduvall@wikimedia.org> | 2018-08-01 10:05:08 -0700 |
commit | 44dc7d91313ee36aed1b85ae7f63c9e75ab78ff3 (patch) | |
tree | fa2a0c8fd0850a5d9ad91c6ae860d8cfd43ee4a1 /Makefile | |
parent | 80936122c749199bb9a376a23ae85e45c4abebe0 (diff) | |
download | blubber-44dc7d91313ee36aed1b85ae7f63c9e75ab78ff3.tar.gz |
Provide Makefile rules for running linters and tests
With the move to Gerrit and away from Phabricator/Arcanist, we lost an
easy way to run linters. New rules have been added to the `Makefile`,
`lint`, `unit`, and `test` that run linters, unit tests, and both
linters and unit tests, respectively.
Bug: T200452
Change-Id: I0742daaa14389841d88f13eba47dee07ac127cf2
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -4,6 +4,9 @@ TARGETS ?= darwin/amd64 linux/amd64 linux/386 linux/arm linux/arm64 linux/ppc64l PACKAGE := gerrit.wikimedia.org/r/blubber REAL_CURDIR := $(shell readlink "$(CURDIR)" || echo "$(CURDIR)") +GO_LIST_GOFILES := '{{range .GoFiles}}{{printf "%s/%s\n" $$.Dir .}}{{end}}{{range .XTestGoFiles}}{{printf "%s/%s\n" $$.Dir .}}{{end}}' +GO_PACKAGES := $(shell go list ./...) + GO_LDFLAGS := \ -X $(PACKAGE)/meta.Version=$(shell cat VERSION) \ -X $(PACKAGE)/meta.GitCommit=$(shell git rev-parse --short HEAD) @@ -21,4 +24,18 @@ release: shasum -a 256 "$${f}" | awk '{print $$1}' > "$${f}.sha256"; \ done +lint: + @echo > .lint-gofmt.diff + @go list -f $(GO_LIST_GOFILES) ./... | while read f; do \ + gofmt -e -d "$${f}" >> .lint-gofmt.diff; \ + done + @test ! -s .lint-gofmt.diff || (echo "gofmt found errors:"; cat .lint-gofmt.diff; exit 1) + golint -set_exit_status $(GO_PACKAGES) + go tool vet -composites=false $(GO_PACKAGES) + +unit: + go test -ldflags "$(GO_LDFLAGS)" $(GO_PACKAGES) + +test: unit lint + .PHONY: install release |