diff options
author | Ivan Voronchihin <bege13mot@gmail.com> | 2018-05-25 01:31:48 +0400 |
---|---|---|
committer | Johannes 'fish' Ziemke <github@freigeist.org> | 2018-05-24 23:31:48 +0200 |
commit | 606568314befb8127ce48de29ecb647bd9d8507a (patch) | |
tree | c622e270f2e13d9fc9f626591bb2fe65d7db2c21 /Makefile.common | |
parent | 04d69158b40cc89fb34b0a6f08d6e136b1a9fde9 (diff) | |
download | prometheus_node_collector-606568314befb8127ce48de29ecb647bd9d8507a.tar.bz2 prometheus_node_collector-606568314befb8127ce48de29ecb647bd9d8507a.tar.xz prometheus_node_collector-606568314befb8127ce48de29ecb647bd9d8507a.zip |
Add Makefile.common (#940)
* Add Makefile.common
Signed-off-by: bege13mot <bege13mot@gmail.com>
* Change Makefile.common to initial Prometheus common
Signed-off-by: bege13mot <bege13mot@gmail.com>
* fix checkmetrics
Signed-off-by: bege13mot <bege13mot@gmail.com>
* fix promu
Signed-off-by: bege13mot <bege13mot@gmail.com>
* Add test to common
Signed-off-by: bege13mot <bege13mot@gmail.com>
* Fix GOPATH
Signed-off-by: bege13mot <bege13mot@gmail.com>
* Initial Makefile.common
Signed-off-by: bege13mot <bege13mot@gmail.com>
* original Makefile.common
Signed-off-by: bege13mot <bege13mot@gmail.com>
* delete promu
Signed-off-by: bege13mot <bege13mot@gmail.com>
* delete redundant .PRONY params
Signed-off-by: bege13mot <bege13mot@gmail.com>
Diffstat (limited to 'Makefile.common')
-rw-r--r-- | Makefile.common | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/Makefile.common b/Makefile.common new file mode 100644 index 0000000..353494c --- /dev/null +++ b/Makefile.common | |||
@@ -0,0 +1,100 @@ | |||
1 | # Copyright 2018 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 | |||
14 | |||
15 | # A common Makefile that includes rules to be reused in different prometheus projects. | ||
16 | # !!! Open PRs only against the prometheus/prometheus/Makefile.common repository! | ||
17 | |||
18 | # Example usage : | ||
19 | # Create the main Makefile in the root project directory. | ||
20 | # include Makefile.common | ||
21 | # customTarget: | ||
22 | # @echo ">> Running customTarget" | ||
23 | # | ||
24 | |||
25 | # Ensure GOBIN is not set during build so that promu is installed to the correct path | ||
26 | unexport GOBIN | ||
27 | |||
28 | GO ?= go | ||
29 | GOFMT ?= $(GO)fmt | ||
30 | FIRST_GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH))) | ||
31 | PROMU := $(FIRST_GOPATH)/bin/promu | ||
32 | STATICCHECK := $(FIRST_GOPATH)/bin/staticcheck | ||
33 | GOVENDOR := $(FIRST_GOPATH)/bin/govendor | ||
34 | pkgs = ./... | ||
35 | |||
36 | PREFIX ?= $(shell pwd) | ||
37 | BIN_DIR ?= $(shell pwd) | ||
38 | DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD)) | ||
39 | |||
40 | all: style staticcheck unused build test | ||
41 | |||
42 | style: | ||
43 | @echo ">> checking code style" | ||
44 | ! $(GOFMT) -d $$(find . -path ./vendor -prune -o -name '*.go' -print) | grep '^' | ||
45 | |||
46 | check_license: | ||
47 | @echo ">> checking license header" | ||
48 | @licRes=$$(for file in $$(find . -type f -iname '*.go' ! -path './vendor/*') ; do \ | ||
49 | awk 'NR<=3' $$file | grep -Eq "(Copyright|generated|GENERATED)" || echo $$file; \ | ||
50 | done); \ | ||
51 | if [ -n "$${licRes}" ]; then \ | ||
52 | echo "license header checking failed:"; echo "$${licRes}"; \ | ||
53 | exit 1; \ | ||
54 | fi | ||
55 | |||
56 | test-short: | ||
57 | @echo ">> running short tests" | ||
58 | $(GO) test -short $(pkgs) | ||
59 | |||
60 | test: | ||
61 | @echo ">> running all tests" | ||
62 | $(GO) test -race $(pkgs) | ||
63 | |||
64 | format: | ||
65 | @echo ">> formatting code" | ||
66 | $(GO) fmt $(pkgs) | ||
67 | |||
68 | vet: | ||
69 | @echo ">> vetting code" | ||
70 | $(GO) vet $(pkgs) | ||
71 | |||
72 | staticcheck: $(STATICCHECK) | ||
73 | @echo ">> running staticcheck" | ||
74 | $(STATICCHECK) -ignore "$(STATICCHECK_IGNORE)" $(pkgs) | ||
75 | |||
76 | unused: $(GOVENDOR) | ||
77 | @echo ">> running check for unused packages" | ||
78 | @$(GOVENDOR) list +unused | grep . && exit 1 || echo 'No unused packages' | ||
79 | |||
80 | build: promu | ||
81 | @echo ">> building binaries" | ||
82 | $(PROMU) build --prefix $(PREFIX) | ||
83 | |||
84 | tarball: promu | ||
85 | @echo ">> building release tarball" | ||
86 | $(PROMU) tarball --prefix $(PREFIX) $(BIN_DIR) | ||
87 | |||
88 | docker: | ||
89 | docker build -t "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" . | ||
90 | |||
91 | promu: | ||
92 | GOOS= GOARCH= $(GO) get -u github.com/prometheus/promu | ||
93 | |||
94 | $(FIRST_GOPATH)/bin/staticcheck: | ||
95 | GOOS= GOARCH= $(GO) get -u honnef.co/go/tools/cmd/staticcheck | ||
96 | |||
97 | $(FIRST_GOPATH)/bin/govendor: | ||
98 | GOOS= GOARCH= $(GO) get -u github.com/kardianos/govendor | ||
99 | |||
100 | .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 | ||