-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
58 lines (44 loc) · 1.61 KB
/
Makefile
File metadata and controls
58 lines (44 loc) · 1.61 KB
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
APPNAME := dscexporter
APPSRC := ./cmd/$(APPNAME)
PKG := github.com/DENICeG/dscexporter
TEST_PKG_LIST := cmd/dscexporter config dscparser exporters scheduler aggregation
GITCOMMITHASH := $(shell git log --max-count=1 --pretty="format:%h" HEAD)
GITCOMMIT := -X main.gitcommit=$(GITCOMMITHASH)
VERSIONTAG := $(shell git describe --tags --abbrev=0)
VERSION := -X main.appversion=$(VERSIONTAG)
BUILDTIMEVALUE := $(shell date +%Y-%m-%dT%H:%M:%S%z)
BUILDTIME := -X main.buildtime=$(BUILDTIMEVALUE)
LDFLAGS := '-extldflags "-static" -d -s -w $(GITCOMMIT) $(VERSION) $(BUILDTIME)'
LDFLAGS_WINDOWS := '-extldflags "-static" -s -w $(GITCOMMIT) $(VERSION) $(BUILDTIME)'
clean:
rm -rf build
info:
@echo - appname: $(APPNAME)
@echo - verison: $(VERSIONTAG)
@echo - commit: $(GITCOMMITHASH)
@echo - buildtime: $(BUILDTIMEVALUE)
dep:
@go get -v -d ./...
install: build-linux
cp build/linux/$(APPNAME) /usr/local/bin
build-linux: info dep
@echo Building for linux
@mkdir -p build/linux
@CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64 \
go build -o build/linux/$(APPNAME)-$(VERSIONTAG)-$(GITCOMMITHASH) -a -ldflags $(LDFLAGS) $(APPSRC)
@cp build/linux/$(APPNAME)-$(VERSIONTAG)-$(GITCOMMITHASH) build/linux/$(APPNAME)
unittests:
CGO_ENABLED=0 go test -v -count=1 -cover -coverprofile cover.out -p 1 $(addprefix $(PKG)/, $(TEST_PKG_LIST))
go tool cover -func=cover.out
go tool cover -html=cover.out -o cover.html
shutdown:
- docker stop prometheus
prometheus: shutdown
docker run -d --rm \
--name prometheus \
--net=host \
-v "$$(pwd)/testdata/prometheus.yml:/etc/prometheus/prometheus.yml" \
prom/prometheus
test: unittests