Add golangci-lint workflow (#4999)
* fix lint workflow * add golang lint * close http response body
This commit is contained in:
@@ -27,7 +27,6 @@ EXCLUDED_PATTERNS=(
|
||||
"verify-linkcheck.sh" # runs in separate Jenkins job once per day due to high network usage
|
||||
"verify-*-dockerized.sh" # Don't run any scripts that intended to be run dockerized
|
||||
"verify-govet-levee.sh" # Do not run levee analysis by default while KEP-1933 implementation is in alpha.
|
||||
"verify-golangci-lint.sh" # Experimental - intended to be run by hand periodically
|
||||
"verify-licenses.sh"
|
||||
)
|
||||
|
||||
|
||||
24
hack/verify-golangci-lint.sh
Normal file → Executable file
24
hack/verify-golangci-lint.sh
Normal file → Executable file
@@ -35,14 +35,24 @@ PATH="${GOBIN}:${PATH}"
|
||||
# Explicitly opt into go modules, even though we're inside a GOPATH directory
|
||||
export GO111MODULE=on
|
||||
|
||||
if ! command -v golangci-lint ; then
|
||||
# Install golangci-lint
|
||||
echo 'installing golangci-lint '
|
||||
pushd "${KUBE_ROOT}/hack/tools" >/dev/null
|
||||
go install github.com/golangci/golangci-lint/cmd/golangci-lint
|
||||
popd >/dev/null
|
||||
echo 'installing golangci-lint '
|
||||
pushd "${KUBE_ROOT}/hack/tools" >/dev/null
|
||||
GO111MODULE=auto go install -mod= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.44.2
|
||||
popd >/dev/null
|
||||
fi
|
||||
|
||||
cd "${KUBE_ROOT}"
|
||||
|
||||
function error_exit {
|
||||
if [ $? -eq 1 ]; then
|
||||
echo "Please run the following command:"
|
||||
echo " make golint"
|
||||
fi
|
||||
}
|
||||
trap "error_exit" EXIT
|
||||
|
||||
echo 'running golangci-lint '
|
||||
golangci-lint run \
|
||||
--timeout 30m \
|
||||
@@ -50,4 +60,8 @@ golangci-lint run \
|
||||
-E deadcode \
|
||||
-E unused \
|
||||
-E varcheck \
|
||||
-E ineffassign
|
||||
-E ineffassign \
|
||||
-E staticcheck \
|
||||
-E gosimple \
|
||||
-E bodyclose \
|
||||
pkg/... cmd/... tools/... test/... kube/...
|
||||
|
||||
Reference in New Issue
Block a user