From 78104834fe425cfa6e0244f3761154e785a1e787 Mon Sep 17 00:00:00 2001 From: Yuan Chen Date: Fri, 10 May 2024 15:41:38 -0700 Subject: [PATCH] Revert "Add verify scripts for various checks (#21)" This reverts commit 144e7a7bb2b5083b3a95d64031b3f22a404446c0, reversing changes made to 2f29e50ed4cdb18c8c97f49c4a46507adc647f2f. Signed-off-by: Yuan Chen --- .yamlfmt.yaml | 4 -- .yamllint.conf | 14 ------ Makefile | 10 ---- hack/spelling.txt | 1 - hack/update-all.sh | 64 ------------------------- hack/update-ends-newline.sh | 42 ----------------- hack/update-go-format.sh | 37 --------------- hack/update-go-mod.sh | 24 ---------- hack/update-shell-format.sh | 37 --------------- hack/update-spelling.sh | 47 ------------------- hack/update-yaml-format.sh | 40 ---------------- hack/verify-all.sh | 75 ----------------------------- hack/verify-ends-newline.sh | 51 -------------------- hack/verify-go-format.sh | 42 ----------------- hack/verify-go-mod.sh | 30 ------------ hack/verify-shell-format.sh | 30 ------------ hack/verify-shellcheck.sh | 94 ------------------------------------- hack/verify-spelling.sh | 30 ------------ hack/verify-yaml-format.sh | 30 ------------ hack/verify-yamllint.sh | 63 ------------------------- 20 files changed, 765 deletions(-) delete mode 100644 .yamlfmt.yaml delete mode 100644 .yamllint.conf delete mode 100644 hack/spelling.txt delete mode 100755 hack/update-all.sh delete mode 100755 hack/update-ends-newline.sh delete mode 100755 hack/update-go-format.sh delete mode 100755 hack/update-go-mod.sh delete mode 100755 hack/update-shell-format.sh delete mode 100755 hack/update-spelling.sh delete mode 100755 hack/update-yaml-format.sh delete mode 100755 hack/verify-all.sh delete mode 100755 hack/verify-ends-newline.sh delete mode 100755 hack/verify-go-format.sh delete mode 100755 hack/verify-go-mod.sh delete mode 100755 hack/verify-shell-format.sh delete mode 100755 hack/verify-shellcheck.sh delete mode 100755 hack/verify-spelling.sh delete mode 100755 hack/verify-yaml-format.sh delete mode 100755 hack/verify-yamllint.sh diff --git a/.yamlfmt.yaml b/.yamlfmt.yaml deleted file mode 100644 index 56ca1d9..0000000 --- a/.yamlfmt.yaml +++ /dev/null @@ -1,4 +0,0 @@ -formatter: - type: basic - indentless_arrays: true - retain_line_breaks_single: true diff --git a/.yamllint.conf b/.yamllint.conf deleted file mode 100644 index ed49eeb..0000000 --- a/.yamllint.conf +++ /dev/null @@ -1,14 +0,0 @@ -# configuration file rules -# https://yamllint.readthedocs.io/en/stable/rules.html - -extends: default - -ignore-from-file: .gitignore - -rules: - indentation: disable - document-start: disable - comments: disable - line-length: disable - truthy: - check-keys: false diff --git a/Makefile b/Makefile index be60da6..4d49e15 100644 --- a/Makefile +++ b/Makefile @@ -22,16 +22,6 @@ IMAGE_REPO ?=docker.io/nvidia/knavigator GIT_REF =$(shell git rev-parse --abbrev-ref HEAD) IMAGE_TAG ?=$(GIT_REF) -## verify: Verify code -.PHONY: verify -verify: - @./hack/verify-all.sh - -## update: Update all the generated -.PHONY: update -update: - @./hack/update-all.sh - .PHONY: build build: @for target in $(TARGETS); do \ diff --git a/hack/spelling.txt b/hack/spelling.txt deleted file mode 100644 index 6daaf5e..0000000 --- a/hack/spelling.txt +++ /dev/null @@ -1 +0,0 @@ -importas diff --git a/hack/update-all.sh b/hack/update-all.sh deleted file mode 100755 index 10fd631..0000000 --- a/hack/update-all.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2023 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. - -set -o errexit -set -o nounset -set -o pipefail - -DIR="$(dirname "${BASH_SOURCE[0]}")" - -ROOT_DIR="$(realpath "${DIR}/..")" - -failed=() - -if [[ "${UPDATE_GO_FORMAT:-true}" == "true" ]]; then - echo "[*] Update go format..." - "${ROOT_DIR}"/hack/update-go-format.sh || failed+=(go-format) -fi - -if [[ "${UPDATE_GO_MOD:-true}" == "true" ]]; then - echo "[*] Update go mod..." - "${ROOT_DIR}"/hack/update-go-mod.sh || failed+=(go-mod) -fi - -if [[ "${UPDATE_GO_LINT:-true}" == "true" ]]; then - echo "[*] Update go lint..." - "${ROOT_DIR}"/hack/update-go-lint.sh || failed+=(go-lint) -fi - -if [[ "${UPDATE_ENDS_NEWLINE:-true}" == "true" ]]; then - echo "[*] Update ends newline..." - "${ROOT_DIR}"/hack/update-ends-newline.sh || failed+=(ends-newline) -fi - -if [[ "${UPDATE_SHELL_FORMAT:-true}" == "true" ]]; then - echo "[*] Update shell format..." - "${ROOT_DIR}"/hack/update-shell-format.sh || failed+=(shell-format) -fi - -if [[ "${UPDATE_YAML_FORMAT:-true}" == "true" ]]; then - echo "[*] Update yaml format..." - "${ROOT_DIR}"/hack/update-yaml-format.sh || failed+=(yaml-format) -fi - -if [[ "${UPDATE_SPELLING:-true}" == "true" ]]; then - echo "[*] Update spelling..." - "${ROOT_DIR}"/hack/update-spelling.sh || failed+=(spelling) -fi - -if [[ "${#failed[@]}" != 0 ]]; then - echo "Update failed for: ${failed[*]}" - exit 1 -fi diff --git a/hack/update-ends-newline.sh b/hack/update-ends-newline.sh deleted file mode 100755 index ef82ec0..0000000 --- a/hack/update-ends-newline.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2023 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. - -set -o errexit -set -o nounset -set -o pipefail - -DIR="$(dirname "${BASH_SOURCE[0]}")" - -ROOT_DIR="$(realpath "${DIR}/..")" - -function update_ends_newline() { - find . \( \ - -iname "*.md" \ - -o -iname "*.sh" \ - -o -iname "*.go" \ - -o -iname "*.tpl" \ - -o -iname "*.yaml" \ - -o -iname "*.yml" \ - \) \ - -not \( \ - -path ./.git/\* \ - -o -path ./vendor/\* \ - -o -path ./demo/node_modules/\* \ - -o -path ./site/themes/\* \ - \) \ - -exec sh -c '[ -n "$(tail -c 1 $1)" ] && echo >> $1' sh {} \; -} - -cd "${ROOT_DIR}" && update_ends_newline diff --git a/hack/update-go-format.sh b/hack/update-go-format.sh deleted file mode 100755 index e476d6a..0000000 --- a/hack/update-go-format.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2023 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. - -set -o errexit -set -o nounset -set -o pipefail - -DIR="$(dirname "${BASH_SOURCE[0]}")" - -ROOT_DIR="$(realpath "${DIR}/..")" - -function format() { - echo "Update go format" - mapfile -t findfiles < <(find . \( \ - -iname "*.go" \ - \) \ - -not \( \ - -path ./vendor/\* \ - -o -path ./demo/node_modules/\* \ - -o -path ./site/themes/\* \ - \)) - gofmt -s -w "${findfiles[@]}" -} - -cd "${ROOT_DIR}" && format diff --git a/hack/update-go-mod.sh b/hack/update-go-mod.sh deleted file mode 100755 index 3fb386a..0000000 --- a/hack/update-go-mod.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2023 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. - -set -o errexit -set -o nounset -set -o pipefail - -DIR="$(dirname "${BASH_SOURCE[0]}")" - -ROOT_DIR="$(realpath "${DIR}/..")" - -cd "${ROOT_DIR}" && go mod tidy diff --git a/hack/update-shell-format.sh b/hack/update-shell-format.sh deleted file mode 100755 index 2e8069a..0000000 --- a/hack/update-shell-format.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2023 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. - -set -o errexit -set -o nounset -set -o pipefail - -DIR="$(dirname "${BASH_SOURCE[0]}")" - -ROOT_DIR="$(realpath "${DIR}/..")" - -function format() { - echo "Update shell format" - mapfile -t findfiles < <(find . \( \ - -iname "*.sh" \ - \) \ - -not \( \ - -path ./vendor/\* \ - -o -path ./demo/node_modules/\* \ - -o -path ./site/themes/\* \ - \)) - go run mvdan.cc/sh/v3/cmd/shfmt@v3.7.0 -w -i=2 "${findfiles[@]}" -} - -cd "${ROOT_DIR}" && format diff --git a/hack/update-spelling.sh b/hack/update-spelling.sh deleted file mode 100755 index b04dc3c..0000000 --- a/hack/update-spelling.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2023 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. - -set -o errexit -set -o nounset -set -o pipefail - -DIR="$(dirname "${BASH_SOURCE[0]}")" - -ROOT_DIR="$(realpath "${DIR}/..")" - -allowed_spelling_words="${ROOT_DIR}/hack/spelling.txt" - -function update() { - local ignore - ignore="$(tr <"${allowed_spelling_words}" '\n' ',')" - mapfile -t files < <(find . \( \ - -iname "*.md" \ - -o -iname "*.sh" \ - -o -iname "*.go" \ - -o -iname "*.tpl" \ - -o -iname "*.yaml" \ - -o -iname "*.yml" \ - \) \ - -not \( \ - -path ./.git/\* \ - -o -path ./vendor/\* \ - -o -path ./demo/node_modules/\* \ - -o -path ./site/themes/\* \ - \)) - go run github.com/client9/misspell/cmd/misspell@v0.3.4 \ - -locale US -w -i "${ignore}" "${files[@]}" -} - -cd "${ROOT_DIR}" && update diff --git a/hack/update-yaml-format.sh b/hack/update-yaml-format.sh deleted file mode 100755 index 65bf544..0000000 --- a/hack/update-yaml-format.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2024 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. - -set -o errexit -set -o nounset -set -o pipefail - -DIR="$(dirname "${BASH_SOURCE[0]}")" - -ROOT_DIR="$(realpath "${DIR}/..")" - -function format() { - echo "Update yaml format" - mapfile -t findfiles < <(find . \( \ - -iname "*.yaml" \ - -o -iname "*.yml" \ - \) \ - -not \( \ - -path ./vendor/\* \ - -o -path ./demo/node_modules/\* \ - -o -path ./site/themes/\* \ - -o -path ./kustomize/crd/bases/\* \ - -o -path ./kustomize/rbac/\* \ - \)) - go run github.com/google/yamlfmt/cmd/yamlfmt@v0.11.0 -conf .yamlfmt.yaml "${findfiles[@]}" -} - -cd "${ROOT_DIR}" && format diff --git a/hack/verify-all.sh b/hack/verify-all.sh deleted file mode 100755 index 5c25aa8..0000000 --- a/hack/verify-all.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2022 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. - -set -o errexit -set -o nounset -set -o pipefail - -DIR="$(dirname "${BASH_SOURCE[0]}")" - -ROOT_DIR="$(realpath "${DIR}/..")" - -failed=() - -if [[ "${VERIFY_ENDS_NEWLINE:-true}" == "true" ]]; then - echo "[*] Verifying ends newline..." - "${ROOT_DIR}"/hack/verify-ends-newline.sh || failed+=(ends-newline) -fi - -if [[ "${VERIFY_GO_MOD:-true}" == "true" ]]; then - echo "[*] Verifying go mod..." - "${ROOT_DIR}"/hack/verify-go-mod.sh || failed+=(go-mod) -fi - -if [[ "${VERIFY_GO_FORMAT:-true}" == "true" ]]; then - echo "[*] Verifying go format..." - "${ROOT_DIR}"/hack/verify-go-format.sh || failed+=(go-format) -fi - -if [[ "${VERIFY_GO_LINT:-true}" == "true" ]]; then - echo "[*] Verifying go lint..." - "${ROOT_DIR}"/hack/verify-go-lint.sh || failed+=(go-lint) -fi - -if [[ "${VERIFY_YAMLLINT:-true}" == "true" ]]; then - echo "[*] Verifying YAML lint..." - "${ROOT_DIR}"/hack/verify-yamllint.sh || failed+=(yamllint) -fi - -if [[ "${VERIFY_SHELLCHECK:-true}" == "true" ]]; then - echo "[*] Verifying shell check..." - "${ROOT_DIR}"/hack/verify-shellcheck.sh || failed+=(shellcheck) -fi - -if [[ "${VERIFY_SHELL_FORMAT:-true}" == "true" ]]; then - echo "[*] Verifying shell format..." - "${ROOT_DIR}"/hack/verify-shell-format.sh || failed+=(shell-format) -fi - -if [[ "${VERIFY_YAML_FORMAT:-true}" == "true" ]]; then - echo "[*] Verifying yaml format..." - "${ROOT_DIR}"/hack/verify-yaml-format.sh || failed+=(yaml-format) -fi - -if [[ "${VERIFY_SPELLING:-true}" == "true" ]]; then - echo "[*] Verifying spelling..." - "${ROOT_DIR}"/hack/verify-spelling.sh || failed+=(spelling) -fi - -# exit based on verify scripts -if [[ "${#failed[@]}" != 0 ]]; then - echo "Verify failed for: ${failed[*]}" - exit 1 -fi diff --git a/hack/verify-ends-newline.sh b/hack/verify-ends-newline.sh deleted file mode 100755 index 5bcdcc8..0000000 --- a/hack/verify-ends-newline.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2022 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. - -set -o errexit -set -o nounset -set -o pipefail - -DIR="$(dirname "${BASH_SOURCE[0]}")" - -ROOT_DIR="$(realpath "${DIR}/..")" - -function check_ends() { - find . \( \ - -iname "*.md" \ - -o -iname "*.sh" \ - -o -iname "*.go" \ - -o -iname "*.tpl" \ - -o -iname "*.yaml" \ - -o -iname "*.yml" \ - \) \ - -not \( \ - -path ./.git/\* \ - -o -path ./vendor/\* \ - -o -path ./demo/node_modules/\* \ - -o -path ./site/themes/\* \ - \) \ - -exec sh -c '[ -n "$(tail -c 1 "$1")" ] && echo "$1"' sh {} \; -} - -function check() { - out="$(check_ends)" - if [[ "${out}" != "" ]]; then - echo "Add a new line in ends for below files" - echo "${out}" - return 1 - fi -} - -cd "${ROOT_DIR}" && check diff --git a/hack/verify-go-format.sh b/hack/verify-go-format.sh deleted file mode 100755 index a20e229..0000000 --- a/hack/verify-go-format.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2022 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. - -set -o errexit -set -o nounset -set -o pipefail - -DIR="$(dirname "${BASH_SOURCE[0]}")" - -ROOT_DIR="$(realpath "${DIR}/..")" - -function check() { - echo "Verify go format" - mapfile -t findfiles < <(find . \( \ - -iname "*.go" \ - \) \ - -not \( \ - -path ./vendor/\* \ - -o -path ./demo/node_modules/\* \ - -o -path ./site/themes/\* \ - \)) - out="$(gofmt -s -w "${findfiles[@]}")" - - if [[ -n "${out}" ]]; then - echo "${out}" - return 1 - fi -} - -cd "${ROOT_DIR}" && check diff --git a/hack/verify-go-mod.sh b/hack/verify-go-mod.sh deleted file mode 100755 index c504008..0000000 --- a/hack/verify-go-mod.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2022 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. - -set -o errexit -set -o nounset -set -o pipefail - -DIR="$(dirname "${BASH_SOURCE[0]}")" - -ROOT_DIR="$(realpath "${DIR}/..")" - -function check() { - echo "Verify go.mod & go.sum" - go mod tidy - git --no-pager diff --exit-code go.mod go.sum -} - -cd "${ROOT_DIR}" && check diff --git a/hack/verify-shell-format.sh b/hack/verify-shell-format.sh deleted file mode 100755 index fbb0b23..0000000 --- a/hack/verify-shell-format.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2023 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. - -set -o errexit -set -o nounset -set -o pipefail - -DIR="$(dirname "${BASH_SOURCE[0]}")" - -ROOT_DIR="$(realpath "${DIR}/..")" - -function check() { - echo "Verify shell format" - "${ROOT_DIR}"/hack/update-shell-format.sh - git --no-pager diff --exit-code -} - -cd "${ROOT_DIR}" && check diff --git a/hack/verify-shellcheck.sh b/hack/verify-shellcheck.sh deleted file mode 100755 index b0a394f..0000000 --- a/hack/verify-shellcheck.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2023 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. - -set -o errexit -set -o nounset -set -o pipefail - -DIR="$(dirname "${BASH_SOURCE[0]}")" - -ROOT_DIR="$(realpath "${DIR}/..")" - -SHELLCHECK_VERSION="0.9.0" - -# disabled lints -disabled=( - # this lint disallows non-constant source, which we use extensively without - # any known bugs - 1090 - # this lint warns when shellcheck cannot find a sourced file - # this wouldn't be a bad idea to warn on, but it fails on lots of path - # dependent sourcing, so just disable enforcing it - 1091 - # this lint prefers command -v to which, they are not the same - 2230 -) -# comma separate for passing to shellcheck -join_by() { - local IFS="$1" - shift - echo "$*" -} -SHELLCHECK_DISABLED="$(join_by , "${disabled[@]}")" -readonly SHELLCHECK_DISABLED - -mapfile -t findfiles < <(find . \( \ - -iname "*.sh" \ - \) \ - -not \( \ - -path ./vendor/\* \ - -o -path ./demo/node_modules/\* \ - -o -path ./site/themes/\* \ - \)) - -SHELLCHECK_OPTIONS=( - "--external-sources" - "--exclude=${SHELLCHECK_DISABLED}" - "--color=always" -) - -HAVE_SHELLCHECK=false -if command -v shellcheck; then - detected_version="$(shellcheck --version | grep 'version: .*')" - if [[ "${detected_version}" == "version: ${SHELLCHECK_VERSION}" ]]; then - HAVE_SHELLCHECK=true - fi -fi - -COMMAND=() -if ${HAVE_SHELLCHECK}; then - COMMAND=(shellcheck) -elif command -v "${ROOT_DIR}/bin/shellcheck"; then - COMMAND=("${ROOT_DIR}/bin/shellcheck") -elif [[ "$(uname -s)" == "Linux" ]] && [[ "$(uname -m)" == "x86_64" ]]; then - wget -qO- "https://github.com/koalaman/shellcheck/releases/download/v${SHELLCHECK_VERSION?}/shellcheck-v${SHELLCHECK_VERSION?}.linux.x86_64.tar.xz" | tar -xJv - mkdir -p "${ROOT_DIR}"/bin - mv "shellcheck-v${SHELLCHECK_VERSION}/shellcheck" "${ROOT_DIR}/bin/" - COMMAND=("${ROOT_DIR}/bin/shellcheck") -elif command -v docker; then - COMMAND=( - docker run - --rm - -v "${ROOT_DIR}:${ROOT_DIR}" - -w "${ROOT_DIR}" - docker.io/koalaman/shellcheck-alpine:v0.9.0@sha256:e19ed93c22423970d56568e171b4512c9244fc75dd9114045016b4a0073ac4b7 - shellcheck - ) -else - echo "WARNING: shellcheck or docker not installed" >&2 - exit 1 -fi - -cd "${ROOT_DIR}" && "${COMMAND[@]}" "${SHELLCHECK_OPTIONS[@]}" "${findfiles[@]}" diff --git a/hack/verify-spelling.sh b/hack/verify-spelling.sh deleted file mode 100755 index 2cfc6b8..0000000 --- a/hack/verify-spelling.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2023 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. - -set -o errexit -set -o nounset -set -o pipefail - -DIR="$(dirname "${BASH_SOURCE[0]}")" - -ROOT_DIR="$(realpath "${DIR}/..")" - -function check() { - echo "Verify spelling" - "${ROOT_DIR}"/hack/update-spelling.sh - git --no-pager diff --exit-code -} - -cd "${ROOT_DIR}" && check diff --git a/hack/verify-yaml-format.sh b/hack/verify-yaml-format.sh deleted file mode 100755 index 38f448f..0000000 --- a/hack/verify-yaml-format.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2024 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. - -set -o errexit -set -o nounset -set -o pipefail - -DIR="$(dirname "${BASH_SOURCE[0]}")" - -ROOT_DIR="$(realpath "${DIR}/..")" - -function check() { - echo "Verify yaml format" - "${ROOT_DIR}"/hack/update-yaml-format.sh - git --no-pager diff --exit-code -} - -cd "${ROOT_DIR}" && check diff --git a/hack/verify-yamllint.sh b/hack/verify-yamllint.sh deleted file mode 100755 index 1b6f844..0000000 --- a/hack/verify-yamllint.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2023 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. - -set -o errexit -set -o nounset -set -o pipefail - -DIR="$(dirname "${BASH_SOURCE[0]}")" - -ROOT_DIR="$(realpath "${DIR}/..")" - -COMMAND=() -if command -v yamllint; then - COMMAND=(yamllint) -elif command -v "${ROOT_DIR}/venv/bin/yamllint"; then - COMMAND=("${ROOT_DIR}/venv/bin/yamllint") -elif command -v python3; then - python3 -m venv "${ROOT_DIR}/venv" - source "${ROOT_DIR}/venv/bin/activate" - pip install yamllint - COMMAND=("${ROOT_DIR}/venv/bin/yamllint") -elif command -v docker; then - COMMAND=( - docker run - --rm -i - -v "${ROOT_DIR}:/workdir" - -w "/workdir" - --security-opt="label=disable" - "docker.io/cytopia/yamllint:1.26@sha256:1bf8270a671a2e5f2fea8ac2e80164d627e0c5fa083759862bbde80628f942b2" - ) -else - echo "WARNING: yamllint, python3 or docker not installed" >&2 - exit 1 -fi - -function check() { - echo "Verify go format" - mapfile -t findfiles < <(find . \( \ - -iname "*.yaml" \ - -o -iname "*.yml" \ - \) \ - -not \( \ - -path ./vendor/\* \ - -o -path ./demo/node_modules/\* \ - -o -path ./site/themes/\* \ - \)) - - "${COMMAND[@]}" -s -c .yamllint.conf "${findfiles[@]}" -} - -cd "${ROOT_DIR}" && check