| 1 |
# Copyright 2018 The Prometheus Authors |
| 2 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 |
# you may not use this file except in compliance with the License. |
| 4 |
# You may obtain a copy of the License at |
| 5 |
# |
| 6 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 7 |
# |
| 8 |
# Unless required by applicable law or agreed to in writing, software |
| 9 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 10 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 |
# See the License for the specific language governing permissions and |
| 12 |
# limitations under the License. |
| 13 |
|
| 14 |
include Makefile.common |
| 15 |
|
| 16 |
BUF := $(FIRST_GOPATH)/bin/buf |
| 17 |
BUF_VERSION ?= v1.39.0 |
| 18 |
|
| 19 |
$(BUF): |
| 20 |
go install github.com/bufbuild/buf/cmd/buf@$(BUF_VERSION) |
| 21 |
|
| 22 |
.PHONY: deps |
| 23 |
deps: |
| 24 |
$(MAKE) common-deps |
| 25 |
cd exp && $(GO) mod tidy && $(GO) mod download |
| 26 |
|
| 27 |
.PHONY: test |
| 28 |
test: deps common-test test-exp |
| 29 |
|
| 30 |
.PHONY: test-short |
| 31 |
test-short: deps common-test-short test-exp-short |
| 32 |
|
| 33 |
.PHONY: generate-go-collector-test-files |
| 34 |
file := supported_go_versions.txt |
| 35 |
VERSIONS := $(shell cat ${file}) |
| 36 |
generate-go-collector-test-files: |
| 37 |
for GO_VERSION in $(VERSIONS); do \ |
| 38 |
docker run \ |
| 39 |
--platform linux/amd64 \ |
| 40 |
--rm -v $(PWD):/workspace \ |
| 41 |
-w /workspace \ |
| 42 |
golang:$$GO_VERSION \ |
| 43 |
bash ./generate-go-collector.bash; \ |
| 44 |
done; \ |
| 45 |
go mod tidy |
| 46 |
|
| 47 |
.PHONY: fmt |
| 48 |
fmt: common-format |
| 49 |
|
| 50 |
.PHONY: proto |
| 51 |
proto: ## Regenerate Go from remote write proto. |
| 52 |
proto: $(BUF) |
| 53 |
@echo ">> regenerating Prometheus Remote Write proto" |
| 54 |
@cd exp/api/remote/genproto && $(BUF) generate |
| 55 |
@cd exp/api/remote && find genproto/ -type f -exec sed -i '' 's/protohelpers "github.com\/planetscale\/vtprotobuf\/protohelpers"/protohelpers "github.com\/prometheus\/client_golang\/exp\/internal\/github.com\/planetscale\/vtprotobuf\/protohelpers"/g' {} \; |
| 56 |
# For some reasons buf generates this unused import, kill it manually for now and reformat. |
| 57 |
@cd exp/api/remote && find genproto/ -type f -exec sed -i '' 's/_ "github.com\/gogo\/protobuf\/gogoproto"//g' {} \; |
| 58 |
@cd exp/api/remote && go fmt ./genproto/... |
| 59 |
$(MAKE) fmt |
| 60 |
|
| 61 |
.PHONY: test-exp |
| 62 |
test-exp: |
| 63 |
cd exp && $(GOTEST) $(test-flags) $(GOOPTS) $(pkgs) |
| 64 |
|
| 65 |
.PHONY: test-exp-short |
| 66 |
test-exp-short: |
| 67 |
cd exp && $(GOTEST) -short $(GOOPTS) $(pkgs) |