From 24721e25178eacfb01667d95d07547717163b60a Mon Sep 17 00:00:00 2001 From: Ilya Dmitrichenko Date: Thu, 11 Oct 2018 15:58:44 +0100 Subject: [PATCH] Fallback to gometalinter in CircleCI for now --- .gometalinter.json | 15 +++++++++++++++ Makefile | 3 ++- build/install.sh | 30 +++++++++++++++++++++++++++++- 3 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 .gometalinter.json diff --git a/.gometalinter.json b/.gometalinter.json new file mode 100644 index 00000000000..a8e11d59913 --- /dev/null +++ b/.gometalinter.json @@ -0,0 +1,15 @@ +{ + "Enable": [ + "vet", + "golint", + "errcheck", + "deadcode" + ], + "Exclude": [ + "^vendor\/", + "^build\/", + "^pkg\/nodebootstrap\/assets.go", + "\/usr\/local\/go" + ], + "Deadline": "5m" +} \ No newline at end of file diff --git a/Makefile b/Makefile index fd463580fed..e2624db6c44 100644 --- a/Makefile +++ b/Makefile @@ -27,9 +27,10 @@ test: generate ## Run unit tests @go test -v -covermode=count -coverprofile=coverage.out ./pkg/... ./cmd/... @test -z $(COVERALLS_TOKEN) || $(GOPATH)/bin/goveralls -coverprofile=coverage.out -service=circle-ci +LINTER ?= gometalinter ./... .PHONY: lint lint: ## Run linter over the codebase - @$(GOPATH)/bin/golangci-lint run + @$(GOPATH)/bin/$(LINTER) .PHONY: ci ci: test lint ## Target for CI system to invoke to run tests and linting diff --git a/build/install.sh b/build/install.sh index 02c197f511e..59596dce1c3 100755 --- a/build/install.sh +++ b/build/install.sh @@ -6,4 +6,32 @@ go install ./vendor/golang.org/x/tools/cmd/stringer go install ./vendor/github.com/mattn/goveralls go install ./vendor/github.com/vektra/mockery/cmd/mockery -curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $GOPATH/bin v1.10.2 +# managing all linters that gometalinter uses with dep is going to take +# a lot of work, so we install all of those from the release tarball +install_gometalinter() { + version="${1}" + prefix="https://github.com/alecthomas/gometalinter/releases/download" + if [ "$(uname)" = "Darwin" ] ; then + suffix="darwin-amd64" + else + suffix="linux-amd64" + fi + basename="gometalinter-${version}-${suffix}" + url="${prefix}/v${version}/${basename}.tar.gz" + cd "${GOPATH}/bin/" + curl --silent --location "${url}" | tar xz + (cd "./${basename}/" ; mv ./* ../) + rmdir "./${basename}" + unset version prefix suffix basename url +} + +install_golangci_lint() { + version="${1}" + curl --silent --fail --location \ + "https://install.goreleaser.com/github.com/golangci/golangci-lint.sh" \ + | sh -s -- -b $GOPATH/bin "${version}" + unset version +} + +install_gometalinter "2.0.11" +install_golangci_lint "v1.10.2" \ No newline at end of file