mirror of
https://github.com/grafana/grafana.git
synced 2024-11-21 16:38:03 -06:00
Chore: Allow using the Go race detector locally (#88380)
* use the Go race detector for local testing only * add recipe to check if Go race detector is enabled
This commit is contained in:
parent
98152b2f84
commit
990ad860df
3
.gitignore
vendored
3
.gitignore
vendored
@ -216,3 +216,6 @@ public/app/plugins/**/dist/
|
||||
|
||||
# Go coverage files created with go test -cover -coverprogile=something.out ...
|
||||
*.out
|
||||
|
||||
# Locally enabling the Go race detector until we can globally do so
|
||||
.go-race-enabled-locally
|
||||
|
19
Makefile
19
Makefile
@ -12,8 +12,10 @@ GO = go
|
||||
GO_VERSION = 1.22.3
|
||||
GO_FILES ?= ./pkg/... ./pkg/apiserver/... ./pkg/apimachinery/... ./pkg/promlib/...
|
||||
SH_FILES ?= $(shell find ./scripts -name *.sh)
|
||||
GO_RACE := $(shell [ -n "$(GO_BUILD_DEV)$(GO_RACE)" -o -e ".go-race-enabled-locally" ] && echo 1 )
|
||||
GO_BUILD_FLAGS += $(if $(GO_BUILD_DEV),-dev)
|
||||
GO_BUILD_FLAGS += $(if $(GO_BUILD_TAGS),-build-tags=$(GO_BUILD_TAGS))
|
||||
GO_BUILD_FLAGS += $(if $(GO_RACE),-race)
|
||||
|
||||
targets := $(shell echo '$(sources)' | tr "," " ")
|
||||
|
||||
@ -209,6 +211,11 @@ build: build-go build-js ## Build backend and frontend.
|
||||
run: $(BRA) ## Build and run web server on filesystem changes.
|
||||
$(BRA) run
|
||||
|
||||
.PHONY: run-go
|
||||
run-go: ## Build and run web server immediately.
|
||||
$(GO) run -race $(if $(GO_BUILD_TAGS),-build-tags=$(GO_BUILD_TAGS)) \
|
||||
./pkg/cmd/grafana -- server -packaging=dev cfg:app_mode=development
|
||||
|
||||
.PHONY: run-frontend
|
||||
run-frontend: deps-js ## Fetch js dependencies and watch frontend for rebuild
|
||||
yarn start
|
||||
@ -404,6 +411,18 @@ scripts/drone/TAGS: $(shell find scripts/drone -name '*.star')
|
||||
format-drone:
|
||||
buildifier --lint=fix -r scripts/drone
|
||||
|
||||
.PHONY: go-race-is-enabled
|
||||
go-race-is-enabled:
|
||||
@if [ -n "$(GO_RACE)" ]; then \
|
||||
echo "The Go race detector is enabled locally, yey!"; \
|
||||
else \
|
||||
echo "The Go race detector is NOT enabled locally, boo!"; \
|
||||
fi;
|
||||
|
||||
.PHONY: enable-go-race
|
||||
enable-go-race:
|
||||
@touch .go-race-enabled-locally
|
||||
|
||||
.PHONY: help
|
||||
help: ## Display this help.
|
||||
@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)
|
||||
|
Loading…
Reference in New Issue
Block a user