Update common Prometheus files (#1064)
Signed-off-by: prombot <prometheus-team@googlegroups.com>
This commit is contained in:
parent
2c3d072cdd
commit
ebd77f0360
|
@ -36,29 +36,6 @@ GO_VERSION ?= $(shell $(GO) version)
|
||||||
GO_VERSION_NUMBER ?= $(word 3, $(GO_VERSION))
|
GO_VERSION_NUMBER ?= $(word 3, $(GO_VERSION))
|
||||||
PRE_GO_111 ?= $(shell echo $(GO_VERSION_NUMBER) | grep -E 'go1\.(10|[0-9])\.')
|
PRE_GO_111 ?= $(shell echo $(GO_VERSION_NUMBER) | grep -E 'go1\.(10|[0-9])\.')
|
||||||
|
|
||||||
GOVENDOR :=
|
|
||||||
GO111MODULE :=
|
|
||||||
ifeq (, $(PRE_GO_111))
|
|
||||||
ifneq (,$(wildcard go.mod))
|
|
||||||
# Enforce Go modules support just in case the directory is inside GOPATH (and for Travis CI).
|
|
||||||
GO111MODULE := on
|
|
||||||
|
|
||||||
ifneq (,$(wildcard vendor))
|
|
||||||
# Always use the local vendor/ directory to satisfy the dependencies.
|
|
||||||
GOOPTS := $(GOOPTS) -mod=vendor
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
ifneq (,$(wildcard go.mod))
|
|
||||||
ifneq (,$(wildcard vendor))
|
|
||||||
$(warning This repository requires Go >= 1.11 because of Go modules)
|
|
||||||
$(warning Some recipes may not work as expected as the current Go runtime is '$(GO_VERSION_NUMBER)')
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
# This repository isn't using Go modules (yet).
|
|
||||||
GOVENDOR := $(FIRST_GOPATH)/bin/govendor
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
PROMU := $(FIRST_GOPATH)/bin/promu
|
PROMU := $(FIRST_GOPATH)/bin/promu
|
||||||
pkgs = ./...
|
pkgs = ./...
|
||||||
|
|
||||||
|
@ -150,11 +127,7 @@ common-check_license:
|
||||||
.PHONY: common-deps
|
.PHONY: common-deps
|
||||||
common-deps:
|
common-deps:
|
||||||
@echo ">> getting dependencies"
|
@echo ">> getting dependencies"
|
||||||
ifdef GO111MODULE
|
$(GO) mod download
|
||||||
GO111MODULE=$(GO111MODULE) $(GO) mod download
|
|
||||||
else
|
|
||||||
$(GO) get $(GOOPTS) -t ./...
|
|
||||||
endif
|
|
||||||
|
|
||||||
.PHONY: update-go-deps
|
.PHONY: update-go-deps
|
||||||
update-go-deps:
|
update-go-deps:
|
||||||
|
@ -162,20 +135,17 @@ update-go-deps:
|
||||||
@for m in $$($(GO) list -mod=readonly -m -f '{{ if and (not .Indirect) (not .Main)}}{{.Path}}{{end}}' all); do \
|
@for m in $$($(GO) list -mod=readonly -m -f '{{ if and (not .Indirect) (not .Main)}}{{.Path}}{{end}}' all); do \
|
||||||
$(GO) get -d $$m; \
|
$(GO) get -d $$m; \
|
||||||
done
|
done
|
||||||
GO111MODULE=$(GO111MODULE) $(GO) mod tidy
|
$(GO) mod tidy
|
||||||
ifneq (,$(wildcard vendor))
|
|
||||||
GO111MODULE=$(GO111MODULE) $(GO) mod vendor
|
|
||||||
endif
|
|
||||||
|
|
||||||
.PHONY: common-test-short
|
.PHONY: common-test-short
|
||||||
common-test-short: $(GOTEST_DIR)
|
common-test-short: $(GOTEST_DIR)
|
||||||
@echo ">> running short tests"
|
@echo ">> running short tests"
|
||||||
GO111MODULE=$(GO111MODULE) $(GOTEST) -short $(GOOPTS) $(pkgs)
|
$(GOTEST) -short $(GOOPTS) $(pkgs)
|
||||||
|
|
||||||
.PHONY: common-test
|
.PHONY: common-test
|
||||||
common-test: $(GOTEST_DIR)
|
common-test: $(GOTEST_DIR)
|
||||||
@echo ">> running all tests"
|
@echo ">> running all tests"
|
||||||
GO111MODULE=$(GO111MODULE) $(GOTEST) $(test-flags) $(GOOPTS) $(pkgs)
|
$(GOTEST) $(test-flags) $(GOOPTS) $(pkgs)
|
||||||
|
|
||||||
$(GOTEST_DIR):
|
$(GOTEST_DIR):
|
||||||
@mkdir -p $@
|
@mkdir -p $@
|
||||||
|
@ -183,25 +153,21 @@ $(GOTEST_DIR):
|
||||||
.PHONY: common-format
|
.PHONY: common-format
|
||||||
common-format:
|
common-format:
|
||||||
@echo ">> formatting code"
|
@echo ">> formatting code"
|
||||||
GO111MODULE=$(GO111MODULE) $(GO) fmt $(pkgs)
|
$(GO) fmt $(pkgs)
|
||||||
|
|
||||||
.PHONY: common-vet
|
.PHONY: common-vet
|
||||||
common-vet:
|
common-vet:
|
||||||
@echo ">> vetting code"
|
@echo ">> vetting code"
|
||||||
GO111MODULE=$(GO111MODULE) $(GO) vet $(GOOPTS) $(pkgs)
|
$(GO) vet $(GOOPTS) $(pkgs)
|
||||||
|
|
||||||
.PHONY: common-lint
|
.PHONY: common-lint
|
||||||
common-lint: $(GOLANGCI_LINT)
|
common-lint: $(GOLANGCI_LINT)
|
||||||
ifdef GOLANGCI_LINT
|
ifdef GOLANGCI_LINT
|
||||||
@echo ">> running golangci-lint"
|
@echo ">> running golangci-lint"
|
||||||
ifdef GO111MODULE
|
|
||||||
# 'go list' needs to be executed before staticcheck to prepopulate the modules cache.
|
# 'go list' needs to be executed before staticcheck to prepopulate the modules cache.
|
||||||
# Otherwise staticcheck might fail randomly for some reason not yet explained.
|
# Otherwise staticcheck might fail randomly for some reason not yet explained.
|
||||||
GO111MODULE=$(GO111MODULE) $(GO) list -e -compiled -test=true -export=false -deps=true -find=false -tags= -- ./... > /dev/null
|
$(GO) list -e -compiled -test=true -export=false -deps=true -find=false -tags= -- ./... > /dev/null
|
||||||
GO111MODULE=$(GO111MODULE) $(GOLANGCI_LINT) run $(GOLANGCI_LINT_OPTS) $(pkgs)
|
$(GOLANGCI_LINT) run $(GOLANGCI_LINT_OPTS) $(pkgs)
|
||||||
else
|
|
||||||
$(GOLANGCI_LINT) run $(pkgs)
|
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
.PHONY: common-yamllint
|
.PHONY: common-yamllint
|
||||||
|
@ -218,28 +184,15 @@ endif
|
||||||
common-staticcheck: lint
|
common-staticcheck: lint
|
||||||
|
|
||||||
.PHONY: common-unused
|
.PHONY: common-unused
|
||||||
common-unused: $(GOVENDOR)
|
common-unused:
|
||||||
ifdef GOVENDOR
|
|
||||||
@echo ">> running check for unused packages"
|
|
||||||
@$(GOVENDOR) list +unused | grep . && exit 1 || echo 'No unused packages'
|
|
||||||
else
|
|
||||||
ifdef GO111MODULE
|
|
||||||
@echo ">> running check for unused/missing packages in go.mod"
|
@echo ">> running check for unused/missing packages in go.mod"
|
||||||
GO111MODULE=$(GO111MODULE) $(GO) mod tidy
|
$(GO) mod tidy
|
||||||
ifeq (,$(wildcard vendor))
|
|
||||||
@git diff --exit-code -- go.sum go.mod
|
@git diff --exit-code -- go.sum go.mod
|
||||||
else
|
|
||||||
@echo ">> running check for unused packages in vendor/"
|
|
||||||
GO111MODULE=$(GO111MODULE) $(GO) mod vendor
|
|
||||||
@git diff --exit-code -- go.sum go.mod vendor/
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
.PHONY: common-build
|
.PHONY: common-build
|
||||||
common-build: promu
|
common-build: promu
|
||||||
@echo ">> building binaries"
|
@echo ">> building binaries"
|
||||||
GO111MODULE=$(GO111MODULE) $(PROMU) build --prefix $(PREFIX) $(PROMU_BINARIES)
|
$(PROMU) build --prefix $(PREFIX) $(PROMU_BINARIES)
|
||||||
|
|
||||||
.PHONY: common-tarball
|
.PHONY: common-tarball
|
||||||
common-tarball: promu
|
common-tarball: promu
|
||||||
|
@ -295,12 +248,6 @@ $(GOLANGCI_LINT):
|
||||||
| sh -s -- -b $(FIRST_GOPATH)/bin $(GOLANGCI_LINT_VERSION)
|
| sh -s -- -b $(FIRST_GOPATH)/bin $(GOLANGCI_LINT_VERSION)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef GOVENDOR
|
|
||||||
.PHONY: $(GOVENDOR)
|
|
||||||
$(GOVENDOR):
|
|
||||||
GOOS= GOARCH= $(GO) get -u github.com/kardianos/govendor
|
|
||||||
endif
|
|
||||||
|
|
||||||
.PHONY: precheck
|
.PHONY: precheck
|
||||||
precheck::
|
precheck::
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue