sigs.k8s.io/prow@v0.0.0-20240503223140-c5e374dc7eb1/hack/make-rules/verify/golangci-lint.sh (about) 1 #!/usr/bin/env bash 2 # Copyright 2021 The Kubernetes Authors. 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # http://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 16 set -o nounset 17 set -o errexit 18 set -o pipefail 19 20 REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd -P)" 21 cd $REPO_ROOT 22 23 trap 'echo ERROR: golangci-lint failed >&2' ERR 24 25 echo "Ensuring go version." 26 source ./hack/build/setup-go.sh 27 28 if [[ ! -f .golangci.yml ]]; then 29 echo 'ERROR: missing .golangci.yml in repo root' >&2 30 exit 1 31 fi 32 33 # build golangci-lint 34 echo "Install golangci-lint." 35 cd "hack/tools" 36 go build -o "${REPO_ROOT}/_bin/golangci-lint" github.com/golangci/golangci-lint/cmd/golangci-lint 37 cd "${REPO_ROOT}" 38 39 echo "Run golangci-lint." 40 echo "Go version: $(go version)" 41 echo "Golangci-lint version: $(./_bin/golangci-lint version)" 42 export GO111MODULE=on 43 export GOPROXY=https://proxy.golang.org 44 export GOSUMDB=sum.golang.org 45 ./_bin/golangci-lint run ./...