Skip to content

Commit

Permalink
Merge pull request kubernetes#123647 from thockin/use_go_-C_instead_o…
Browse files Browse the repository at this point in the history
…f_pushd_popd

Change `pushd $d; go ...; popd` to `go -C $d ...`
  • Loading branch information
k8s-ci-robot committed Mar 3, 2024
2 parents 38e5a29 + a0215ba commit 19df52c
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 41 deletions.
6 changes: 2 additions & 4 deletions hack/jenkins/benchmark-dockerized.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,8 @@ export PATH=${GOPATH}/bin:${PWD}/third_party/etcd:/usr/local/go/bin:${PATH}
export GO111MODULE=off

# Install tools we need
pushd "${KUBE_ROOT}/hack/tools" >/dev/null
GO111MODULE=on go install github.com/cespare/prettybench
GO111MODULE=on go install gotest.tools/gotestsum
popd >/dev/null
GO111MODULE=on go -C "${KUBE_ROOT}/hack/tools" install github.com/cespare/prettybench
GO111MODULE=on go -C "${KUBE_ROOT}/hack/tools" install gotest.tools/gotestsum

# Disable the Go race detector.
export KUBE_RACE=" "
Expand Down
4 changes: 1 addition & 3 deletions hack/jenkins/test-dockerized.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ export PATH=${GOPATH}/bin:${PWD}/third_party/etcd:/usr/local/go/bin:${PATH}
export GO111MODULE=off

# Install tools we need
pushd "./hack/tools" >/dev/null
GO111MODULE=on go install gotest.tools/gotestsum
popd >/dev/null
GO111MODULE=on go -C "./hack/tools" install gotest.tools/gotestsum

# Disable coverage report
export KUBE_COVER="n"
Expand Down
6 changes: 1 addition & 5 deletions hack/lib/golang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -599,11 +599,7 @@ kube::golang::setup_gomaxprocs() {
# when running in a container, please see https://github.com/golang/go/issues/33803
if [[ -z "${GOMAXPROCS:-}" ]]; then
if ! command -v ncpu >/dev/null 2>&1; then
# shellcheck disable=SC2164
pushd "${KUBE_ROOT}/hack/tools" >/dev/null
go install ./ncpu || echo "Will not automatically set GOMAXPROCS"
# shellcheck disable=SC2164
popd >/dev/null
go -C "${KUBE_ROOT}/hack/tools" install ./ncpu || echo "Will not automatically set GOMAXPROCS"
fi
if command -v ncpu >/dev/null 2>&1; then
GOMAXPROCS=$(ncpu)
Expand Down
12 changes: 4 additions & 8 deletions hack/make-rules/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -190,21 +190,17 @@ produceJUnitXMLReport() {
junit_xml_filename="${junit_filename_prefix}.xml"

if ! command -v gotestsum >/dev/null 2>&1; then
kube::log::status "gotestsum not found; installing from hack/tools"
pushd "${KUBE_ROOT}/hack/tools" >/dev/null
go install gotest.tools/gotestsum
popd >/dev/null
kube::log::status "gotestsum not found; installing from ./hack/tools"
go -C "${KUBE_ROOT}/hack/tools" install gotest.tools/gotestsum
fi
gotestsum --junitfile "${junit_xml_filename}" --raw-command cat "${junit_filename_prefix}"*.stdout
if [[ ! ${KUBE_KEEP_VERBOSE_TEST_OUTPUT} =~ ^[yY]$ ]]; then
rm "${junit_filename_prefix}"*.stdout
fi

if ! command -v prune-junit-xml >/dev/null 2>&1; then
kube::log::status "prune-junit-xml not found; installing from hack/tools"
pushd "${KUBE_ROOT}/cmd/prune-junit-xml" >/dev/null
go install .
popd >/dev/null
kube::log::status "prune-junit-xml not found; installing from ./cmd"
go -C "${KUBE_ROOT}/cmd/prune-junit-xml" install .
fi
prune-junit-xml "${junit_xml_filename}"

Expand Down
4 changes: 1 addition & 3 deletions hack/update-mocks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ source "${KUBE_ROOT}/hack/lib/init.sh"
kube::golang::setup_env

echo 'installing mockgen'
pushd "${KUBE_ROOT}/hack/tools" >/dev/null
go install github.com/golang/mock/mockgen
popd >/dev/null
go -C "${KUBE_ROOT}/hack/tools" install github.com/golang/mock/mockgen

function git_grep() {
git grep --untracked --exclude-standard \
Expand Down
4 changes: 1 addition & 3 deletions hack/update-netparse-cve.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ PATH="${GOBIN}:${PATH}"

# Install golangci-lint
echo 'installing net parser converter'
pushd "${KUBE_ROOT}/hack/tools" >/dev/null
go install github.com/aojea/sloppy-netparser
popd >/dev/null
go -C "${KUBE_ROOT}/hack/tools" install github.com/aojea/sloppy-netparser

cd "${KUBE_ROOT}"

Expand Down
4 changes: 1 addition & 3 deletions hack/update-vanity-imports.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ source "${KUBE_ROOT}/hack/lib/init.sh"

kube::golang::verify_go_version

pushd "${KUBE_ROOT}/hack/tools" >/dev/null
go install github.com/jcchavezs/porto/cmd/porto
popd >/dev/null
go -C "${KUBE_ROOT}/hack/tools" install github.com/jcchavezs/porto/cmd/porto

porto --restrict-to-dirs="staging" --restrict-to-files="doc\\.go$" -w "${KUBE_ROOT}"

16 changes: 7 additions & 9 deletions hack/verify-golangci-lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,13 @@ done

# Install golangci-lint
echo "installing golangci-lint and logcheck plugin from hack/tools into ${GOBIN}"
pushd "${KUBE_ROOT}/hack/tools" >/dev/null
go install github.com/golangci/golangci-lint/cmd/golangci-lint
if [ "${golangci_config}" ]; then
# This cannot be used without a config.
# This uses `go build` because `go install -buildmode=plugin` doesn't work
# (on purpose: https://github.com/golang/go/issues/64964).
go build -o "${GOBIN}/logcheck.so" -buildmode=plugin sigs.k8s.io/logtools/logcheck/plugin
fi
popd >/dev/null
go -C "${KUBE_ROOT}/hack/tools" install github.com/golangci/golangci-lint/cmd/golangci-lint
if [ "${golangci_config}" ]; then
# This cannot be used without a config.
# This uses `go build` because `go install -buildmode=plugin` doesn't work
# (on purpose: https://github.com/golang/go/issues/64964).
go -C "${KUBE_ROOT}/hack/tools" build -o "${GOBIN}/logcheck.so" -buildmode=plugin sigs.k8s.io/logtools/logcheck/plugin
fi

if [ "${golangci_config}" ]; then
# The relative path to _output/local/bin only works if that actually is the
Expand Down
4 changes: 1 addition & 3 deletions hack/verify-spelling.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ export GOBIN="${KUBE_OUTPUT_BIN}"
PATH="${GOBIN}:${PATH}"

# Install tools we need
pushd "${KUBE_ROOT}/hack/tools" >/dev/null
go install github.com/client9/misspell/cmd/misspell
popd >/dev/null
go -C "${KUBE_ROOT}/hack/tools" install github.com/client9/misspell/cmd/misspell

# Spell checking
# All the skipping files are defined in hack/.spelling_failures
Expand Down

0 comments on commit 19df52c

Please sign in to comment.