This repository has been archived by the owner on Sep 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hack: include more update and verify scripts
update: - deps: calls go mod tidy verify: - build: calls build for ./cmd - deps: verifies if the current go.* files are valid - gotest: calls go tests on _test files if present - govet: calls go vet - shellcheck: executes shellcheck on all .sh files
- Loading branch information
Showing
9 changed files
with
356 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
# Copyright 2019 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 | ||
|
||
# shellcheck source=/dev/null | ||
source "$(dirname "$0")/utils.sh" | ||
REPO_PATH=$(get_root_path) | ||
|
||
"${REPO_PATH}"/hack/update-deps.sh | ||
"${REPO_PATH}"/hack/update-gofmt.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env bash | ||
# Copyright 2019 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 nounset | ||
set -o errexit | ||
set -o pipefail | ||
|
||
# shellcheck source=/dev/null | ||
source "$(dirname "$0")/utils.sh" | ||
# cd to the root path | ||
cd_root_path | ||
|
||
export GO111MODULE="on" | ||
go mod tidy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#!/usr/bin/env bash | ||
# Copyright 2019 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 | ||
|
||
# shellcheck source=/dev/null | ||
source "$(dirname "$0")/utils.sh" | ||
|
||
# set REPO_PATH | ||
REPO_PATH=$(get_root_path) | ||
cd "${REPO_PATH}" | ||
|
||
# exit code, if a script fails we'll set this to 1 | ||
res=0 | ||
|
||
# run all verify scripts, optionally skipping any of them | ||
|
||
if [[ "${VERIFY_WHITESPACE:-true}" == "true" ]]; then | ||
echo "[*] Verifying whitespace..." | ||
hack/verify-whitespace.sh || res=1 | ||
cd "${REPO_PATH}" | ||
fi | ||
|
||
if [[ "${VERIFY_SPELLING:-true}" == "true" ]]; then | ||
echo "[*] Verifying spelling..." | ||
hack/verify-spelling.sh || res=1 | ||
cd "${REPO_PATH}" | ||
fi | ||
|
||
if [[ "${VERIFY_GOFMT:-true}" == "true" ]]; then | ||
echo "[*] Verifying gofmt..." | ||
hack/verify-gofmt.sh || res=1 | ||
cd "${REPO_PATH}" | ||
fi | ||
|
||
if [[ "${VERIFY_GOLINT:-true}" == "true" ]]; then | ||
echo "[*] Verifying golint..." | ||
hack/verify-golint.sh || res=1 | ||
cd "${REPO_PATH}" | ||
fi | ||
|
||
if [[ "${VERIFY_GOVET:-true}" == "true" ]]; then | ||
echo "[*] Verifying govet..." | ||
hack/verify-govet.sh || res=1 | ||
cd "${REPO_PATH}" | ||
fi | ||
|
||
if [[ "${VERIFY_DEPS:-true}" == "true" ]]; then | ||
echo "[*] Verifying deps..." | ||
hack/verify-deps.sh || res=1 | ||
cd "${REPO_PATH}" | ||
fi | ||
|
||
if [[ "${VERIFY_GOTEST:-true}" == "true" ]]; then | ||
echo "[*] Verifying gotest..." | ||
hack/verify-gotest.sh || res=1 | ||
cd "${REPO_PATH}" | ||
fi | ||
|
||
if [[ "${VERIFY_BUILD:-true}" == "true" ]]; then | ||
echo "[*] Verifying build..." | ||
hack/verify-build.sh || res=1 | ||
cd "${REPO_PATH}" | ||
fi | ||
|
||
# exit based on verify scripts | ||
if [[ "${res}" = 0 ]]; then | ||
echo "" | ||
echo "All verify checks passed, congrats!" | ||
else | ||
echo "" | ||
echo "One or more verify checks failed! See output above..." | ||
fi | ||
exit "${res}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bash | ||
# Copyright 2019 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 | ||
|
||
# shellcheck source=/dev/null | ||
source "$(dirname "$0")/utils.sh" | ||
|
||
# check if the code builds | ||
cd_root_path | ||
export GO111MODULE=on | ||
go build ./cmd/... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env bash | ||
# Copyright 2019 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 nounset | ||
set -o pipefail | ||
|
||
# shellcheck source=/dev/null | ||
source "$(dirname "$0")/utils.sh" | ||
# cd to the root path | ||
cd_root_path | ||
|
||
# cleanup on exit | ||
cleanup() { | ||
echo "Cleaning up..." | ||
mv go.mod.old go.mod | ||
mv go.sum.old go.sum | ||
} | ||
trap cleanup EXIT | ||
|
||
echo "Verifying..." | ||
# temporary copy the go mod and sum files | ||
cp go.mod go.mod.old || exit | ||
cp go.sum go.sum.old || exit | ||
|
||
# run update-deps.sh | ||
export GO111MODULE="on" | ||
./hack/update-deps.sh | ||
|
||
# compare the old and new files | ||
DIFF0=$(diff -u go.mod go.mod.old) | ||
DIFF1=$(diff -u go.sum go.sum.old) | ||
|
||
if [[ -n "${DIFF0}" ]] || [[ -n "${DIFF1}" ]]; then | ||
echo "${DIFF0}" | ||
echo "${DIFF1}" | ||
echo "Check failed. Please run ./hack/update-deps.sh" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env bash | ||
# Copyright 2019 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 | ||
|
||
# shellcheck source=/dev/null | ||
source "$(dirname "$0")/utils.sh" | ||
# cd to the root path | ||
cd_root_path | ||
|
||
# check for gofmt diffs | ||
diff=$(git ls-files | grep "\.go" | grep -v "\/vendor" | xargs gofmt -s -d 2>&1) | ||
if [[ -n "${diff}" ]]; then | ||
echo "${diff}" | ||
echo | ||
echo "Check failed. Please run hack/update-gofmt.sh" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env bash | ||
# Copyright 2019 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 | ||
|
||
# shellcheck source=/dev/null | ||
source "$(dirname "$0")/utils.sh" | ||
# cd to the root path | ||
cd_root_path | ||
|
||
# run go test | ||
export GO111MODULE=on | ||
go test ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bash | ||
# Copyright 2019 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 vet over our code | ||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
# shellcheck source=/dev/null | ||
source "$(dirname "$0")/utils.sh" | ||
# cd to the root path | ||
cd_root_path | ||
|
||
# run go vet | ||
export GO111MODULE=on | ||
go vet ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env bash | ||
# Copyright 2019 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 | ||
|
||
# shellcheck source=/dev/null | ||
source "$(dirname "$0")/utils.sh" | ||
ROOT_PATH=$(get_root_path) | ||
|
||
# create a temporary directory | ||
TMP_DIR=$(mktemp -d) | ||
|
||
# cleanup on exit | ||
cleanup() { | ||
echo "Cleaning up..." | ||
rm -rf "${TMP_DIR}" | ||
} | ||
trap cleanup EXIT | ||
|
||
# install shellcheck (Linux-x64 only!) | ||
cd "${TMP_DIR}" || exit | ||
VERSION="shellcheck-v0.6.0" | ||
DOWNLOAD_FILE="${VERSION}.linux.x86_64.tar.xz" | ||
wget https://storage.googleapis.com/shellcheck/"${DOWNLOAD_FILE}" | ||
tar xf "${DOWNLOAD_FILE}" | ||
cd "${VERSION}" || exit | ||
|
||
echo "Running shellcheck..." | ||
cd "${ROOT_PATH}" || exit | ||
OUT="${TMP_DIR}/out.log" | ||
FILES=$(find . -name "*.sh") | ||
while read -r file; do | ||
"${TMP_DIR}/${VERSION}/shellcheck" "$file" >> "${OUT}" 2>&1 | ||
done <<< "$FILES" | ||
|
||
if [[ -s "${OUT}" ]]; then | ||
echo "Found errors:" | ||
cat "${OUT}" | ||
exit 1 | ||
fi |