aboutsummaryrefslogtreecommitdiff
path: root/Makefile.common
diff options
context:
space:
mode:
authorPrometheusBot <prometheus-team@googlegroups.com>2019-04-25 09:53:48 +0100
committerBen Kochie <superq@gmail.com>2019-04-25 10:53:48 +0200
commitb5cab091dc76aff99e36621aeb6515dcfe225af8 (patch)
treee54fba4bbb0b0dc36e9b08a0bf6f17464c64b63e /Makefile.common
parent78b9eb9c2c4366d6523a2ccbea6e9b0aad1104fe (diff)
downloadprometheus_node_collector-b5cab091dc76aff99e36621aeb6515dcfe225af8.tar.bz2
prometheus_node_collector-b5cab091dc76aff99e36621aeb6515dcfe225af8.tar.xz
prometheus_node_collector-b5cab091dc76aff99e36621aeb6515dcfe225af8.zip
Synchronize Makefile.common from prometheus/prometheus (#1328)
* makefile: update Makefile.common with newer version Signed-off-by: prombot <prometheus-team@googlegroups.com> * Add .golangci.yml Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Diffstat (limited to 'Makefile.common')
-rw-r--r--Makefile.common36
1 files changed, 19 insertions, 17 deletions
diff --git a/Makefile.common b/Makefile.common
index 873964f..73052b3 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -72,14 +72,13 @@ endif
72PROMU_VERSION ?= 0.3.0 72PROMU_VERSION ?= 0.3.0
73PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_VERSION)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM).tar.gz 73PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_VERSION)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM).tar.gz
74 74
75STATICCHECK := 75GOLANGCI_LINT :=
76# staticcheck only supports linux, freebsd, darwin and windows platforms on i386/amd64 76GOLANGCI_LINT_VERSION ?= v1.16.0
77# golangci-lint only supports linux, darwin and windows platforms on i386/amd64.
77# windows isn't included here because of the path separator being different. 78# windows isn't included here because of the path separator being different.
78ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux freebsd darwin)) 79ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin))
79 ifeq ($(GOHOSTARCH),$(filter $(GOHOSTARCH),amd64 i386)) 80 ifeq ($(GOHOSTARCH),$(filter $(GOHOSTARCH),amd64 i386))
80 STATICCHECK := $(FIRST_GOPATH)/bin/staticcheck 81 GOLANGCI_LINT := $(FIRST_GOPATH)/bin/golangci-lint
81 STATICCHECK_VERSION ?= 2019.1
82 STATICCHECK_URL := https://github.com/dominikh/go-tools/releases/download/$(STATICCHECK_VERSION)/staticcheck_$(GOHOSTOS)_$(GOHOSTARCH)
83 endif 82 endif
84endif 83endif
85 84
@@ -107,7 +106,7 @@ endif
107%: common-% ; 106%: common-% ;
108 107
109.PHONY: common-all 108.PHONY: common-all
110common-all: precheck style check_license staticcheck unused build test 109common-all: precheck style check_license lint unused build test
111 110
112.PHONY: common-style 111.PHONY: common-style
113common-style: 112common-style:
@@ -159,21 +158,24 @@ common-vet:
159 @echo ">> vetting code" 158 @echo ">> vetting code"
160 GO111MODULE=$(GO111MODULE) $(GO) vet $(GOOPTS) $(pkgs) 159 GO111MODULE=$(GO111MODULE) $(GO) vet $(GOOPTS) $(pkgs)
161 160
162.PHONY: common-staticcheck 161.PHONY: common-lint
163common-staticcheck: $(STATICCHECK) 162common-lint: $(GOLANGCI_LINT)
164ifdef STATICCHECK 163ifdef GOLANGCI_LINT
165 @echo ">> running staticcheck" 164 @echo ">> running golangci-lint"
166 chmod +x $(STATICCHECK)
167ifdef GO111MODULE 165ifdef GO111MODULE
168# 'go list' needs to be executed before staticcheck to prepopulate the modules cache. 166# 'go list' needs to be executed before staticcheck to prepopulate the modules cache.
169# Otherwise staticcheck might fail randomly for some reason not yet explained. 167# Otherwise staticcheck might fail randomly for some reason not yet explained.
170 GO111MODULE=$(GO111MODULE) $(GO) list -e -compiled -test=true -export=false -deps=true -find=false -tags= -- ./... > /dev/null 168 GO111MODULE=$(GO111MODULE) $(GO) list -e -compiled -test=true -export=false -deps=true -find=false -tags= -- ./... > /dev/null
171 GO111MODULE=$(GO111MODULE) $(STATICCHECK) -ignore "$(STATICCHECK_IGNORE)" $(pkgs) 169 GO111MODULE=$(GO111MODULE) $(GOLANGCI_LINT) run $(pkgs)
172else 170else
173 $(STATICCHECK) -ignore "$(STATICCHECK_IGNORE)" $(pkgs) 171 $(GOLANGCI_LINT) run $(pkgs)
174endif 172endif
175endif 173endif
176 174
175# For backward-compatibility.
176.PHONY: common-staticcheck
177common-staticcheck: lint
178
177.PHONY: common-unused 179.PHONY: common-unused
178common-unused: $(GOVENDOR) 180common-unused: $(GOVENDOR)
179ifdef GOVENDOR 181ifdef GOVENDOR
@@ -241,10 +243,10 @@ proto:
241 @echo ">> generating code from proto files" 243 @echo ">> generating code from proto files"
242 @./scripts/genproto.sh 244 @./scripts/genproto.sh
243 245
244ifdef STATICCHECK 246ifdef GOLANGCI_LINT
245$(STATICCHECK): 247$(GOLANGCI_LINT):
246 mkdir -p $(FIRST_GOPATH)/bin 248 mkdir -p $(FIRST_GOPATH)/bin
247 curl -s -L $(STATICCHECK_URL) > $(STATICCHECK) 249 curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(FIRST_GOPATH)/bin $(GOLANGCI_LINT_VERSION)
248endif 250endif
249 251
250ifdef GOVENDOR 252ifdef GOVENDOR