-
Notifications
You must be signed in to change notification settings - Fork 38
/
Makefile
129 lines (101 loc) · 3.26 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
PWD = $(shell pwd)
MODULES ?= bkmonitorbeat collector operator transfer unify-query influxdb-proxy ingester offline-data-archive bk-monitor-worker sliwebhook
RELEASE_PATH ?= $(PWD)/dist
BUILD_NO ?= 1
COMMIT_ID = $(shell git rev-parse HEAD)
MODULE = ''
RELEASE ?= false
MODULE_VERSION = $(subst v,ee-V, $(shell cat $(PWD)/pkg/$(MODULE)/VERSION||echo ''))
BRANCH ?= $(shell git symbolic-ref --short HEAD)
ifeq ($(RELEASE), true)
PACKAGE_VERSION = $(MODULE_VERSION)
else
PACKAGE_VERSION = $(MODULE_VERSION)-$(BRANCH)
endif
VERSION = $(subst v,,$(subst x,$(BUILD_NO),$(shell cat $(PWD)/pkg/$(MODULE)/VERSION || echo '')))
TAG = pkg/$(MODULE)/v$(VERSION)
PIP_PATH ?= $(shell which pip)
.PHONY: all
all: bkmonitorbeat collector operator transfer unify-query influxdb-proxy ingester offline-data-archive bk-monitor-worker sliwebhook
.PHONY: .check_module_vars
.check_module_vars:
@test $${MODULE?Please set environment variable MODULE}
.PHONY: build
build: .check_module_vars
mkdir -p $(RELEASE_PATH)/$(MODULE)
@echo make module: $(MODULE) BUILD_NO: $(BUILD_NO) COMMIT_ID: $(COMMIT_ID)
cd $(PWD)/pkg/$(MODULE) && make RELEASE_PATH=$(RELEASE_PATH)/$(MODULE) VERSION=$(VERSION) BUILD_NO=$(BUILD_NO) COMMIT_ID=$(COMMIT_ID) build
.PHONY: bkmonitorbeat
bkmonitorbeat:
$(MAKE) MODULE=bkmonitorbeat build
.PHONY: collector
collector:
$(MAKE) MODULE=collector build
.PHONY: operator
operator:
$(MAKE) MODULE=operator build
.PHONY: sliwebhook
sliwebhook:
$(MAKE) MODULE=sliwebhook build
.PHONY: transfer
transfer:
$(MAKE) MODULE=transfer build
.PHONY: unify-query
unify-query:
$(MAKE) MODULE=unify-query build
.PHONY: influxdb-proxy
influxdb-proxy:
$(MAKE) MODULE=influxdb-proxy build
.PHONY: ingester
ingester:
$(MAKE) MODULE=ingester build
.PHONY: offline-data-archive
offline-data-archive:
$(MAKE) MODULE=offline-data-archive build
.PHONY: bk-monitor-worker
bk-monitor-worker:
$(MAKE) MODULE=bk-monitor-worker build
.PHONY: version
version: .check_module_vars
@echo $(VERSION)
.PHONY: package_version
package_version:
@echo $(PACKAGE_VERSION)
.PHONY: tag
tag: .check_module_vars
cd $(PWD)/pkg/$(MODULE) || exit 1
@echo tag: $(TAG)
git tag $(TAG)
git push --tags
.PHONY: lint
lint:
cd $(PWD)/pkg/$(MODULE) && make lint
.PHONY: test
test:
cd $(PWD)/pkg/$(MODULE) && make test
.PHONY: fmt
fmt:
cd $(PWD)/pkg/$(MODULE) && go fmt ./...
.PHONY: debug
debug: .check_module_vars
mkdir -p $(RELEASE_PATH)/$(MODULE)
@echo make module: $(MODULE) BUILD_NO: $(BUILD_NO) COMMIT_ID: $(COMMIT_ID)
cd $(PWD)/pkg/$(MODULE) && make RELEASE_PATH=$(RELEASE_PATH)/$(MODULE) VERSION=$(VERSION) BUILD_NO=$(BUILD_NO) COMMIT_ID=$(COMMIT_ID) debug
.PHONY: pre-commit
pre-commit:
pre-commit run -a
.check_pip_vars:
@test $(PIP_PATH)||(echo 'pip command or PIP_PATH not found'&&exit 1)
.PHONY: pre-commit-install
pre-commit-install: .check_pip_vars
$(PIP_PATH) install -r scripts/requirements.txt
go install github.com/google/addlicense@latest
go install github.com/incu6us/goimports-reviser/v3@latest
pre-commit clean
pre-commit install
.PHONY: addlicense
addlicense:
find ./ -type f \( -iname \*.go -o -iname \*.py -iname \*.sh \)|xargs addlicense -v -f scripts/license.txt -ignore vendor/*
.PHONY: imports
imports: addlicense
goimports-reviser -project-name "github.com/TencentBlueKing/bkmonitor-datalink/pkg" ./...