-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathMakefile
More file actions
201 lines (173 loc) · 8.83 KB
/
Copy pathMakefile
File metadata and controls
201 lines (173 loc) · 8.83 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
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
BUILD_VERSION := $(if $(BUILD_VERSION),$(BUILD_VERSION),$(shell git describe --tags --always --dirty))
BUILD_COMMIT := $(if $(BUILD_COMMIT),$(BUILD_COMMIT),$(shell git log --format="%H" -n 1))
BUILD_COMMIT_TS := $(if $(BUILD_COMMIT_TS),$(BUILD_COMMIT_TS),$(shell git log --format="%ct" -n 1))
BUILD_TIME := $(if $(BUILD_TIME),$(BUILD_TIME),$(shell date +%FT%T%z))
BUILD_MACHINE := $(if $(BUILD_MACHINE),$(BUILD_MACHINE),$(shell uname -n -m -r -s))
REACT_APP_BUILD_VERSION := $(if $(REACT_APP_BUILD_VERSION),$(REACT_APP_BUILD_VERSION),$(BUILD_VERSION)-$(BUILD_TIME))
TL_BYTE_VERSIONS := statshouse.
# TODO: BUILD_ID
TL_GEN := go run github.com/VKCOM/tl/cmd/tl2gen@v1.5.3
#TL_GEN := /home/user/devbox/VKCOM/tl/target/bin/tlgen # for quick switch to locally developed tlgen
COMMON_BUILD_VARS := -X 'github.com/VKCOM/statshouse/internal/vkgo/build.time=$(BUILD_TIME)' \
-X 'github.com/VKCOM/statshouse/internal/vkgo/build.machine=$(BUILD_MACHINE)' \
-X 'github.com/VKCOM/statshouse/internal/vkgo/build.commit=$(BUILD_COMMIT)' \
-X 'github.com/VKCOM/statshouse/internal/vkgo/build.version=$(BUILD_VERSION)' \
-X 'github.com/VKCOM/statshouse/internal/vkgo/build.number=$(BUILD_ID)' \
-X 'github.com/VKCOM/statshouse/internal/vkgo/build.commitTimestamp=$(BUILD_COMMIT_TS)' \
-X 'github.com/VKCOM/statshouse/internal/vkgo/build.trustedSubnetGroups=$(BUILD_TRUSTED_SUBNET_GROUPS)'
COMMON_LDFLAGS = $(COMMON_BUILD_VARS) -extldflags '-O2'
.PHONY: all build-go build-ui \
build-sh build-sh-api build-sh-api-noembed build-sh-metadata build-sh-grafana build-sh-balancer \
build-sh-ui build-grafana-ui
all: build-ui build-go # order important
build-go: build-sh build-sh-api build-sh-metadata build-sh-grafana build-sh-balancer build-igp build-agg
build-ui: build-sh-ui build-grafana-ui
build-main-daemons: build-sh build-sh-api build-sh-metadata build-sh-balancer build-igp build-agg
# to build tools for running on adm512, disable cgo
# CGO_ENABLED=0 go build ...
build-sh:
CGO_ENABLED=0 go build -ldflags "$(COMMON_LDFLAGS)" -buildvcs=false -o target/statshouse ./cmd/statshouse
build-sh-api:
rm -rf cmd/statshouse-api/build || true # remove old dir from previous builds
CGO_ENABLED=0 go build -tags embed -ldflags "$(COMMON_LDFLAGS)" -buildvcs=false -o target/statshouse-api ./cmd/statshouse-api
build-sh-api-noembed:
rm -rf cmd/statshouse-api/build || true # remove old dir from previous builds
CGO_ENABLED=0 go build -ldflags "$(COMMON_LDFLAGS)" -buildvcs=false -o target/statshouse-api ./cmd/statshouse-api
build-sh-metadata:
go build -ldflags "$(COMMON_LDFLAGS)" -buildvcs=false -o target/statshouse-metadata ./cmd/statshouse-metadata
build-igp:
CGO_ENABLED=0 go build -ldflags "$(COMMON_LDFLAGS)" -buildvcs=false -o target/statshouse-igp ./cmd/statshouse-igp
build-agg:
go build -ldflags "$(COMMON_LDFLAGS)" -buildvcs=false -o target/statshouse-agg ./cmd/statshouse-agg
build-sh-grafana:
go build -ldflags "$(COMMON_LDFLAGS)" -buildvcs=false -o target/statshouse-grafana-plugin ./cmd/statshouse-grafana-plugin
build-sh-balancer:
CGO_ENABLED=0 go build -ldflags "$(COMMON_LDFLAGS)" -buildvcs=false -o target/statshouse-balancer ./cmd/statshouse-balancer
build-sh-ui:
cd statshouse-ui && npm clean-install && NODE_ENV=production REACT_APP_BUILD_VERSION=$(REACT_APP_BUILD_VERSION) npm run build
build-grafana-ui:
cd grafana-plugin-ui && npm clean-install && npm run build
build-deb:
./build/makedeb.sh
.PHONY: gen
gen: gen-tl gen-easyjson gen-yaml
gen-tl: ./internal/data_model/api.tl ./internal/data_model/common.tl ./internal/data_model/engine.tl ./internal/data_model/metadata.tl ./internal/data_model/public.tl ./internal/data_model/schema.tl
$(TL_GEN) --language=go --outdir=./internal/data_model/gen2 -v \
--generateRPCCode=true \
--pkgPath=github.com/VKCOM/statshouse/internal/data_model/gen2/tl \
--basicPkgPath=github.com/VKCOM/statshouse/internal/vkgo/basictl \
--basicRPCPath=github.com/VKCOM/tl/pkg/rpc \
--generateRandomCode \
--generateByteVersions=$(TL_BYTE_VERSIONS) \
--rawHandlerWhiteList=statshouse.,metadata. \
--copyrightPath=./copyright \
--tl2WhiteList=statshouseApi. \
./internal/data_model/api.tl \
./internal/data_model/common.tl \
./internal/data_model/engine.tl \
./internal/data_model/metadata.tl \
./internal/data_model/public.tl \
./internal/data_model/schema.tl
@echo "Checking that generated code actually compiles..."
@go build ./internal/data_model/gen2/...
# --tl2-generate \
# --tl2WhiteList=statshouse.,statshouseApi.,metadata. \
# --tl2-migration-file=internal/data_model \
# --tl2-migration-by-namespaces \
# --tl2-continuous-migration \
# --tl2-migration-whitelist=statshouse.,metadata. \
gen-tl2:
$(TL_GEN) --language=go --outdir=./internal/data_model/gen2 -v \
--generateRPCCode=true \
--pkgPath=github.com/VKCOM/statshouse/internal/data_model/gen2/tl \
--basicPkgPath=github.com/VKCOM/statshouse/internal/vkgo/basictl \
--basicRPCPath=github.com/VKCOM/tl/pkg/rpc \
--generateRandomCode \
--generateByteVersions=$(TL_BYTE_VERSIONS) \
--rawHandlerWhiteList=statshouse.,metadata. \
--tl2WhiteList=statshouse.,statshouseApi.,metadata. \
--tl2-generate \
--copyrightPath=./copyright \
./internal/data_model/api.tl \
./internal/data_model/common.tl \
./internal/data_model/engine.tl \
./internal/data_model/namespaces/__common_namespace.tl2 \
./internal/data_model/namespaces/metadata.tl2 \
./internal/data_model/namespaces/statshouse.tl2
@echo "Checking that generated code actually compiles..."
@go build ./internal/data_model/gen2/...
# we now copy those files from vkgo together with the rest of sqlitev2 engine
#gen-sqlite: ./internal/data_model/common.tl ./internal/sqlitev2/checkpoint/metainfo.tl
# go run github.com/vkcom/tl/cmd/tlgen@v1.2.19 --language=go --outdir=./internal/sqlitev2/checkpoint/gen2 -v \
# --generateRPCCode=true \
# --pkgPath=github.com/VKCOM/statshouse/internal/sqlitev2/checkpoint/gen2/tl \
# --basicPkgPath=github.com/VKCOM/statshouse/internal/vkgo/basictl \
# --basicRPCPath=github.com/VKCOM/tl/pkg/rpc \
# --generateByteVersions=sqlite. \
# --copyrightPath=./copyright \
# ./internal/data_model/common.tl \
# ./internal/sqlitev2/checkpoint/metainfo.tl
# @echo "Checking that generated code actually compiles..."
# @go build ./internal/sqlitev2/checkpoint/gen2/...
gen-easyjson: ./internal/format/format.go ./internal/api/handler.go ./internal/api/httputil.go
@echo "you may need to install easyjson version: go install github.com/mailru/easyjson/...@latest"
go generate ./internal/api/handler.go
go generate ./internal/format/format.go
gen-yaml: ./internal/promql/parser/parse.y
@echo "you may need to install yaml version: go install gopkg.in/yaml.v2/...@latest"
go generate ./internal/promql/parser/...
.PHONY: lint test check
lint:
go run honnef.co/go/tools/cmd/staticcheck@v0.6.1 -version
go run honnef.co/go/tools/cmd/staticcheck@v0.6.1 ./...
test:
CGO_LDFLAGS="-w" go test -race ./...
# only tests that run local ClickHouse
test-integration:
CGO_LDFLAGS="-w" go test -v -race -tags integration -run '.*Integration' ./...
check: lint test
upgrade_mod:
# commented those, which need code regeneration
go get -u github.com/ClickHouse/ch-go
go get -u github.com/ClickHouse/clickhouse-go/v2
go get -u github.com/VKCOM/statshouse-go
go get -u github.com/cloudflare/tableflip
go get -u github.com/dchest/siphash
go get -u github.com/dgryski/go-maglev
go get -u github.com/fsnotify/fsnotify
go get -u github.com/go-kit/log
go get -u github.com/gogo/protobuf
go get -u github.com/golang-jwt/jwt/v4
go get -u github.com/google/btree
go get -u github.com/google/go-cmp
go get -u github.com/google/uuid
go get -u github.com/gorilla/handlers
go get -u github.com/gorilla/mux
go get -u github.com/gotd/ige
go get -u github.com/hrissan/tdigest
go get -u github.com/mailru/easyjson
go get -u github.com/petar/GoLLRB
go get -u github.com/pierrec/lz4
go get -u github.com/pkg/errors
go get -u github.com/prometheus/procfs
go get -u github.com/spf13/pflag
go get -u github.com/stretchr/testify
go get -u github.com/tinylib/msgp
go get -u github.com/xi2/xz
go get -u github.com/zeebo/xxh3
go get -u go.uber.org/atomic
go get -u go.uber.org/multierr
go get -u go4.org/mem
go get -u golang.org/x/crypto golang.org/x/exp golang.org/x/sync golang.org/x/sys
go get -u google.golang.org/protobuf
go get -u gopkg.in/yaml.v2
go get -u pgregory.net/rand
go get -u pgregory.net/rapid
go get -u github.com/grafana/grafana-plugin-sdk-go
go get -u k8s.io/apimachinery
go get -u github.com/testcontainers/testcontainers-go github.com/testcontainers/testcontainers-go/modules/clickhouse
# updating prometheus breaks our promql engine
# go get -u github.com/prometheus/common github.com/prometheus/prometheus
go get go@1.24
go mod tidy
@echo "you may need to regenerate code with make gen if packages with code generation changed, which might require 'go install' appropriate tools (yes what morons designed this)"