mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 05:34:05 -08:00
More updates for libraries
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
parent
be68fb0f30
commit
5bd9010196
|
@ -29,23 +29,27 @@ GO ?= go
|
||||||
GOFMT ?= $(GO)fmt
|
GOFMT ?= $(GO)fmt
|
||||||
FIRST_GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH)))
|
FIRST_GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH)))
|
||||||
GOOPTS ?=
|
GOOPTS ?=
|
||||||
ifneq (,$(wildcard go.mod))
|
unexport GOVENDOR
|
||||||
ifeq ($(shell $(GO) version | grep -E 'go1\.(10|[0-9])\.'),)
|
ifeq ($(shell $(GO) version | grep -E 'go1\.(10|[0-9])\.'),)
|
||||||
ifneq (,$(wildcard vendor))
|
ifneq (,$(wildcard go.mod))
|
||||||
# Always use the local vendor/ directory to satisfy the dependencies.
|
# Enforce Go modules support just in case the directory is inside GOPATH (and for Travis CI).
|
||||||
GOOPTS := $(GOOPTS) -mod=vendor
|
GO111MODULE := on
|
||||||
endif
|
|
||||||
# Enable module support forcibly just in case the directory is inside GOPATH (and Travis CI).
|
|
||||||
GO111MODULE := on
|
|
||||||
|
|
||||||
unexport GOVENDOR
|
ifneq (,$(wildcard vendor))
|
||||||
|
# Always use the local vendor/ directory to satisfy the dependencies.
|
||||||
|
GOOPTS := $(GOOPTS) -mod=vendor
|
||||||
|
endif
|
||||||
|
endif
|
||||||
else
|
else
|
||||||
|
ifneq (,$(wildcard go.mod))
|
||||||
|
ifneq (,$(wildcard vendor))
|
||||||
$(warning This repository requires Go >= 1.11 because of Go modules)
|
$(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 '$(shell $(GO) version)')
|
$(warning Some recipes may not work as expected as the current Go runtime is '$(shell $(GO) version)')
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
# This repository isn't using Go modules (yet).
|
# This repository isn't using Go modules (yet).
|
||||||
GOVENDOR := $(FIRST_GOPATH)/bin/govendor
|
GOVENDOR := $(FIRST_GOPATH)/bin/govendor
|
||||||
|
endif
|
||||||
|
|
||||||
unexport GO111MODULE
|
unexport GO111MODULE
|
||||||
endif
|
endif
|
||||||
|
@ -110,7 +114,7 @@ common-vet:
|
||||||
.PHONY: common-staticcheck
|
.PHONY: common-staticcheck
|
||||||
common-staticcheck: $(STATICCHECK)
|
common-staticcheck: $(STATICCHECK)
|
||||||
@echo ">> running staticcheck"
|
@echo ">> running staticcheck"
|
||||||
ifeq (,$(wildcard go.mod))
|
ifndef GO111MODULE
|
||||||
$(STATICCHECK) -ignore "$(STATICCHECK_IGNORE)" $(pkgs)
|
$(STATICCHECK) -ignore "$(STATICCHECK_IGNORE)" $(pkgs)
|
||||||
else
|
else
|
||||||
$(STATICCHECK) -ignore "$(STATICCHECK_IGNORE)" -checks "SA*" $(pkgs)
|
$(STATICCHECK) -ignore "$(STATICCHECK_IGNORE)" -checks "SA*" $(pkgs)
|
||||||
|
@ -118,10 +122,11 @@ endif
|
||||||
|
|
||||||
.PHONY: common-unused
|
.PHONY: common-unused
|
||||||
common-unused: $(GOVENDOR)
|
common-unused: $(GOVENDOR)
|
||||||
ifeq (,$(wildcard go.mod))
|
ifdef GOVENDOR
|
||||||
@echo ">> running check for unused packages"
|
@echo ">> running check for unused packages"
|
||||||
@$(GOVENDOR) list +unused | grep . && exit 1 || echo 'No unused packages'
|
@$(GOVENDOR) list +unused | grep . && exit 1 || echo 'No unused packages'
|
||||||
else
|
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
|
GO111MODULE=$(GO111MODULE) $(GO) mod tidy
|
||||||
@git diff --exit-code -- go.sum go.mod
|
@git diff --exit-code -- go.sum go.mod
|
||||||
|
@ -131,6 +136,7 @@ ifneq (,$(wildcard vendor))
|
||||||
@git diff --exit-code -- go.sum go.mod vendor/
|
@git diff --exit-code -- go.sum go.mod vendor/
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
.PHONY: common-build
|
.PHONY: common-build
|
||||||
common-build: promu
|
common-build: promu
|
||||||
|
@ -160,10 +166,10 @@ promu:
|
||||||
|
|
||||||
.PHONY: $(STATICCHECK)
|
.PHONY: $(STATICCHECK)
|
||||||
$(STATICCHECK):
|
$(STATICCHECK):
|
||||||
ifneq (,$(wildcard go.mod))
|
ifdef GO111MODULE
|
||||||
# Get staticcheck from a temporary directory to avoid modifying the local go.{mod,sum}.
|
# Get staticcheck from a temporary directory to avoid modifying the local go.{mod,sum}.
|
||||||
# See https://github.com/golang/go/issues/27643.
|
# See https://github.com/golang/go/issues/27643.
|
||||||
# For now, we are using the next branch of staticcheck because master isn't compatible yet with Go modules.
|
# For now, we are using the next branch of staticcheck because master isn't compatible yet with Go modules.
|
||||||
tmpModule=$$(mktemp -d 2>&1) && \
|
tmpModule=$$(mktemp -d 2>&1) && \
|
||||||
mkdir -p $${tmpModule}/staticcheck && \
|
mkdir -p $${tmpModule}/staticcheck && \
|
||||||
cd "$${tmpModule}"/staticcheck && \
|
cd "$${tmpModule}"/staticcheck && \
|
||||||
|
@ -171,8 +177,10 @@ ifneq (,$(wildcard go.mod))
|
||||||
GO111MODULE=on GOOS= GOARCH= $(GO) get -u honnef.co/go/tools/cmd/staticcheck@next && \
|
GO111MODULE=on GOOS= GOARCH= $(GO) get -u honnef.co/go/tools/cmd/staticcheck@next && \
|
||||||
rm -rf $${tmpModule};
|
rm -rf $${tmpModule};
|
||||||
else
|
else
|
||||||
GOOS= GOARCH= $(GO) get -u honnef.co/go/tools/cmd/staticcheck
|
GOOS= GOARCH= GO111MODULE=off $(GO) get -u honnef.co/go/tools/cmd/staticcheck
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef GOVENDOR
|
||||||
.PHONY: $(GOVENDOR)
|
.PHONY: $(GOVENDOR)
|
||||||
$(GOVENDOR):
|
$(GOVENDOR):
|
||||||
GOOS= GOARCH= $(GO) get -u github.com/kardianos/govendor
|
GOOS= GOARCH= $(GO) get -u github.com/kardianos/govendor
|
||||||
|
|
Loading…
Reference in a new issue