@@ -7,7 +7,6 @@ WIRE_TAGS = "oss"
7
7
-include local/Makefile
8
8
include .bingo/Variables.mk
9
9
10
- .PHONY : all deps-go deps-js deps build-go build-backend build-server build-cli build-js build build-docker-full build-docker-full-ubuntu lint-go golangci-lint test-go test-js gen-ts test run run-frontend clean devenv devenv-down protobuf drone help gen-go gen-cue fix-cue gen-feature-toggles
11
10
12
11
GO = go
13
12
GO_FILES ?= ./pkg/... ./pkg/apiserver/... ./pkg/apimachinery/... ./pkg/promlib/...
@@ -19,17 +18,22 @@ targets := $(shell echo '$(sources)' | tr "," " ")
19
18
20
19
GO_INTEGRATION_TESTS := $(shell find ./pkg -type f -name '* _test.go' -exec grep -l '^func TestIntegration' '{}' '+' | grep -o '\(.* \) /' | sort -u)
21
20
21
+ .PHONY : all
22
22
all : deps build
23
23
24
24
# #@ Dependencies
25
25
26
+ .PHONY : deps-go
26
27
deps-go : # # Install backend dependencies.
27
28
$(GO ) run build.go setup
28
29
30
+ .PHONY : deps-js
29
31
deps-js : node_modules # # Install frontend dependencies.
30
32
33
+ .PHONY : deps
31
34
deps : deps-js # # Install all dependencies.
32
35
36
+ .PHONY : node_modules
33
37
node_modules : package.json yarn.lock # # Install node modules.
34
38
@echo " install frontend dependencies"
35
39
YARN_ENABLE_PROGRESS_BARS=false yarn install --immutable
@@ -47,6 +51,7 @@ $(MERGED_SPEC_TARGET): swagger-oss-gen swagger-enterprise-gen $(NGALERT_SPEC_TAR
47
51
# known conflicts DsPermissionType, AddApiKeyCommand, Json, Duration (identical models referenced by both specs)
48
52
$(SWAGGER ) mixin -q $(SPEC_TARGET ) $(ENTERPRISE_SPEC_TARGET ) $(NGALERT_SPEC_TARGET ) --ignore-conflicts -o $(MERGED_SPEC_TARGET )
49
53
54
+ .PHONY : swagger-oss-gen
50
55
swagger-oss-gen : $(SWAGGER ) # # Generate API Swagger specification
51
56
@echo " re-generating swagger for OSS"
52
57
rm -f $(SPEC_TARGET )
@@ -58,6 +63,7 @@ swagger-oss-gen: $(SWAGGER) ## Generate API Swagger specification
58
63
--exclude-tag=enterprise
59
64
60
65
# this file only exists if enterprise is enabled
66
+ .PHONY : swagger-enterprise-gen
61
67
ENTERPRISE_EXT_FILE = pkg/extensions/ext.go
62
68
ifeq ("$(wildcard $(ENTERPRISE_EXT_FILE ) ) ","") # # if enterprise is not enabled
63
69
swagger-enterprise-gen :
@@ -74,11 +80,14 @@ swagger-enterprise-gen: $(SWAGGER) ## Generate API Swagger specification
74
80
--include-tag=enterprise
75
81
endif
76
82
83
+ .PHONY : swagger-gen
77
84
swagger-gen : gen-go $(MERGED_SPEC_TARGET ) swagger-validate
78
85
86
+ .PHONY : swagger-validate
79
87
swagger-validate : $(MERGED_SPEC_TARGET ) $(SWAGGER ) # # Validate API spec
80
88
$(SWAGGER ) validate --skip-warnings $(< )
81
89
90
+ .PHONY : swagger-clean
82
91
swagger-clean :
83
92
rm -f $(SPEC_TARGET ) $(MERGED_SPEC_TARGET ) $(OAPI_SPEC_TARGET )
84
93
@@ -97,15 +106,18 @@ lefthook-uninstall: $(LEFTHOOK)
97
106
# #@ OpenAPI 3
98
107
OAPI_SPEC_TARGET = public/openapi3.json
99
108
109
+ .PHONY : openapi3-gen
100
110
openapi3-gen : swagger-gen # # Generates OpenApi 3 specs from the Swagger 2 already generated
101
111
$(GO ) run scripts/openapi3/openapi3conv.go $(MERGED_SPEC_TARGET ) $(OAPI_SPEC_TARGET )
102
112
103
113
# #@ Building
114
+ .PHONY : gen-cue
104
115
gen-cue : # # Do all CUE/Thema code generation
105
116
@echo " generate code from .cue files"
106
117
go generate ./kinds/gen.go
107
118
go generate ./public/app/plugins/gen.go
108
119
120
+ .PHONY : gen-feature-toggles
109
121
gen-feature-toggles :
110
122
# # First go test run fails because it will re-generate the feature toggles.
111
123
# # Second go test run will compare the generated files and pass.
@@ -117,41 +129,50 @@ gen-feature-toggles:
117
129
go test -v ./pkg/services/featuremgmt/...; \
118
130
fi
119
131
132
+ .PHONY : gen-go
120
133
gen-go :
121
134
@echo " generate go files"
122
135
$(GO ) run ./pkg/build/wire/cmd/wire/main.go gen -tags $(WIRE_TAGS ) ./pkg/server
123
136
137
+ .PHONY : fix-cue
124
138
fix-cue : $(CUE )
125
139
@echo " formatting cue files"
126
140
$(CUE ) fix kinds/** /* .cue
127
141
$(CUE ) fix public/app/plugins/** /** /* .cue
128
142
143
+ .PHONY : gen-jsonnet
129
144
gen-jsonnet :
130
145
go generate ./devenv/jsonnet
131
146
147
+ .PHONY : build-go
132
148
build-go : gen-go # # Build all Go binaries.
133
149
@echo " build go files"
134
150
$(GO ) run build.go $(GO_BUILD_FLAGS ) build
135
151
152
+ .PHONY : build-backend
136
153
build-backend : # # Build Grafana backend.
137
154
@echo " build backend"
138
155
$(GO ) run build.go $(GO_BUILD_FLAGS ) build-backend
139
156
157
+ .PHONY : build-server
140
158
build-server : # # Build Grafana server.
141
159
@echo " build server"
142
160
$(GO ) run build.go $(GO_BUILD_FLAGS ) build-server
143
161
162
+ .PHONY : build-cli
144
163
build-cli : # # Build Grafana CLI application.
145
164
@echo " build grafana-cli"
146
165
$(GO ) run build.go $(GO_BUILD_FLAGS ) build-cli
147
166
167
+ .PHONY : build-js
148
168
build-js : # # Build frontend assets.
149
169
@echo " build frontend"
150
170
yarn run build
151
171
yarn run plugins:build-bundled
152
172
153
173
PLUGIN_ID ?=
154
174
175
+ .PHONY : build-plugin-go
155
176
build-plugin-go : # # Build decoupled plugins
156
177
@echo " build plugin $( PLUGIN_ID) "
157
178
@cd pkg/tsdb; \
@@ -161,11 +182,14 @@ build-plugin-go: ## Build decoupled plugins
161
182
fi ; \
162
183
mage -v buildplugin $(PLUGIN_ID )
163
184
185
+ .PHONY : build
164
186
build : build-go build-js # # Build backend and frontend.
165
187
188
+ .PHONY : run
166
189
run : $(BRA ) # # Build and run web server on filesystem changes.
167
190
$(BRA ) run
168
191
192
+ .PHONY : run-frontend
169
193
run-frontend : deps-js # # Fetch js dependencies and watch frontend for rebuild
170
194
yarn start
171
195
@@ -217,22 +241,27 @@ test-go-integration-memcached: ## Run integration tests for memcached cache.
217
241
$(GO ) clean -testcache
218
242
MEMCACHED_HOSTS=localhost:11211 $(GO ) test -run IntegrationMemcached -covermode=atomic -timeout=2m $(GO_INTEGRATION_TESTS )
219
243
244
+ .PHONY : test-js
220
245
test-js : # # Run tests for frontend.
221
246
@echo " test frontend"
222
247
yarn test
223
248
249
+ .PHONY : test
224
250
test : test-go test-js # # Run all tests.
225
251
226
252
# #@ Linting
253
+ .PHONY : golangci-lint
227
254
golangci-lint : $(GOLANGCI_LINT )
228
255
@echo " lint via golangci-lint"
229
256
$(GOLANGCI_LINT ) run \
230
257
--config .golangci.toml \
231
258
$(GO_FILES )
232
259
260
+ .PHONY : lint-go
233
261
lint-go : golangci-lint # # Run all code checks for backend. You can use GO_FILES to specify exact files to check
234
262
235
263
# with disabled SC1071 we are ignored some TCL,Expect `/usr/bin/env expect` scripts
264
+ .PHONY : shellcheck
236
265
shellcheck : $(SH_FILES ) # # Run checks for shell scripts.
237
266
@docker run --rm -v " $$ PWD:/mnt" koalaman/shellcheck:stable \
238
267
$(SH_FILES ) -e SC1071 -e SC2162
@@ -242,6 +271,7 @@ shellcheck: $(SH_FILES) ## Run checks for shell scripts.
242
271
TAG_SUFFIX =$(if $(WIRE_TAGS ) !=oss,-$(WIRE_TAGS ) )
243
272
PLATFORM =linux/amd64
244
273
274
+ .PHONY : build-docker-full
245
275
build-docker-full : # # Build Docker image for development.
246
276
@echo " build docker container"
247
277
tar -ch . | \
@@ -255,6 +285,7 @@ build-docker-full: ## Build Docker image for development.
255
285
--tag grafana/grafana$(TAG_SUFFIX ) :dev \
256
286
$(DOCKER_BUILD_ARGS )
257
287
288
+ .PHONY : build-docker-full-ubuntu
258
289
build-docker-full-ubuntu : # # Build Docker image based on Ubuntu for development.
259
290
@echo " build docker container"
260
291
tar -ch . | \
@@ -274,6 +305,7 @@ build-docker-full-ubuntu: ## Build Docker image based on Ubuntu for development.
274
305
275
306
# create docker-compose file with provided sources and start them
276
307
# example: make devenv sources=postgres,auth/openldap
308
+ .PHONY : devenv
277
309
ifeq ($(sources ) ,)
278
310
devenv :
279
311
@printf ' You have to define sources for this command \nexample: make devenv sources=postgres,openldap\n'
@@ -287,15 +319,18 @@ devenv: devenv-down ## Start optional services, e.g. postgres, prometheus, and e
287
319
docker-compose up -d --build
288
320
endif
289
321
322
+ .PHONY : devenv-down
290
323
devenv-down : # # Stop optional services.
291
324
@cd devenv; \
292
325
test -f docker-compose.yaml && \
293
326
docker-compose down || exit 0;
294
327
328
+ .PHONY : devenv-postgres
295
329
devenv-postgres :
296
330
@cd devenv; \
297
331
sources=postgres_tests
298
332
333
+ .PHONY : devenv-mysql
299
334
devenv-mysql :
300
335
@cd devenv; \
301
336
sources=mysql_tests
@@ -307,18 +342,21 @@ devenv-mysql:
307
342
# go-gettable dependency and so getting it installed can be inconvenient.
308
343
#
309
344
# If you are working on changes to protobuf interfaces you may either use
310
- # this target or run the individual scripts below directly.
345
+ # this target or run the individual scripts below directly
346
+ .PHONY : protobuf
311
347
protobuf : # # Compile protobuf definitions
312
348
bash scripts/protobuf-check.sh
313
349
bash pkg/plugins/backendplugin/pluginextensionv2/generate.sh
314
350
bash pkg/plugins/backendplugin/secretsmanagerplugin/generate.sh
315
351
bash pkg/services/store/entity/generate.sh
316
352
353
+ .PHONY : clean
317
354
clean : # # Clean up intermediate build artifacts.
318
355
@echo " cleaning"
319
356
rm -rf node_modules
320
357
rm -rf public/build
321
358
359
+ .PHONY : gen-ts
322
360
gen-ts :
323
361
@echo " generating TypeScript definitions"
324
362
go get github.com/tkrajina/typescriptify-golang-structs/
[email protected]
@@ -328,18 +366,22 @@ gen-ts:
328
366
# This repository's configuration is protected (https://readme.drone.io/signature/).
329
367
# Use this make target to regenerate the configuration YAML files when
330
368
# you modify starlark files.
369
+ .PHONY : drone
331
370
drone : $(DRONE )
332
371
bash scripts/drone/env-var-check.sh
333
372
$(DRONE ) starlark --format
334
373
$(DRONE ) lint .drone.yml --trusted
335
374
$(DRONE ) --server https://drone.grafana.net sign --save grafana/grafana
336
375
337
376
# Generate an Emacs tags table (https://www.gnu.org/software/emacs/manual/html_node/emacs/Tags-Tables.html) for Starlark files.
377
+ .PHONY : scripts/drone/TAGS
338
378
scripts/drone/TAGS : $(shell find scripts/drone -name '* .star')
339
379
etags --lang none --regex=" /def \(\w+\)[^:]+:/\1/" --regex=" /\s*\(\w+\) =/\1/" $^ -o $@
340
380
381
+ .PHONY : format-drone
341
382
format-drone :
342
383
buildifier --lint=fix -r scripts/drone
343
384
385
+ .PHONY : help
344
386
help : # # Display this help.
345
387
@awk ' BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST )
0 commit comments