-
Notifications
You must be signed in to change notification settings - Fork 19
/
Makefile
56 lines (43 loc) · 1.38 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
PKG := github.com/dev25/mcrouter_exporter
OUT := mcrouter_exporter
GOLANGCI_VERSION ?= 1.27.0
# Build info
REVISION := $(shell git describe --always --long --dirty)
VERSION := $(shell git tag --points-at HEAD)
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
BUILD_DATE := $(shell date +%Y%m%d-%H:%M:%S)
FLAGS := "-X github.com/prometheus/common/version.Version=${VERSION} \
-X github.com/prometheus/common/version.Branch=${BRANCH} \
-X github.com/prometheus/common/version.Revision=${REVISION} \
-X github.com/prometheus/common/version.BuildDate=${BUILD_DATE}"
all: fmt lint build
bin/golangci-lint: bin/golangci-lint-${GOLANGCI_VERSION}
@ln -sf golangci-lint-${GOLANGCI_VERSION} bin/golangci-lint
bin/golangci-lint-${GOLANGCI_VERSION}:
@mkdir -p bin
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | BINARY=golangci-lint bash -s -- v${GOLANGCI_VERSION}
@mv bin/golangci-lint $@
.PHONY: lint
lint: bin/golangci-lint ## Run linter
bin/golangci-lint run
.PHONY: fix
fix: bin/golangci-lint ## Fix lint violations
bin/golangci-lint run --fix
.PHONY: fmt
fmt:
@go fmt
.PHONY: vet
vet:
@go vet ${PKG_LIST}
.PHONY: test
test: fmt vet
go test -mod=vendor
.PHONY: build
build:
go build -mod=vendor -v -o ${OUT} -ldflags=$(FLAGS)
.PHONY: build-docker
build-docker:
CGO_ENABLED=0 go build -mod=vendor -a -o ${OUT} -ldflags=$(FLAGS)
.PHONY: clean
clean:
-@rm -f ${OUT}