mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-14 18:33:09 -06:00
Switch travis to golangci-lint. Add user linting script
This commit is contained in:
parent
89a7d094da
commit
e7988f71f2
|
|
@ -17,7 +17,7 @@ gb build
|
||||||
echo "Double checking it builds..."
|
echo "Double checking it builds..."
|
||||||
go build github.com/matrix-org/dendrite/cmd/...
|
go build github.com/matrix-org/dendrite/cmd/...
|
||||||
|
|
||||||
./scripts/find-lint.sh
|
./scripts/find-lint-ci.sh
|
||||||
|
|
||||||
echo "Testing..."
|
echo "Testing..."
|
||||||
gb test
|
gb test
|
||||||
|
|
|
||||||
43
scripts/find-lint-ci.sh
Executable file
43
scripts/find-lint-ci.sh
Executable file
|
|
@ -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
|
||||||
|
|
@ -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"
|
export GOPATH="$(pwd):$(pwd)/vendor"
|
||||||
|
|
||||||
# prefer the versions of gometalinter and the linters that we install
|
# Install the linter to the local GOPATH
|
||||||
# to anythign that ends up on the PATH.
|
go get github.com/golangci/golangci-lint/cmd/golangci-lint
|
||||||
export PATH="$(pwd)/bin:$PATH"
|
|
||||||
|
|
||||||
args=""
|
# Run the linter
|
||||||
if [ ${1:-""} = "fast" ]
|
golangci-lint run --max-same-issues 0 --max-issues-per-linter 0
|
||||||
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
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ function kill_kafka {
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ "${TEST_SUITE:-lint}" == "lint" ]; then
|
if [ "${TEST_SUITE:-lint}" == "lint" ]; then
|
||||||
./scripts/find-lint.sh
|
./scripts/find-lint-ci.sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${TEST_SUITE:-unit-test}" == "unit-test" ]; then
|
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"
|
travis_start gb-build "Building dendrite and integ tests"
|
||||||
gb build
|
gb build
|
||||||
travis_end
|
travis_end
|
||||||
|
|
||||||
# Check that all the packages can build.
|
# Check that all the packages can build.
|
||||||
# When `go build` is given multiple packages it won't output anything, and just
|
# 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
|
# checks that everything builds. This seems to do a better job of handling
|
||||||
|
|
|
||||||
6
vendor/manifest
vendored
6
vendor/manifest
vendored
|
|
@ -7,12 +7,6 @@
|
||||||
"revision": "574d3147eee384229bf96a5d12c207fe7b5234f3",
|
"revision": "574d3147eee384229bf96a5d12c207fe7b5234f3",
|
||||||
"branch": "master"
|
"branch": "master"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"importpath": "github.com/alecthomas/gometalinter",
|
|
||||||
"repository": "https://github.com/alecthomas/gometalinter",
|
|
||||||
"revision": "b8b1f84ae8cb72e7870785840eab2d6c6355aa9f",
|
|
||||||
"branch": "master"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"importpath": "github.com/alecthomas/units",
|
"importpath": "github.com/alecthomas/units",
|
||||||
"repository": "https://github.com/alecthomas/units",
|
"repository": "https://github.com/alecthomas/units",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue