sigs.k8s.io/prow@v0.0.0-20240503223140-c5e374dc7eb1/hack/make-rules/verify/misspell.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  BIN_DIR="${REPO_ROOT}/_bin/misspell"
    24  mkdir -p "$BIN_DIR"
    25  MISSPELL="${BIN_DIR}/misspell"
    26  
    27  echo "Ensuring go version."
    28  source ./hack/build/setup-go.sh
    29  
    30  # build misspell
    31  echo "Install misspell."
    32  cd "hack/tools"
    33  go build -o "$MISSPELL" github.com/client9/misspell/cmd/misspell
    34  cd "${REPO_ROOT}"
    35  
    36  trap 'echo ERROR: found unexpected instance of "Git"hub, use github or GitHub' ERR
    37  
    38  echo "Check for word 'github'..."
    39  # Unit test: Git"hub (remove ")
    40  # Appear to need to use this if statement on mac to get the not grep to work
    41  if find -L . -type f -not \( \
    42    \( \
    43      -path '*/vendor/*' \
    44      -o -path '*/external/*' \
    45      -o -path '*/static/*' \
    46      -o -path '*/third_party/*' \
    47      -o -path '*/node_modules/*' \
    48      -o -path '*/localdata/*' \
    49      -o -path '*/gubernator/*' \
    50      -o -path '*/pkg/bugzilla/client_test.go' \
    51      -o -path './.git/*' \
    52      -o -path './_bin/*' \
    53      -o -path './_output/*' \
    54      -o -path './_artifacts/*' \
    55      -o -path './bazel-*/*' \
    56      -o -path './.python_virtual_env/*' \
    57      \) -prune \
    58      \) -exec grep -Hn 'Git'hub '{}' '+' ; then
    59    echo "Failed"
    60    false
    61  fi
    62  
    63  
    64  trap 'echo ERROR: bad spelling, fix with hack/update/misspell.sh' ERR
    65  
    66  echo "Check for spelling..."
    67  # Unit test: lang auge (remove space)
    68  find -L . -type f -not \( \
    69    \( \
    70      -path '*/vendor/*' \
    71      -o -path '*/external/*' \
    72      -o -path '*/static/*' \
    73      -o -path '*/third_party/*' \
    74      -o -path '*/node_modules/*' \
    75      -o -path '*/localdata/*' \
    76      -o -path './.git/*' \
    77      -o -path './_bin/*' \
    78      -o -path './_output/*' \
    79      -o -path './_artifacts/*' \
    80      -o -path './bazel-*/*' \
    81      -o -path './hack/tools/go.mod' \
    82      -o -path './hack/tools/go.sum' \
    83      -o -path './.python_virtual_env/*' \
    84      \) -prune \
    85      \) | xargs "$MISSPELL" --error
    86  
    87  echo 'PASS: No spelling issues detected'