This repository has been archived by the owner on Jul 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 57
/
Makefile
71 lines (56 loc) · 2.02 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
GO ?= go
GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH)))
pkgs = $(shell $(GO) list ./... | grep -v /vendor/)
PROMU ?= $(GOPATH)/bin/promu
GODEP ?= $(GOPATH)/bin/dep
GOLINTER ?= $(GOPATH)/bin/gometalinter
BIN_DIR ?= $(shell pwd):x
TARGET ?= gluster_exporter
info:
@echo "build: Go build"
@echo "docker: build and run in docker container"
@echo "gometalinter: run some linting checks"
@echo "gotest: run go tests and reformats"
build: depcheck $(PROMU) gotest
@echo ">> building binaries"
@$(PROMU) build
docker: gotest build
docker build -t gluster-exporter-test .
docker run --rm --privileged=true -p 9189:9189 -p 24007:24007 -p 24009-24108:24009-24108/tcp -i -v gluster-test:/data gluster-exporter-test
gotest: vet format
@echo ">> running tests"
@$(GO) test -short $(pkgs)
format:
@echo ">> formatting code"
@$(GO) fmt $(pkgs)
vet:
@echo ">> vetting code"
@$(GO) vet $(pkgs)
$(GOPATH)/bin/promu promu:
@GOOS=$(shell uname -s | tr A-Z a-z) \
GOARCH=$(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m))) \
$(GO) get -u github.com/prometheus/promu
promu-build: gotest promu
$(PROMU) build
tarball: build promu
@$(PROMU) tarball $(BIN_DIR)
clean:
@echo ">> cleaning up"
@find . -type f -name '*~' -exec rm -fv {} \;
@$(RM) $(TARGET)
depcheck: $(GODEP)
@echo ">> ensure vendoring"
@$(GODEP) ensure
gometalinter: $(GOLINTER)
@echo ">> linting code"
@$(GOLINTER) --install > /dev/null
@$(GOLINTER) --config=./.gometalinter.json ./...
$(GOPATH)/bin/dep dep:
@GOOS=$(shell uname -s | tr A-Z a-z) \
GOARCH=$(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m))) \
$(GO) get -u github.com/golang/dep/cmd/dep
$(GOPATH)/bin/gometalinter lint:
@GOOS=$(shell uname -s | tr A-Z a-z) \
GOARCH=$(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m))) \
$(GO) get -u github.com/alecthomas/gometalinter
.PHONY: all format vet build gotest promu promu-build clean $(GOPATH)/bin/promu $(GOPATH)/bin/dep dep depcheck $(GOPATH)/bin/gometalinter lint