-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
62 lines (51 loc) · 1.58 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
BIN = $(CURDIR)/bin
IMAGE = ppussar/mongodb_exporter
VERSION ?= $(shell git describe --tags --always --dirty 2> /dev/null || echo v0)
GO = go
TIMEOUT = 15
.PHONY: all
all:
@echo $(VERSION)
.PHONY: run
run:
$(GO) run *.go configuration.yaml
.PHONY: test
test: ## Runs the go tests.
@echo "+ $@"
@$(GO) test -v -tags "$(BUILDTAGS) cgo" $(shell $(GO) list ./... | grep -v wrapper | grep -v mocks)
.PHONY: cover
cover: ## Runs go test with coverage.
@echo "" > coverage.txt
@for d in $(shell $(GO) list ./... | grep -v vendor); do \
$(GO) test -race -coverprofile=profile.out -covermode=atomic "$$d"; \
if [ -f profile.out ]; then \
cat profile.out >> coverage.txt; \
rm profile.out; \
fi; \
done;
.PHONY: build
build: test
$(GO) build -v -o $(BIN)/mongodb_exporter .
.PHONY: clean
clean:
@rm -rf $(BIN)
.PHONY: image
image:
CGO_ENABLED=0 GOOS=linux $(GO) build -a -installsuffix cgo -o $(BIN)/mongodb_exporter .
@cp docker/Dockerfile $(BIN)
@docker build -t $(IMAGE):$(VERSION) $(BIN)
.PHONY: push-image
push-image:
@docker push $(IMAGE):$(VERSION)
.PHONY: start-demo
start-demo: image
@docker compose -f docker/docker-compose.yaml up --build -d
@echo "\ncurl localhost:9090/prometheus | grep fruitstore"
@curl -s localhost:9090/prometheus | grep fruitstore
.PHONY: stop-demo
stop-demo:
@docker compose -f docker/docker-compose.yaml down --remove-orphans
.PHONY: generate-mocks
generate-mocks: ## regenerates the mocks for the tests
mockery -dir internal/wrapper -output internal/mocks -name IConnection
mockery -dir internal/wrapper -output internal/mocks -name ICursor