mirror of
https://github.com/kubernetes-sigs/kind.git
synced 2025-12-01 07:26:05 +07:00
add golint script and further improve hack/* consistency
This commit is contained in:
@@ -26,17 +26,15 @@ set -o errexit
|
||||
set -o pipefail
|
||||
set -o xtrace
|
||||
|
||||
# cd to the repo root
|
||||
REPO_ROOT=$(git rev-parse --show-toplevel)
|
||||
|
||||
trap 'echo "FAILED" >&2' ERR
|
||||
|
||||
cd "${REPO_ROOT}"
|
||||
|
||||
# plase to stick temp binaries
|
||||
BIN_DIR="${REPO_ROOT}/_output/bin"
|
||||
# place to stick temp binaries
|
||||
BINDIR="${REPO_ROOT}/_output/bin"
|
||||
|
||||
# obtain dep either from existing bazel build (in case of running in an sh_binary)
|
||||
# or install it from vendor into BIN_DIR
|
||||
# or install it from vendor into BINDIR
|
||||
get_dep() {
|
||||
# look for local bazel built dep first
|
||||
local dep
|
||||
@@ -47,8 +45,8 @@ get_dep() {
|
||||
return 0
|
||||
fi
|
||||
# otherwise build dep from vendor and use that ...
|
||||
GOBIN="${BIN_DIR}" go install ./vendor/github.com/golang/dep/cmd/dep
|
||||
echo "${BIN_DIR}/dep"
|
||||
GOBIN="${BINDIR}" go install ./vendor/github.com/golang/dep/cmd/dep
|
||||
echo "${BINDIR}/dep"
|
||||
}
|
||||
|
||||
# select dep binary to use
|
||||
|
||||
@@ -17,6 +17,11 @@ set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
# cd to the repo root
|
||||
REPO_ROOT=$(git rev-parse --show-toplevel)
|
||||
cd "${REPO_ROOT}"
|
||||
|
||||
# check for gofmt diffs
|
||||
diff=$(find . -name "*.go" | grep -v "\/vendor\/" | xargs gofmt -s -d 2>&1)
|
||||
if [[ -n "${diff}" ]]; then
|
||||
echo "${diff}"
|
||||
|
||||
49
hack/verify-golint.sh
Executable file
49
hack/verify-golint.sh
Executable file
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 2018 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# CI script to run go lint over our code
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
set -o verbose
|
||||
|
||||
# cd to the repo root
|
||||
REPO_ROOT=$(git rev-parse --show-toplevel)
|
||||
cd "${REPO_ROOT}"
|
||||
|
||||
# place to stick temp binaries
|
||||
BINDIR="${REPO_ROOT}/_output/bin"
|
||||
|
||||
# obtain golint either from existing bazel build (in case of running in an sh_binary)
|
||||
# or install it from vendor into BINDIR
|
||||
get_golint() {
|
||||
# look for local bazel built dep first
|
||||
local golint
|
||||
golint="$(find bazel-bin/ -type f -name golint | head -n1)"
|
||||
# if we found dep from bazel, just return that
|
||||
if [[ -n "${golint}" ]]; then
|
||||
echo "golint"
|
||||
return 0
|
||||
fi
|
||||
# otherwise build dep from vendor and use that ...
|
||||
GOBIN="${BINDIR}" go install ./vendor/github.com/golang/lint/golint
|
||||
echo "${BINDIR}/golint"
|
||||
}
|
||||
|
||||
# select golint binary to use
|
||||
GOLINT="${GOLINT:-$(get_golint)}"
|
||||
|
||||
# we need to do this because golint ./... matches vendor...
|
||||
go list ./... | xargs -L1 "${GOLINT}" -set_exit_status
|
||||
@@ -19,4 +19,8 @@ set -o nounset
|
||||
set -o pipefail
|
||||
set -o verbose
|
||||
|
||||
# cd to the repo root
|
||||
REPO_ROOT=$(git rev-parse --show-toplevel)
|
||||
cd "${REPO_ROOT}"
|
||||
|
||||
go vet ./...
|
||||
|
||||
Reference in New Issue
Block a user