diff --git a/.circleci/config.yml b/.circleci/config.yml index 806701a41e..754c575bd3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -16,7 +16,7 @@ jobs: steps: - checkout - run: make promu - - run: make check_license staticcheck style unused build + - run: make check_license style unused staticcheck build - run: git diff --exit-code - store_artifacts: path: prometheus diff --git a/.travis.yml b/.travis.yml index 46b819079a..c6c4eafa97 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,5 +10,5 @@ go: go_import_path: github.com/prometheus/prometheus script: -- make check_license staticcheck style unused test +- make check_license style unused test staticcheck - git diff --exit-code diff --git a/Makefile.common b/Makefile.common index 3159def4ae..e05bb6ae72 100644 --- a/Makefile.common +++ b/Makefile.common @@ -45,7 +45,6 @@ $(warning Some recipes may not work as expected as the current Go runtime is '$( else # This repository isn't using Go modules (yet). GOVENDOR := $(FIRST_GOPATH)/bin/govendor - STATICCHECK := $(FIRST_GOPATH)/bin/staticcheck GO111MODULE := auto endif PROMU := $(FIRST_GOPATH)/bin/promu @@ -108,16 +107,15 @@ common-vet: .PHONY: common-staticcheck common-staticcheck: $(STATICCHECK) @echo ">> running staticcheck" -ifdef STATICCHECK - GO111MODULE=off $(STATICCHECK) -ignore "$(STATICCHECK_IGNORE)" $(pkgs) +ifeq (,$(wildcard go.mod)) + $(STATICCHECK) -ignore "$(STATICCHECK_IGNORE)" $(pkgs) else - GO111MODULE=$(GO111MODULE) $(GO) install -v $(GOOPTS) honnef.co/go/tools/cmd/staticcheck - $(FIRST_GOPATH)/bin/staticcheck -ignore "$(STATICCHECK_IGNORE)" -checks "SA*" $(pkgs) + GO111MODULE=$(GO111MODULE) $(GO) run $(GOOPTS) honnef.co/go/tools/cmd/staticcheck -ignore "$(STATICCHECK_IGNORE)" -checks "SA*" $(pkgs) endif .PHONY: common-unused common-unused: $(GOVENDOR) -ifdef GOVENDOR +ifeq (,$(wildcard go.mod)) @echo ">> running check for unused packages" @$(GOVENDOR) list +unused | grep . && exit 1 || echo 'No unused packages' else @@ -155,7 +153,7 @@ common-docker-tag-latest: promu: GOOS= GOARCH= GO111MODULE=off $(GO) get -u github.com/prometheus/promu -ifneq (,$(wildcard go.mod)) +ifeq (,$(wildcard go.mod)) .PHONY: $(STATICCHECK) $(STATICCHECK): GOOS= GOARCH= GO111MODULE=off $(GO) get -u honnef.co/go/tools/cmd/staticcheck diff --git a/util/tools/tools.go b/util/tools/tools.go new file mode 100644 index 0000000000..e9a42456d6 --- /dev/null +++ b/util/tools/tools.go @@ -0,0 +1,24 @@ +// Copyright 2018 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Imports of tools we want "go mod vendor" to include. +// https://github.com/golang/go/issues/25624#issuecomment-395556484 +// https://github.com/golang/go/issues/25922 + +// +build tools + +package tools + +import ( + _ "honnef.co/go/tools/cmd/staticcheck" +)