From c36d8a46c8a31e744c50ba1e371f9e7bd4ea996d 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 | 8 +++++++- build/install.sh | 32 +++++++++++++++++++++++++++++++- 3 files changed, 53 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..de305af1090 100644 --- a/Makefile +++ b/Makefile @@ -27,9 +27,14 @@ 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 +ifeq ($(CIRCLECI),true) +LINTER := gometalinter ./... +else +LINTER := golangci-lint run +endif .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 @@ -94,6 +99,7 @@ eksctl-image: eksctl-build-image ## Create the eksctl image release: eksctl-build-image ## Create a new eksctl release @docker run \ --env=GITHUB_TOKEN \ + --env=CIRCLECI \ --env=CIRCLE_TAG \ --env=CIRCLE_PROJECT_USERNAME \ --volume=$(CURDIR):/go/src/github.com/weaveworks/eksctl \ diff --git a/build/install.sh b/build/install.sh index 02c197f511e..7b2ba21b7eb 100755 --- a/build/install.sh +++ b/build/install.sh @@ -6,4 +6,34 @@ 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" + +## golangci-lint is broken in CircleCI +test -n "${CIRCLECI:-}" || install_golangci_lint "v1.10.2" \ No newline at end of file