aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorMatt Layher <mdlayher@gmail.com>2018-02-13 12:04:03 -0500
committerBen Kochie <superq@gmail.com>2018-02-13 18:04:03 +0100
commitdcb31670d63235cdd0ff0de03fe283980ce4e543 (patch)
treef381f3927b63489e093b50dd52c42f314e610515 /Makefile
parent3de2542d21da8b15db960677ad82a7d74d306714 (diff)
downloadprometheus_node_collector-dcb31670d63235cdd0ff0de03fe283980ce4e543.tar.bz2
prometheus_node_collector-dcb31670d63235cdd0ff0de03fe283980ce4e543.tar.xz
prometheus_node_collector-dcb31670d63235cdd0ff0de03fe283980ce4e543.zip
Makefile: add checkmetrics target, use in CI (#797)
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile20
1 files changed, 17 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 93c5b6c..1bbb136 100644
--- a/Makefile
+++ b/Makefile
@@ -16,6 +16,7 @@ GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH)))
16GOARCH := $(shell $(GO) env GOARCH) 16GOARCH := $(shell $(GO) env GOARCH)
17GOHOSTARCH := $(shell $(GO) env GOHOSTARCH) 17GOHOSTARCH := $(shell $(GO) env GOHOSTARCH)
18 18
19PROMTOOL ?= $(GOPATH)/bin/promtool
19PROMU ?= $(GOPATH)/bin/promu 20PROMU ?= $(GOPATH)/bin/promu
20STATICCHECK ?= $(GOPATH)/bin/staticcheck 21STATICCHECK ?= $(GOPATH)/bin/staticcheck
21pkgs = $(shell $(GO) list ./... | grep -v /vendor/) 22pkgs = $(shell $(GO) list ./... | grep -v /vendor/)
@@ -48,6 +49,12 @@ else
48 test-e2e := skip-test-e2e 49 test-e2e := skip-test-e2e
49endif 50endif
50 51
52ifeq ($(MACH), ppc64le)
53 e2e-out = collector/fixtures/e2e-ppc64le-output.txt
54else
55 e2e-out = collector/fixtures/e2e-output.txt
56endif
57
51# 64bit -> 32bit mapping for cross-checking. At least for amd64/386, the 64bit CPU can execute 32bit code but not the other way around, so we don't support cross-testing upwards. 58# 64bit -> 32bit mapping for cross-checking. At least for amd64/386, the 64bit CPU can execute 32bit code but not the other way around, so we don't support cross-testing upwards.
52cross-test = skip-test-32bit 59cross-test = skip-test-32bit
53define goarch_pair 60define goarch_pair
@@ -65,7 +72,7 @@ $(eval $(call goarch_pair,arm64,arm))
65$(eval $(call goarch_pair,mips64,mips)) 72$(eval $(call goarch_pair,mips64,mips))
66$(eval $(call goarch_pair,mips64el,mipsel)) 73$(eval $(call goarch_pair,mips64el,mipsel))
67 74
68all: format vet staticcheck build test $(cross-test) $(test-e2e) 75all: format vet staticcheck checkmetrics build test $(cross-test) $(test-e2e)
69 76
70style: 77style:
71 @echo ">> checking code style" 78 @echo ">> checking code style"
@@ -93,6 +100,10 @@ test-e2e: build collector/fixtures/sys/.unpacked
93skip-test-e2e: 100skip-test-e2e:
94 @echo ">> SKIP running end-to-end tests on $(OS_detected)" 101 @echo ">> SKIP running end-to-end tests on $(OS_detected)"
95 102
103checkmetrics: $(PROMTOOL)
104 @echo ">> checking metrics for correctness"
105 ./checkmetrics.sh $(PROMTOOL) $(e2e-out)
106
96format: 107format:
97 @echo ">> formatting code" 108 @echo ">> formatting code"
98 @$(GO) fmt $(pkgs) 109 @$(GO) fmt $(pkgs)
@@ -124,6 +135,9 @@ test-docker:
124 @echo ">> testing docker image" 135 @echo ">> testing docker image"
125 ./test_image.sh "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" 9100 136 ./test_image.sh "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" 9100
126 137
138$(GOPATH)/bin/promtool promtool:
139 @GOOS= GOARCH= $(GO) get -u github.com/prometheus/prometheus/cmd/promtool
140
127$(GOPATH)/bin/promu promu: 141$(GOPATH)/bin/promu promu:
128 @GOOS= GOARCH= $(GO) get -u github.com/prometheus/promu 142 @GOOS= GOARCH= $(GO) get -u github.com/prometheus/promu
129 143
@@ -131,10 +145,10 @@ $(GOPATH)/bin/staticcheck:
131 @GOOS= GOARCH= $(GO) get -u honnef.co/go/tools/cmd/staticcheck 145 @GOOS= GOARCH= $(GO) get -u honnef.co/go/tools/cmd/staticcheck
132 146
133 147
134.PHONY: all style format build test test-e2e vet tarball docker promu staticcheck 148.PHONY: all style format build test test-e2e vet tarball docker promtool promu staticcheck checkmetrics
135 149
136# Declaring the binaries at their default locations as PHONY targets is a hack 150# Declaring the binaries at their default locations as PHONY targets is a hack
137# to ensure the latest version is downloaded on every make execution. 151# to ensure the latest version is downloaded on every make execution.
138# If this is not desired, copy/symlink these binaries to a different path and 152# If this is not desired, copy/symlink these binaries to a different path and
139# set the respective environment variables. 153# set the respective environment variables.
140.PHONY: $(GOPATH)/bin/promu $(GOPATH)/bin/staticcheck 154.PHONY: $(GOPATH)/bin/promtool $(GOPATH)/bin/promu $(GOPATH)/bin/staticcheck