Skip to content

Commit 783f195

Browse files
authored
Merge pull request #7462 from oscr/add-shell-script-tracing
✨ Add environment variable to enable tracing for hack/ shell scripts
2 parents d1ec32a + ecece95 commit 783f195

15 files changed

+65
-9
lines changed

Makefile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ export KUBEBUILDER_CONTROLPLANE_STOP_TIMEOUT ?= 60s
4646
# This option is for running docker manifest command
4747
export DOCKER_CLI_EXPERIMENTAL := enabled
4848

49+
# Enables shell script tracing. Enable by running: TRACE=1 make <target>
50+
TRACE ?= 0
51+
4952
#
5053
# Directories.
5154
#
@@ -556,7 +559,7 @@ lint-fix: $(GOLANGCI_LINT) ## Lint the codebase and run auto-fixers if supported
556559

557560
.PHONY: tiltfile-fix
558561
tiltfile-fix: ## Format the Tiltfile
559-
./hack/verify-starlark.sh fix
562+
TRACE=$(TRACE) ./hack/verify-starlark.sh fix
560563

561564
APIDIFF_OLD_COMMIT ?= $(shell git rev-parse origin/main)
562565

@@ -593,23 +596,23 @@ verify-conversions: $(CONVERSION_VERIFIER) ## Verifies expected API conversion
593596

594597
.PHONY: verify-doctoc
595598
verify-doctoc:
596-
./hack/verify-doctoc.sh
599+
TRACE=$(TRACE) ./hack/verify-doctoc.sh
597600

598601
.PHONY: verify-capi-book-summary
599602
verify-capi-book-summary:
600-
./hack/verify-capi-book-summary.sh
603+
TRACE=$(TRACE) ./hack/verify-capi-book-summary.sh
601604

602605
.PHONY: verify-boilerplate
603606
verify-boilerplate: ## Verify boilerplate text exists in each file
604-
./hack/verify-boilerplate.sh
607+
TRACE=$(TRACE) ./hack/verify-boilerplate.sh
605608

606609
.PHONY: verify-shellcheck
607610
verify-shellcheck: ## Verify shell files
608-
./hack/verify-shellcheck.sh
611+
TRACE=$(TRACE) ./hack/verify-shellcheck.sh
609612

610613
.PHONY: verify-tiltfile
611614
verify-tiltfile: ## Verify Tiltfile format
612-
./hack/verify-starlark.sh
615+
TRACE=$(TRACE) ./hack/verify-starlark.sh
613616

614617
## --------------------------------------
615618
## Binaries

hack/ensure-go.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ set -o errexit
1818
set -o nounset
1919
set -o pipefail
2020

21+
if [[ "${TRACE-0}" == "1" ]]; then
22+
set -o xtrace
23+
fi
24+
2125
# Ensure the go tool exists and is a viable version.
2226
verify_go_version() {
2327
if [[ -z "$(command -v go)" ]]; then

hack/ensure-golangci-lint.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818

1919
set -e
2020

21+
if [[ "${TRACE-0}" == "1" ]]; then
22+
set -o xtrace
23+
fi
24+
2125
usage() {
2226
this=$1
2327
cat <<EOF
@@ -42,12 +46,11 @@ parse_args() {
4246
# over-ridden by flag below
4347

4448
BINDIR=${BINDIR:-./bin}
45-
while getopts "b:dh?x" arg; do
49+
while getopts "b:dh?" arg; do
4650
case "$arg" in
4751
b) BINDIR="$OPTARG" ;;
4852
d) log_set_priority 10 ;;
4953
h | \?) usage "$0" ;;
50-
x) set -x ;;
5154
esac
5255
done
5356
shift $((OPTIND - 1))

hack/ensure-kind.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ set -o errexit
1818
set -o nounset
1919
set -o pipefail
2020

21-
set -x
21+
if [[ "${TRACE-0}" == "1" ]]; then
22+
set -o xtrace
23+
fi
2224

2325
GOPATH_BIN="$(go env GOPATH)/bin"
2426
MINIMUM_KIND_VERSION=v0.17.0

hack/ensure-kubectl.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ set -o errexit
1818
set -o nounset
1919
set -o pipefail
2020

21+
if [[ "${TRACE-0}" == "1" ]]; then
22+
set -o xtrace
23+
fi
24+
2125
GOPATH_BIN="$(go env GOPATH)/bin/"
2226
MINIMUM_KUBECTL_VERSION=v1.19.0
2327
goarch="$(go env GOARCH)"

hack/get-project-maintainers.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ set -o errexit
1818
set -o nounset
1919
set -o pipefail
2020

21+
if [[ "${TRACE-0}" == "1" ]]; then
22+
set -o xtrace
23+
fi
24+
2125
REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
2226

2327
YQ_BIN=yq

hack/kind-install-for-capd.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ set -o errexit
2626
set -o nounset
2727
set -o pipefail
2828

29+
if [[ "${TRACE-0}" == "1" ]]; then
30+
set -o xtrace
31+
fi
32+
2933
KIND_CLUSTER_NAME=${CAPI_KIND_CLUSTER_NAME:-"capi-test"}
3034

3135
if [[ "$(kind get clusters)" =~ .*"${KIND_CLUSTER_NAME}".* ]]; then

hack/pin-dependency.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ set -o errexit
1818
set -o nounset
1919
set -o pipefail
2020

21+
if [[ "${TRACE-0}" == "1" ]]; then
22+
set -o xtrace
23+
fi
24+
2125
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
2226

2327
# Usage:

hack/setup-envtest-with-kind.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ set -o errexit
1818
set -o nounset
1919
set -o pipefail
2020

21+
if [[ "${TRACE-0}" == "1" ]]; then
22+
set -o xtrace
23+
fi
24+
2125
os="unknown"
2226
if [[ "${OSTYPE}" == "linux"* ]]; then
2327
os="linux"

hack/verify-boilerplate.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ set -o errexit
1818
set -o nounset
1919
set -o pipefail
2020

21+
if [[ "${TRACE-0}" == "1" ]]; then
22+
set -o xtrace
23+
fi
24+
2125
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
2226

2327
boilerDir="${KUBE_ROOT}/hack/boilerplate"

hack/verify-capi-book-summary.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ set -o errexit
1818
set -o nounset
1919
set -o pipefail
2020

21+
if [[ "${TRACE-0}" == "1" ]]; then
22+
set -o xtrace
23+
fi
24+
2125
RESULT=0
2226
SUMMARY=$(cat ./docs/book/src/SUMMARY.md)
2327

hack/verify-doctoc.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ set -o errexit
1818
set -o nounset
1919
set -o pipefail
2020

21+
if [[ "${TRACE-0}" == "1" ]]; then
22+
set -o xtrace
23+
fi
24+
2125
command -v doctoc || echo "doctoc is not available on your system, skipping verification" && exit 0
2226

2327
doctoc_files="README.md \

hack/verify-shellcheck.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ set -o errexit
1717
set -o nounset
1818
set -o pipefail
1919

20+
if [[ "${TRACE-0}" == "1" ]]; then
21+
set -o xtrace
22+
fi
23+
2024
VERSION="v0.8.0"
2125

2226
OS="unknown"

hack/verify-starlark.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ set -o errexit
1717
set -o nounset
1818
set -o pipefail
1919

20+
if [[ "${TRACE-0}" == "1" ]]; then
21+
set -o xtrace
22+
fi
23+
2024
SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
2125
ROOT_PATH="$(cd "${SCRIPT_DIR}"/.. && pwd)"
2226

hack/version.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ set -o errexit
1717
set -o nounset
1818
set -o pipefail
1919

20+
if [[ "${TRACE-0}" == "1" ]]; then
21+
set -o xtrace
22+
fi
23+
2024
version::get_version_vars() {
2125
# shellcheck disable=SC1083
2226
GIT_COMMIT="$(git rev-parse HEAD^{commit})"

0 commit comments

Comments
 (0)