From e7988f71f27e82e1dcb8d77c1a4553a684bb7587 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Fri, 15 Jun 2018 19:31:21 +0100 Subject: [PATCH] Switch travis to golangci-lint. Add user linting script --- scripts/build-test-lint.sh | 2 +- scripts/find-lint-ci.sh | 43 ++++++++++++++++++++++++++++++++++ scripts/find-lint.sh | 47 ++++---------------------------------- scripts/travis-test.sh | 4 ++-- vendor/manifest | 6 ----- 5 files changed, 50 insertions(+), 52 deletions(-) create mode 100755 scripts/find-lint-ci.sh diff --git a/scripts/build-test-lint.sh b/scripts/build-test-lint.sh index f283017fd..492aa1ae9 100755 --- a/scripts/build-test-lint.sh +++ b/scripts/build-test-lint.sh @@ -17,7 +17,7 @@ gb build echo "Double checking it builds..." go build github.com/matrix-org/dendrite/cmd/... -./scripts/find-lint.sh +./scripts/find-lint-ci.sh echo "Testing..." gb test diff --git a/scripts/find-lint-ci.sh b/scripts/find-lint-ci.sh new file mode 100755 index 000000000..421e71a20 --- /dev/null +++ b/scripts/find-lint-ci.sh @@ -0,0 +1,43 @@ +#! /bin/bash + +# Runs the linters against dendrite + +# The linters can take a lot of resources and are slow, so they can be +# configured using two environment variables: +# +# - `DENDRITE_LINT_CONCURRENCY` - number of concurrent linters to run, +# gometalinter defaults this to 8 +# - `DENDRITE_LINT_DISABLE_GC` - if set then the the go gc will be disabled +# when running the linters, speeding them up but using much more memory. + + +set -eux + +cd `dirname $0`/.. + +export GOPATH=$(pwd)/vendor + +args="" +if [ ${1:-""} = "fast" ] +then args="--config=linter-fast.json" +else args="--config=linter.json" +fi + +if [ -n "${DENDRITE_LINT_CONCURRENCY:-}" ] +then args="$args --concurrency=$DENDRITE_LINT_CONCURRENCY" +fi + +if [ -z "${DENDRITE_LINT_DISABLE_GC:-}" ] +then args="$args --enable-gc" +fi + +echo "Installing lint search engine..." +curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s v1.6.1 +go get github.com/client9/misspell/cmd/misspell +export GOPATH="$GOPATH:$(pwd)" + +echo "Looking for lint..." +golangci-lint run --max-same-issues 0 --max-issues-per-linter 0 + +echo "Double checking spelling..." +$(pwd)/vendor/bin/misspell -error src *.md \ No newline at end of file diff --git a/scripts/find-lint.sh b/scripts/find-lint.sh index 3b1cbac61..a7259b5c2 100755 --- a/scripts/find-lint.sh +++ b/scripts/find-lint.sh @@ -1,46 +1,7 @@ -#! /bin/bash - -# Runs the linters against dendrite - -# The linters can take a lot of resources and are slow, so they can be -# configured using two environment variables: -# -# - `DENDRITE_LINT_CONCURRENCY` - number of concurrent linters to run, -# gometalinter defaults this to 8 -# - `DENDRITE_LINT_DISABLE_GC` - if set then the the go gc will be disabled -# when running the linters, speeding them up but using much more memory. - - -set -eux - -cd `dirname $0`/.. - export GOPATH="$(pwd):$(pwd)/vendor" -# prefer the versions of gometalinter and the linters that we install -# to anythign that ends up on the PATH. -export PATH="$(pwd)/bin:$PATH" +# Install the linter to the local GOPATH +go get github.com/golangci/golangci-lint/cmd/golangci-lint -args="" -if [ ${1:-""} = "fast" ] -then args="--config=linter-fast.json" -else args="--config=linter.json" -fi - -if [ -n "${DENDRITE_LINT_CONCURRENCY:-}" ] -then args="$args --concurrency=$DENDRITE_LINT_CONCURRENCY" -fi - -if [ -z "${DENDRITE_LINT_DISABLE_GC:-}" ] -then args="$args --enable-gc" -fi - -echo "Installing lint search engine..." -gb build github.com/alecthomas/gometalinter/ -gometalinter --config=linter.json ./... --install - -echo "Looking for lint..." -gometalinter ./... $args - -echo "Double checking spelling..." -misspell -error src *.md +# Run the linter +golangci-lint run --max-same-issues 0 --max-issues-per-linter 0 diff --git a/scripts/travis-test.sh b/scripts/travis-test.sh index 2d0332153..2e57be2f2 100755 --- a/scripts/travis-test.sh +++ b/scripts/travis-test.sh @@ -47,7 +47,7 @@ function kill_kafka { } if [ "${TEST_SUITE:-lint}" == "lint" ]; then - ./scripts/find-lint.sh + ./scripts/find-lint-ci.sh fi if [ "${TEST_SUITE:-unit-test}" == "unit-test" ]; then @@ -58,7 +58,7 @@ if [ "${TEST_SUITE:-integ-test}" == "integ-test" ]; then travis_start gb-build "Building dendrite and integ tests" gb build travis_end - + # Check that all the packages can build. # When `go build` is given multiple packages it won't output anything, and just # checks that everything builds. This seems to do a better job of handling diff --git a/vendor/manifest b/vendor/manifest index 2f075ef3e..d58e0245d 100644 --- a/vendor/manifest +++ b/vendor/manifest @@ -7,12 +7,6 @@ "revision": "574d3147eee384229bf96a5d12c207fe7b5234f3", "branch": "master" }, - { - "importpath": "github.com/alecthomas/gometalinter", - "repository": "https://github.com/alecthomas/gometalinter", - "revision": "b8b1f84ae8cb72e7870785840eab2d6c6355aa9f", - "branch": "master" - }, { "importpath": "github.com/alecthomas/units", "repository": "https://github.com/alecthomas/units",