From 45b8dea320b4a47d5f564ff78af37196584e9b99 Mon Sep 17 00:00:00 2001 From: Simon Pasquier Date: Mon, 11 Jun 2018 17:51:28 +0200 Subject: [PATCH] Makefile: update .PHONY target (#4234) Makefile: update .PHONY target * Move .PHONY declarations near their targets Signed-off-by: Simon Pasquier --- Makefile | 3 ++- Makefile.common | 21 +++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index c243f60ac..5a03f63c8 100644 --- a/Makefile +++ b/Makefile @@ -27,8 +27,9 @@ ifdef DEBUG bindata_flags = -debug endif +.PHONY: assets assets: @echo ">> writing assets" @$(GO) get -u github.com/jteeuwen/go-bindata/... @go-bindata $(bindata_flags) -pkg ui -o web/ui/bindata.go -ignore '(.*\.map|bootstrap\.js|bootstrap-theme\.css|bootstrap\.css)' web/ui/templates/... web/ui/static/... - @$(GO) fmt ./web/ui \ No newline at end of file + @$(GO) fmt ./web/ui diff --git a/Makefile.common b/Makefile.common index 353494c06..eaee9f0b9 100644 --- a/Makefile.common +++ b/Makefile.common @@ -37,12 +37,15 @@ PREFIX ?= $(shell pwd) BIN_DIR ?= $(shell pwd) DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD)) +.PHONY: all all: style staticcheck unused build test +.PHONY: style style: @echo ">> checking code style" ! $(GOFMT) -d $$(find . -path ./vendor -prune -o -name '*.go' -print) | grep '^' +.PHONY: check_license check_license: @echo ">> checking license header" @licRes=$$(for file in $$(find . -type f -iname '*.go' ! -path './vendor/*') ; do \ @@ -53,48 +56,58 @@ check_license: exit 1; \ fi +.PHONY: test-short test-short: @echo ">> running short tests" $(GO) test -short $(pkgs) +.PHONY: test test: @echo ">> running all tests" $(GO) test -race $(pkgs) +.PHONY: format format: @echo ">> formatting code" $(GO) fmt $(pkgs) +.PHONY: vet vet: @echo ">> vetting code" $(GO) vet $(pkgs) +.PHONY: staticcheck staticcheck: $(STATICCHECK) @echo ">> running staticcheck" $(STATICCHECK) -ignore "$(STATICCHECK_IGNORE)" $(pkgs) +.PHONY: unused unused: $(GOVENDOR) @echo ">> running check for unused packages" @$(GOVENDOR) list +unused | grep . && exit 1 || echo 'No unused packages' +.PHONY: build build: promu @echo ">> building binaries" $(PROMU) build --prefix $(PREFIX) +.PHONY: tarball tarball: promu @echo ">> building release tarball" $(PROMU) tarball --prefix $(PREFIX) $(BIN_DIR) +.PHONY: docker docker: docker build -t "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" . +.PHONY: promu 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 -$(FIRST_GOPATH)/bin/govendor: +.PHONY: $(GOVENDOR) +$(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 \ No newline at end of file