Upgrade to golangci-lint

This commit is contained in:
Erik Wilson 2019-03-24 21:50:02 -07:00
parent 4463408819
commit 1f82d834e7
4 changed files with 34 additions and 38 deletions

19
.golangci.json Normal file
View File

@ -0,0 +1,19 @@
{
"linters": {
"disable-all": true,
"enable": [
"govet",
"golint",
"goimports",
"misspell",
"ineffassign",
"gofmt"
]
},
"run": {
"skip-files": [
"/zz_generated_"
],
"deadline": "5m"
}
}

View File

@ -1,11 +0,0 @@
{
"EnableAll": false,
"Enable": [
"golint",
"goimports",
"misspell",
"ineffassign",
"errcheck"
],
"Deadline": "1m"
}

View File

@ -6,17 +6,18 @@ RUN apk -U --no-cache add bash git gcc musl-dev docker vim less file curl wget c
RUN pip3 install 'tox==3.6.0'
RUN apk -U --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/main/ add sqlite-dev sqlite-static
RUN mkdir -p /go/src/golang.org/x && \
cd /go/src/golang.org/x && git clone https://github.com/golang/tools && git clone https://github.com/golang/lint && \
git -C /go/src/golang.org/x/lint/golint checkout -b current 06c8688daad7faa9da5a0c2f163a3d14aac986ca && \
go install golang.org/x/lint/golint
RUN go get -d github.com/alecthomas/gometalinter && \
git -C /go/src/github.com/alecthomas/gometalinter checkout -b current v2.0.11 && \
go install github.com/alecthomas/gometalinter && \
gometalinter --install
cd /go/src/golang.org/x && git clone https://github.com/golang/tools && \
git -C /go/src/golang.org/x/tools checkout -b current e9f45831faab4562ce3f53f7196b67c08f948e86 && \
go install golang.org/x/tools/cmd/goimports
RUN rm -rf /go/src /go/pkg
ARG DAPPER_HOST_ARCH
ENV ARCH $DAPPER_HOST_ARCH
RUN if [ "${ARCH}" == "amd64" ]; then \
curl -sL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.15.0; \
fi
ENV DAPPER_RUN_ARGS --privileged -v k3s-cache:/go/src/github.com/rancher/k3s/.cache
ENV DAPPER_ENV REPO TAG DRONE_TAG IMAGE_NAME
ENV DAPPER_SOURCE /go/src/github.com/rancher/k3s/

View File

@ -3,34 +3,21 @@ set -e
cd $(dirname $0)/..
if ! command -v golangci-lint; then
echo Skipping validation: no golangci-lint available
exit
fi
echo Running validation
PACKAGES="$(go list ./...)"
if [ ! -e build/data ];then
mkdir -p build/data
fi
echo Running: go generate
go generate
echo Running: go vet
go vet ${PACKAGES}
echo Running: gometalinter
for i in ${PACKAGES}; do
if [ -n "$(gometalinter $i | \
grep -v 'pkg/data/zz_generated_bindata.go' | \
grep -v 'should have comment.*or be unexported' | \
grep -v 'cli/cmd.*don.t use underscores in Go name' | \
grep -v 'cli/cmd.*should be DNS' | \
tee /dev/stderr)" ]; then
failed=true
fi
done
test -z "$failed"
echo Running: go fmt
test -z "$(go fmt ${PACKAGES} | \
grep -v 'pkg/data/zz_generated_bindata.go' | \
tee /dev/stderr)"
echo Running: golangci-lint
golangci-lint run
. ./scripts/version.sh