mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
Upgrade to golangci-lint
This commit is contained in:
parent
4463408819
commit
1f82d834e7
19
.golangci.json
Normal file
19
.golangci.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"linters": {
|
||||
"disable-all": true,
|
||||
"enable": [
|
||||
"govet",
|
||||
"golint",
|
||||
"goimports",
|
||||
"misspell",
|
||||
"ineffassign",
|
||||
"gofmt"
|
||||
]
|
||||
},
|
||||
"run": {
|
||||
"skip-files": [
|
||||
"/zz_generated_"
|
||||
],
|
||||
"deadline": "5m"
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
{
|
||||
"EnableAll": false,
|
||||
"Enable": [
|
||||
"golint",
|
||||
"goimports",
|
||||
"misspell",
|
||||
"ineffassign",
|
||||
"errcheck"
|
||||
],
|
||||
"Deadline": "1m"
|
||||
}
|
@ -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/
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user