aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Pasquier <spasquie@redhat.com>2019-03-25 12:47:57 +0100
committerJohannes 'fish' Ziemke <github@freigeist.org>2019-03-25 12:47:57 +0100
commitdbe7badc7c37da1ddaaa33db4860e51a73c4c44a (patch)
tree9fad12c85f6537992e4f7051a90d2c3ffa44732d
parent2f87b7cba6d6eb729a78724335fd59e746fcdff4 (diff)
downloadprometheus_node_collector-dbe7badc7c37da1ddaaa33db4860e51a73c4c44a.tar.bz2
prometheus_node_collector-dbe7badc7c37da1ddaaa33db4860e51a73c4c44a.tar.xz
prometheus_node_collector-dbe7badc7c37da1ddaaa33db4860e51a73c4c44a.zip
Update Makefile.common (#1288)
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
-rw-r--r--Makefile5
-rw-r--r--Makefile.common34
-rw-r--r--node_exporter_test.go13
3 files changed, 44 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index d4144e4..908cb9a 100644
--- a/Makefile
+++ b/Makefile
@@ -11,6 +11,9 @@
11# See the License for the specific language governing permissions and 11# See the License for the specific language governing permissions and
12# limitations under the License. 12# limitations under the License.
13 13
14# Ensure that 'all' is the default target otherwise it will be the first target from Makefile.common.
15all::
16
14include Makefile.common 17include Makefile.common
15 18
16PROMTOOL_VERSION ?= 2.5.0 19PROMTOOL_VERSION ?= 2.5.0
@@ -70,7 +73,7 @@ $(eval $(call goarch_pair,amd64,386))
70$(eval $(call goarch_pair,mips64,mips)) 73$(eval $(call goarch_pair,mips64,mips))
71$(eval $(call goarch_pair,mips64el,mipsel)) 74$(eval $(call goarch_pair,mips64el,mipsel))
72 75
73all: style vet staticcheck checkmetrics checkrules build test $(cross-test) $(test-e2e) 76all:: vet checkmetrics checkrules common-all $(cross-test) $(test-e2e)
74 77
75.PHONY: test 78.PHONY: test
76test: collector/fixtures/sys/.unpacked 79test: collector/fixtures/sys/.unpacked
diff --git a/Makefile.common b/Makefile.common
index 79001dd..ed29aa8 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -60,7 +60,6 @@ $(warning Some recipes may not work as expected as the current Go runtime is '$(
60 endif 60 endif
61endif 61endif
62PROMU := $(FIRST_GOPATH)/bin/promu 62PROMU := $(FIRST_GOPATH)/bin/promu
63STATICCHECK := $(FIRST_GOPATH)/bin/staticcheck
64pkgs = ./... 63pkgs = ./...
65 64
66ifeq (arm, $(GOHOSTARCH)) 65ifeq (arm, $(GOHOSTARCH))
@@ -72,8 +71,17 @@ endif
72 71
73PROMU_VERSION ?= 0.3.0 72PROMU_VERSION ?= 0.3.0
74PROMU_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
75STATICCHECK_VERSION ?= 2019.1 74
76STATICCHECK_URL := https://github.com/dominikh/go-tools/releases/download/$(STATICCHECK_VERSION)/staticcheck_$(GOHOSTOS)_$(GOHOSTARCH) 75STATICCHECK :=
76# staticcheck only supports linux, freebsd, darwin and windows platforms on i386/amd64
77# windows isn't included here because of the path separator being different.
78ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux freebsd darwin))
79 ifeq ($(GOHOSTARCH),$(filter $(GOHOSTARCH),amd64 i386))
80 STATICCHECK := $(FIRST_GOPATH)/bin/staticcheck
81 STATICCHECK_VERSION ?= 2019.1
82 STATICCHECK_URL := https://github.com/dominikh/go-tools/releases/download/$(STATICCHECK_VERSION)/staticcheck_$(GOHOSTOS)_$(GOHOSTARCH)
83 endif
84endif
77 85
78PREFIX ?= $(shell pwd) 86PREFIX ?= $(shell pwd)
79BIN_DIR ?= $(shell pwd) 87BIN_DIR ?= $(shell pwd)
@@ -87,14 +95,14 @@ ifeq ($(GOHOSTARCH),amd64)
87 endif 95 endif
88endif 96endif
89 97
90.PHONY: all
91all: precheck style staticcheck unused build test
92
93# This rule is used to forward a target like "build" to "common-build". This 98# This rule is used to forward a target like "build" to "common-build". This
94# allows a new "build" target to be defined in a Makefile which includes this 99# allows a new "build" target to be defined in a Makefile which includes this
95# one and override "common-build" without override warnings. 100# one and override "common-build" without override warnings.
96%: common-% ; 101%: common-% ;
97 102
103.PHONY: common-all
104common-all: precheck style check_license staticcheck unused build test
105
98.PHONY: common-style 106.PHONY: common-style
99common-style: 107common-style:
100 @echo ">> checking code style" 108 @echo ">> checking code style"
@@ -116,6 +124,15 @@ common-check_license:
116 exit 1; \ 124 exit 1; \
117 fi 125 fi
118 126
127.PHONY: common-deps
128common-deps:
129 @echo ">> getting dependencies"
130ifdef GO111MODULE
131 GO111MODULE=$(GO111MODULE) $(GO) mod download
132else
133 $(GO) get $(GOOPTS) -t ./...
134endif
135
119.PHONY: common-test-short 136.PHONY: common-test-short
120common-test-short: 137common-test-short:
121 @echo ">> running short tests" 138 @echo ">> running short tests"
@@ -138,6 +155,7 @@ common-vet:
138 155
139.PHONY: common-staticcheck 156.PHONY: common-staticcheck
140common-staticcheck: $(STATICCHECK) 157common-staticcheck: $(STATICCHECK)
158ifdef STATICCHECK
141 @echo ">> running staticcheck" 159 @echo ">> running staticcheck"
142 chmod +x $(STATICCHECK) 160 chmod +x $(STATICCHECK)
143ifdef GO111MODULE 161ifdef GO111MODULE
@@ -148,6 +166,7 @@ ifdef GO111MODULE
148else 166else
149 $(STATICCHECK) -ignore "$(STATICCHECK_IGNORE)" $(pkgs) 167 $(STATICCHECK) -ignore "$(STATICCHECK_IGNORE)" $(pkgs)
150endif 168endif
169endif
151 170
152.PHONY: common-unused 171.PHONY: common-unused
153common-unused: $(GOVENDOR) 172common-unused: $(GOVENDOR)
@@ -205,9 +224,11 @@ proto:
205 @echo ">> generating code from proto files" 224 @echo ">> generating code from proto files"
206 @./scripts/genproto.sh 225 @./scripts/genproto.sh
207 226
227ifdef STATICCHECK
208$(STATICCHECK): 228$(STATICCHECK):
209 mkdir -p $(FIRST_GOPATH)/bin 229 mkdir -p $(FIRST_GOPATH)/bin
210 curl -s -L $(STATICCHECK_URL) > $(STATICCHECK) 230 curl -s -L $(STATICCHECK_URL) > $(STATICCHECK)
231endif
211 232
212ifdef GOVENDOR 233ifdef GOVENDOR
213.PHONY: $(GOVENDOR) 234.PHONY: $(GOVENDOR)
@@ -221,7 +242,6 @@ precheck::
221define PRECHECK_COMMAND_template = 242define PRECHECK_COMMAND_template =
222precheck:: $(1)_precheck 243precheck:: $(1)_precheck
223 244
224
225PRECHECK_COMMAND_$(1) ?= $(1) $$(strip $$(PRECHECK_OPTIONS_$(1))) 245PRECHECK_COMMAND_$(1) ?= $(1) $$(strip $$(PRECHECK_OPTIONS_$(1)))
226.PHONY: $(1)_precheck 246.PHONY: $(1)_precheck
227$(1)_precheck: 247$(1)_precheck:
diff --git a/node_exporter_test.go b/node_exporter_test.go
index 5a9599e..a0881e9 100644
--- a/node_exporter_test.go
+++ b/node_exporter_test.go
@@ -1,3 +1,16 @@
1// Copyright 2017 The Prometheus Authors
2// Licensed under the Apache License, Version 2.0 (the "License");
3// you may not use this file except in compliance with the License.
4// You may obtain a copy of the License at
5//
6// http://www.apache.org/licenses/LICENSE-2.0
7//
8// Unless required by applicable law or agreed to in writing, software
9// distributed under the License is distributed on an "AS IS" BASIS,
10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11// See the License for the specific language governing permissions and
12// limitations under the License.
13
1package main 14package main
2 15
3import ( 16import (