From 7997785237f8a40f01b0cf1bbec3cb5ce9989d82 Mon Sep 17 00:00:00 2001 From: Richard Case Date: Thu, 6 Sep 2018 15:49:47 +0100 Subject: [PATCH 1/2] Added linting A new make target has been added to run gometalinter. --- .gometalinter.json | 3 +++ Makefile | 13 +++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 .gometalinter.json diff --git a/.gometalinter.json b/.gometalinter.json new file mode 100644 index 0000000000..2b1bd4bf5e --- /dev/null +++ b/.gometalinter.json @@ -0,0 +1,3 @@ +{ + "Enable": ["vet", "golint", "errcheck", "deadcode"] + } \ No newline at end of file diff --git a/Makefile b/Makefile index ee0ecc7b10..2c541a2b70 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,19 @@ test: generate @go test -v -covermode=count -coverprofile=coverage.out ./pkg/... ./cmd/... @test -z $(COVERALLS_TOKEN) || goveralls -coverprofile=coverage.out -service=circle-ci +.PHONY: lint +lint: + gometalinter --exclude=^vendor\/ ./... + +.PHONY: install-lint-deps +install-lint-deps: + curl https://git.io/vp6lP | sh + gometalinter --install + +.PHONY: ci +ci: test lint + + .PHONY: integration-test-dev integration-test-dev: build @go test -tags integration -v -timeout 21m ./tests/integration/... \ From 94f9c6ef9e206e69402d98fde8c987dc8810bc8a Mon Sep 17 00:00:00 2001 From: Ilya Dmitrichenko Date: Wed, 12 Sep 2018 14:20:28 +0100 Subject: [PATCH 2/2] Wrap up gometalinter - make installation more deperministic - include it in the docker build - increase deadline to make it not timeout --- .gometalinter.json | 7 +++++-- Dockerfile | 2 +- Makefile | 7 +------ build/install.sh | 23 ++++++++++++++++++++++- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/.gometalinter.json b/.gometalinter.json index 2b1bd4bf5e..0d141be4cf 100644 --- a/.gometalinter.json +++ b/.gometalinter.json @@ -1,3 +1,6 @@ { - "Enable": ["vet", "golint", "errcheck", "deadcode"] - } \ No newline at end of file + "Errors": true, + "Enable": ["vet", "golint", "errcheck", "deadcode"], + "Exclude": ["^vendor\/", "^build\/"], + "Deadline": "5m" +} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 580a67cb0f..c0dd3f0fb1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,7 @@ ARG COVERALLS_TOKEN ENV COVERALLS_TOKEN $COVERALLS_TOKEN WORKDIR $EKSCTL -RUN make test && make \ +RUN make lint && make test && make \ && cp ./eksctl /out/usr/local/bin/eksctl RUN go build ./vendor/github.com/heptio/authenticator/cmd/heptio-authenticator-aws \ diff --git a/Makefile b/Makefile index 2c541a2b70..ea37412b6a 100644 --- a/Makefile +++ b/Makefile @@ -21,12 +21,7 @@ test: generate .PHONY: lint lint: - gometalinter --exclude=^vendor\/ ./... - -.PHONY: install-lint-deps -install-lint-deps: - curl https://git.io/vp6lP | sh - gometalinter --install + @gometalinter ./... .PHONY: ci ci: test lint diff --git a/build/install.sh b/build/install.sh index 0a1e28de25..0e4f2ec905 100755 --- a/build/install.sh +++ b/build/install.sh @@ -1,7 +1,28 @@ -#!/bin/sh +#!/bin/sh -eu go install ./vendor/github.com/jteeuwen/go-bindata/go-bindata go install ./vendor/github.com/weaveworks/github-release 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 + +# 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_gometalinter "2.0.11" \ No newline at end of file