Sync Makefile.common from prometheus

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
Simon Pasquier 2018-06-18 14:05:04 +02:00
parent 4a9cde8cef
commit 79fa36fe39

View file

@ -37,12 +37,15 @@ PREFIX ?= $(shell pwd)
BIN_DIR ?= $(shell pwd) BIN_DIR ?= $(shell pwd)
DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD)) DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD))
.PHONY: all
all: style staticcheck unused build test all: style staticcheck unused build test
.PHONY: style
style: style:
@echo ">> checking code style" @echo ">> checking code style"
! $(GOFMT) -d $$(find . -path ./vendor -prune -o -name '*.go' -print) | grep '^' ! $(GOFMT) -d $$(find . -path ./vendor -prune -o -name '*.go' -print) | grep '^'
.PHONY: check_license
check_license: check_license:
@echo ">> checking license header" @echo ">> checking license header"
@licRes=$$(for file in $$(find . -type f -iname '*.go' ! -path './vendor/*') ; do \ @licRes=$$(for file in $$(find . -type f -iname '*.go' ! -path './vendor/*') ; do \
@ -53,48 +56,58 @@ check_license:
exit 1; \ exit 1; \
fi fi
.PHONY: test-short
test-short: test-short:
@echo ">> running short tests" @echo ">> running short tests"
$(GO) test -short $(pkgs) $(GO) test -short $(pkgs)
.PHONY: test
test: test:
@echo ">> running all tests" @echo ">> running all tests"
$(GO) test -race $(pkgs) $(GO) test -race $(pkgs)
.PHONY: format
format: format:
@echo ">> formatting code" @echo ">> formatting code"
$(GO) fmt $(pkgs) $(GO) fmt $(pkgs)
.PHONY: vet
vet: vet:
@echo ">> vetting code" @echo ">> vetting code"
$(GO) vet $(pkgs) $(GO) vet $(pkgs)
.PHONY: staticcheck
staticcheck: $(STATICCHECK) staticcheck: $(STATICCHECK)
@echo ">> running staticcheck" @echo ">> running staticcheck"
$(STATICCHECK) -ignore "$(STATICCHECK_IGNORE)" $(pkgs) $(STATICCHECK) -ignore "$(STATICCHECK_IGNORE)" $(pkgs)
.PHONY: unused
unused: $(GOVENDOR) unused: $(GOVENDOR)
@echo ">> running check for unused packages" @echo ">> running check for unused packages"
@$(GOVENDOR) list +unused | grep . && exit 1 || echo 'No unused packages' @$(GOVENDOR) list +unused | grep . && exit 1 || echo 'No unused packages'
.PHONY: build
build: promu build: promu
@echo ">> building binaries" @echo ">> building binaries"
$(PROMU) build --prefix $(PREFIX) $(PROMU) build --prefix $(PREFIX)
.PHONY: tarball
tarball: promu tarball: promu
@echo ">> building release tarball" @echo ">> building release tarball"
$(PROMU) tarball --prefix $(PREFIX) $(BIN_DIR) $(PROMU) tarball --prefix $(PREFIX) $(BIN_DIR)
.PHONY: docker
docker: docker:
docker build -t "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" . docker build -t "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" .
.PHONY: promu
promu: promu:
GOOS= GOARCH= $(GO) get -u github.com/prometheus/promu GOOS= GOARCH= $(GO) get -u github.com/prometheus/promu
$(FIRST_GOPATH)/bin/staticcheck: .PHONY: $(STATICCHECK)
$(STATICCHECK):
GOOS= GOARCH= $(GO) get -u honnef.co/go/tools/cmd/staticcheck GOOS= GOARCH= $(GO) get -u honnef.co/go/tools/cmd/staticcheck
$(FIRST_GOPATH)/bin/govendor: .PHONY: $(GOVENDOR)
$(GOVENDOR):
GOOS= GOARCH= $(GO) get -u github.com/kardianos/govendor GOOS= GOARCH= $(GO) get -u github.com/kardianos/govendor
.PHONY: all style check_license format build test vet assets tarball docker promu staticcheck $(FIRST_GOPATH)/bin/staticcheck govendor $(FIRST_GOPATH)/bin/govendor