summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile17
1 files changed, 17 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index b4cab3f..0e94470 100644
--- a/Makefile
+++ b/Makefile
@@ -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