diff options
author | PrometheusBot <prometheus-team@googlegroups.com> | 2019-04-25 09:53:48 +0100 |
---|---|---|
committer | Ben Kochie <superq@gmail.com> | 2019-04-25 10:53:48 +0200 |
commit | b5cab091dc76aff99e36621aeb6515dcfe225af8 (patch) | |
tree | e54fba4bbb0b0dc36e9b08a0bf6f17464c64b63e /Makefile.common | |
parent | 78b9eb9c2c4366d6523a2ccbea6e9b0aad1104fe (diff) | |
download | prometheus_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.common | 36 |
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 | |||
72 | PROMU_VERSION ?= 0.3.0 | 72 | PROMU_VERSION ?= 0.3.0 |
73 | PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_VERSION)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM).tar.gz | 73 | PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_VERSION)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM).tar.gz |
74 | 74 | ||
75 | STATICCHECK := | 75 | GOLANGCI_LINT := |
76 | # staticcheck only supports linux, freebsd, darwin and windows platforms on i386/amd64 | 76 | GOLANGCI_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. |
78 | ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux freebsd darwin)) | 79 | ifeq ($(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 |
84 | endif | 83 | endif |
85 | 84 | ||
@@ -107,7 +106,7 @@ endif | |||
107 | %: common-% ; | 106 | %: common-% ; |
108 | 107 | ||
109 | .PHONY: common-all | 108 | .PHONY: common-all |
110 | common-all: precheck style check_license staticcheck unused build test | 109 | common-all: precheck style check_license lint unused build test |
111 | 110 | ||
112 | .PHONY: common-style | 111 | .PHONY: common-style |
113 | common-style: | 112 | common-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 |
163 | common-staticcheck: $(STATICCHECK) | 162 | common-lint: $(GOLANGCI_LINT) |
164 | ifdef STATICCHECK | 163 | ifdef GOLANGCI_LINT |
165 | @echo ">> running staticcheck" | 164 | @echo ">> running golangci-lint" |
166 | chmod +x $(STATICCHECK) | ||
167 | ifdef GO111MODULE | 165 | ifdef 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) |
172 | else | 170 | else |
173 | $(STATICCHECK) -ignore "$(STATICCHECK_IGNORE)" $(pkgs) | 171 | $(GOLANGCI_LINT) run $(pkgs) |
174 | endif | 172 | endif |
175 | endif | 173 | endif |
176 | 174 | ||
175 | # For backward-compatibility. | ||
176 | .PHONY: common-staticcheck | ||
177 | common-staticcheck: lint | ||
178 | |||
177 | .PHONY: common-unused | 179 | .PHONY: common-unused |
178 | common-unused: $(GOVENDOR) | 180 | common-unused: $(GOVENDOR) |
179 | ifdef GOVENDOR | 181 | ifdef 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 | ||
244 | ifdef STATICCHECK | 246 | ifdef 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) |
248 | endif | 250 | endif |
249 | 251 | ||
250 | ifdef GOVENDOR | 252 | ifdef GOVENDOR |