mirror of
https://github.com/kubernetes-sigs/kind.git
synced 2025-12-01 07:26:05 +07:00
track misspell with tools module
This commit is contained in:
@@ -3,6 +3,7 @@ module sigs.k8s.io/kind/hack/tools
|
||||
go 1.12
|
||||
|
||||
require (
|
||||
github.com/client9/misspell v0.3.4
|
||||
github.com/spf13/pflag v1.0.3 // indirect
|
||||
golang.org/x/lint v0.0.0-20190409202823-959b441ac422
|
||||
golang.org/x/tools v0.0.0-20190606174628-0139d5756a7d // indirect
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
|
||||
@@ -8,6 +8,7 @@ package tools
|
||||
|
||||
import (
|
||||
// linter(s)
|
||||
_ "github.com/client9/misspell"
|
||||
_ "golang.org/x/lint"
|
||||
_ "honnef.co/go/tools/cmd/staticcheck"
|
||||
|
||||
|
||||
@@ -21,42 +21,19 @@ set -o pipefail
|
||||
REPO_ROOT=$(git rev-parse --show-toplevel)
|
||||
cd "${REPO_ROOT}"
|
||||
|
||||
# create a temporary directory
|
||||
TMP_DIR=$(mktemp -d)
|
||||
# enable modules and the proxy cache
|
||||
export GO111MODULE="on"
|
||||
GOPROXY="${GOPROXY:-https://proxy.golang.org}"
|
||||
export GOPROXY
|
||||
|
||||
# cleanup
|
||||
exitHandler() (
|
||||
echo "Cleaning up ..."
|
||||
rm -rf "${TMP_DIR}"
|
||||
)
|
||||
trap exitHandler EXIT
|
||||
|
||||
# pull misspell
|
||||
export GO111MODULE=on
|
||||
URL="https://github.com/client9/misspell"
|
||||
echo "Cloning ${URL} in ${TMP_DIR}..."
|
||||
git clone --quiet --depth=1 "${URL}" "${TMP_DIR}"
|
||||
pushd "${TMP_DIR}" > /dev/null
|
||||
go mod init
|
||||
popd > /dev/null
|
||||
|
||||
# build misspell
|
||||
BIN_PATH="${TMP_DIR}/cmd/misspell"
|
||||
pushd "${BIN_PATH}" > /dev/null
|
||||
echo "Building misspell ..."
|
||||
go build > /dev/null
|
||||
popd > /dev/null
|
||||
# build staticcheck
|
||||
BINDIR="${REPO_ROOT}/bin"
|
||||
# use the tools module
|
||||
cd "hack/tools"
|
||||
go build -o "${BINDIR}/misspell" github.com/client9/misspell/cmd/misspell
|
||||
# go back to the root
|
||||
cd "${REPO_ROOT}"
|
||||
|
||||
# check spelling
|
||||
RES=0
|
||||
ERROR_LOG="${TMP_DIR}/errors.log"
|
||||
echo "Checking spelling ..."
|
||||
git ls-files | grep -v -e "vendor\|go.\(sum\|mod\)" | xargs "${BIN_PATH}/misspell" > "${ERROR_LOG}"
|
||||
if [[ -s "${ERROR_LOG}" ]]; then
|
||||
sed 's/^/error: /' "${ERROR_LOG}" # add 'error' to each line to highlight in e2e status
|
||||
echo "Found spelling errors!"
|
||||
RES=1
|
||||
else
|
||||
echo "Done!"
|
||||
fi
|
||||
exit "${RES}"
|
||||
# NOTE add 'error' to each line to highlight in e2e status
|
||||
git ls-files | grep -v -e "vendor\|go.\(sum\|mod\)" | xargs "${BINDIR}/misspell" -error | sed 's/^/error: /'
|
||||
|
||||
Reference in New Issue
Block a user