forked from prometheus-community/systemd_exporter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
30 lines (23 loc) · 967 Bytes
/
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
DATE := $(shell date +%FT%T%z)
USER := $(shell whoami)
GIT_HASH := $(shell git --no-pager describe --tags --always)
BRANCH := $(shell git branch | grep \* | cut -d ' ' -f2)
LINT_FLAGS := run --deadline=120s
LINTER := ./bin/golangci-lint
TESTFLAGS := -v -cover
GO111MODULE := on
all: $(LINTER) deps test lint build
$(LINTER):
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v1.15.0
.PHONY: lint
lint: $(LINTER)
$(LINTER) $(LINT_FLAGS) ./...
.PHONY: deps
deps:
go get .
.PHONY: test
test:
go test $(TESTFLAGS) ./...
.PHONY: build
build: deps
CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-s -X github.com/prometheus/common/version.Version=$(GIT_HASH) -X github.com/prometheus/common/version.BuildDate="$(DATE)" -X github.com/prometheus/common/version.Branch=$(BRANCH) -X github.com/prometheus/common/version.Revision=$(GIT_HASH) -X github.com/prometheus/common/version.BuildUser=$(USER) -extldflags "-static"' .