-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
71 lines (54 loc) · 1.89 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
# Directory containing the Makefile.
PROJECT_ROOT = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
export PATH := $(GOBIN):$(PATH)
BENCH_FLAGS ?= -cpuprofile=cpu.pprof -memprofile=mem.pprof -benchmem
# Directories containing independent Go modules.
MODULE_DIRS = benchmark acronis-db-bench acronis-restrelay-bench
GO_INSTALLABLE_DIRS = acronis-db-bench
# Directories that we want to test and track coverage for.
TEST_DIRS = benchmark acronis-restrelay-bench
include acronis-restrelay-bench/restrelay-bench.Makefile
.PHONY: all
all: lint cover
.PHONY: lint
lint: golangci-lint
.PHONY: golangci-lint
golangci-lint:
@$(foreach mod,$(MODULE_DIRS), \
(cd $(mod) && \
echo "[lint] golangci-lint: $(mod)" && \
golangci-lint run --path-prefix $(mod)) &&) true
.PHONY: tidy
tidy:
@$(foreach dir,$(MODULE_DIRS), \
(cd $(dir) && go mod tidy) &&) true
.PHONY: test
test:
@$(foreach dir,$(TEST_DIRS),(cd $(dir) && go test -race ./...) &&) true
.PHONY: cover
cover:
@$(foreach dir,$(TEST_DIRS), ( \
cd $(dir) && \
go test -race -coverprofile=cover.out -coverpkg=./... ./... \
&& go tool cover -html=cover.out -o cover.html) &&) true
.PHONY: install
install: go-install
.PHONY: go-install
go-install:
@$(foreach dir,$(GO_INSTALLABLE_DIRS), ( \
cd $(dir) && \
go install -v -ldflags "-X main.Version=`cat VERSION`" ./... \
&& echo `go list -f '{{.Module.Path}}'`-v`cat VERSION` has been installed to `go list -f '{{.Target}}'`) &&) true
.PHONY: install-acronis-db-bench
install-acronis-db-bench:
@$(MAKE) GO_INSTALLABLE_DIRS=acronis-db-bench install
.PHONY: build-acronis-restrelay-bench
build-acronis-restrelay-bench: build-restrelay-bench
.PHONY: up-version
up-version:
@$(foreach dir,$(MODULE_DIRS), ( \
cd $(dir) ; \
echo "Up version for `basename $(dir)` to `cat VERSION`" ; \
git tag "`basename $(dir)`/v`cat VERSION`" ; \
git push origin "`basename $(dir)`/v`cat VERSION`") ; \
) true