Merge pull request #123647 from thockin/use_go_-C_instead_of_pushd_popd

Change `pushd $d; go ...; popd` to `go -C $d ...`
This commit is contained in:
Kubernetes Prow Robot 2024-03-02 16:41:56 -08:00 committed by GitHub
commit 19df52c41a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 19 additions and 41 deletions

View File

@ -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=" "

View File

@ -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"

View File

@ -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)

View File

@ -190,10 +190,8 @@ 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
@ -201,10 +199,8 @@ produceJUnitXMLReport() {
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}"

View File

@ -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 \

View File

@ -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}"

View File

@ -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}"

View File

@ -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
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 build -o "${GOBIN}/logcheck.so" -buildmode=plugin sigs.k8s.io/logtools/logcheck/plugin
fi
popd >/dev/null
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

View File

@ -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