upgrade to latest dependencies (#5131)

bumping knative.dev/hack a645040...123a278:
  > 123a278 🧹 Migrate to using the `go run` instead of `go install` (# 172)

Signed-off-by: Knative Automation <automation@knative.team>
This commit is contained in:
knative-automation 2022-07-25 06:55:24 -04:00 committed by GitHub
parent 62a338af5b
commit 934286a61b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 78 additions and 53 deletions

2
go.mod
View File

@ -28,7 +28,7 @@ require (
gopkg.in/go-playground/webhooks.v3 v3.13.0 gopkg.in/go-playground/webhooks.v3 v3.13.0
gopkg.in/yaml.v2 v2.3.0 gopkg.in/yaml.v2 v2.3.0
honnef.co/go/tools v0.0.1-2020.1.5 // indirect honnef.co/go/tools v0.0.1-2020.1.5 // indirect
knative.dev/hack v0.0.0-20220721014222-a6450400b5f1 knative.dev/hack v0.0.0-20220722185521-123a2783c4d8
) )
replace go.opencensus.io => go.opencensus.io v0.20.2 replace go.opencensus.io => go.opencensus.io v0.20.2

4
go.sum
View File

@ -538,8 +538,8 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.0.1-2020.1.5 h1:nI5egYTGJakVyOryqLs1cQO5dO0ksin5XXs2pspk75k= honnef.co/go/tools v0.0.1-2020.1.5 h1:nI5egYTGJakVyOryqLs1cQO5dO0ksin5XXs2pspk75k=
honnef.co/go/tools v0.0.1-2020.1.5/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.5/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
knative.dev/hack v0.0.0-20220721014222-a6450400b5f1 h1:t6jYBtJwVhyx+48cidFj1ckYAlMesS0yCnAlW2BJyNo= knative.dev/hack v0.0.0-20220722185521-123a2783c4d8 h1:nqgnAXhOPokDf/BumO5aTqEo7R1+mhMVcjmGVft7vUM=
knative.dev/hack v0.0.0-20220721014222-a6450400b5f1/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI= knative.dev/hack v0.0.0-20220722185521-123a2783c4d8/go.mod h1:t/azP8I/Cygaw+87O7rkAPrNRjCelmtfSzWzu/9TM7I=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=

View File

@ -1,3 +1,3 @@
module knative.dev/hack module knative.dev/hack
go 1.14 go 1.17

View File

@ -17,7 +17,7 @@
# This is a collection of functions for infra related setups, mainly # This is a collection of functions for infra related setups, mainly
# cluster provisioning. It doesn't do anything when called from command line. # cluster provisioning. It doesn't do anything when called from command line.
source $(dirname "${BASH_SOURCE[0]}")/library.sh source "$(dirname "${BASH_SOURCE[0]:-$0}")/library.sh"
# Dumps the k8s api server metrics. Spins up a proxy, waits a little bit and # Dumps the k8s api server metrics. Spins up a proxy, waits a little bit and
# dumps the metrics to ${ARTIFACTS}/k8s.metrics.txt # dumps the metrics to ${ARTIFACTS}/k8s.metrics.txt

View File

@ -40,7 +40,7 @@ fi
readonly IS_PROW readonly IS_PROW
[[ ! -v REPO_ROOT_DIR ]] && REPO_ROOT_DIR="$(git rev-parse --show-toplevel)" [[ ! -v REPO_ROOT_DIR ]] && REPO_ROOT_DIR="$(git rev-parse --show-toplevel)"
readonly REPO_ROOT_DIR readonly REPO_ROOT_DIR
readonly REPO_NAME="$(basename ${REPO_ROOT_DIR})" readonly REPO_NAME="${REPO_NAME:-$(basename "${REPO_ROOT_DIR}")}"
# Useful flags about the current OS # Useful flags about the current OS
IS_LINUX=0 IS_LINUX=0
@ -56,10 +56,15 @@ readonly IS_LINUX
readonly IS_OSX readonly IS_OSX
readonly IS_WINDOWS readonly IS_WINDOWS
export TMPDIR="${TMPDIR:-$(mktemp -u -t -d knative.XXXXXXXX)}"
mkdir -p "$TMPDIR"
# Set ARTIFACTS to an empty temp dir if unset # Set ARTIFACTS to an empty temp dir if unset
if [[ -z "${ARTIFACTS:-}" ]]; then if [[ -z "${ARTIFACTS:-}" ]]; then
export ARTIFACTS="$(mktemp -d)" ARTIFACTS="$(mktemp -u -t -d)"
export ARTIFACTS
fi fi
mkdir -p "$ARTIFACTS"
# On a Prow job, redirect stderr to stdout so it's synchronously added to log # On a Prow job, redirect stderr to stdout so it's synchronously added to log
(( IS_PROW )) && exec 2>&1 (( IS_PROW )) && exec 2>&1
@ -429,7 +434,7 @@ function mktemp_with_extension() {
function create_junit_xml() { function create_junit_xml() {
local xml local xml
xml="$(mktemp_with_extension "${ARTIFACTS}"/junit_XXXXXXXX xml)" xml="$(mktemp_with_extension "${ARTIFACTS}"/junit_XXXXXXXX xml)"
echo "JUnit file ${xml} is created for reporting the test result" echo "XML report for $1::$2 written to ${xml}"
run_kntest junit --suite="$1" --name="$2" --err-msg="$3" --dest="${xml}" || return 1 run_kntest junit --suite="$1" --name="$2" --err-msg="$3" --dest="${xml}" || return 1
} }
@ -437,37 +442,38 @@ function create_junit_xml() {
# Parameters: $1... - parameters to go test # Parameters: $1... - parameters to go test
function report_go_test() { function report_go_test() {
local go_test_args=( "$@" ) local go_test_args=( "$@" )
# Install gotestsum if necessary. local logfile xml ansilog htmllog
run_go_tool gotest.tools/gotestsum gotestsum --help > /dev/null 2>&1
# Capture the test output to the report file.
local report
report="$(mktemp)"
local xml
xml="$(mktemp_with_extension "${ARTIFACTS}"/junit_XXXXXXXX xml)" xml="$(mktemp_with_extension "${ARTIFACTS}"/junit_XXXXXXXX xml)"
# Keep the suffix, so files are related.
logfile="${xml/junit_/go_test_}"
logfile="${logfile/.xml/.jsonl}"
echo "Running go test with args: ${go_test_args[*]}" echo "Running go test with args: ${go_test_args[*]}"
capture_output "${report}" gotestsum --format "${GO_TEST_VERBOSITY:-testname}" \ go_run gotest.tools/gotestsum@v1.8.0 \
--junitfile "${xml}" --junitfile-testsuite-name relative --junitfile-testcase-classname relative \ --format "${GO_TEST_VERBOSITY:-testname}" \
--junitfile "${xml}" \
--junitfile-testsuite-name relative \
--junitfile-testcase-classname relative \
--jsonfile "${logfile}" \
-- "${go_test_args[@]}" -- "${go_test_args[@]}"
local failed=$? local gotest_retcode=$?
echo "Finished run, return code is ${failed}" echo "Finished run, return code is ${gotest_retcode}"
echo "XML report written to ${xml}" echo "XML report written to ${xml}"
if [[ -n "$(grep '<testsuites></testsuites>' "${xml}")" ]]; then echo "Test log (JSONL) written to ${logfile}"
# XML report is empty, something's wrong; use the output as failure reason
create_junit_xml _go_tests "GoTests" "$(cat "${report}")" ansilog="${logfile/.jsonl/-ansi.log}"
fi go_run github.com/haveyoudebuggedit/gotestfmt/v2/cmd/gotestfmt@v2.3.1 \
# Capture and report any race condition errors -input "${logfile}" \
local race_errors -showteststatus \
race_errors="$(sed -n '/^WARNING: DATA RACE$/,/^==================$/p' "${report}")" -nofail > "$ansilog"
create_junit_xml _go_tests "DataRaceAnalysis" "${race_errors}" echo "Test log (ANSI) written to ${ansilog}"
if (( ! IS_PROW )); then
# Keep the suffix, so files are related. htmllog="${logfile/.jsonl/.html}"
local logfile=${xml/junit_/go_test_} go_run github.com/buildkite/terminal-to-html/v3/cmd/terminal-to-html@v3.6.1 \
logfile=${logfile/.xml/.log} --preview < "$ansilog" > "$htmllog"
cp "${report}" "${logfile}" echo "Test log (HTML) written to ${htmllog}"
echo "Test log written to ${logfile}"
fi return ${gotest_retcode}
return ${failed}
} }
# Install Knative Serving in the current cluster. # Install Knative Serving in the current cluster.
@ -543,24 +549,45 @@ function start_latest_eventing_sugar_controller() {
start_knative_eventing_extension "${KNATIVE_EVENTING_SUGAR_CONTROLLER_RELEASE}" "knative-eventing" start_knative_eventing_extension "${KNATIVE_EVENTING_SUGAR_CONTROLLER_RELEASE}" "knative-eventing"
} }
# Run a go utility without installing it.
# Parameters: $1 - tool package for go run.
# $2..$n - parameters passed to the tool.
function go_run() {
local package
package="$1"
if [[ "$package" != *@* ]]; then
abort 'Package for "go_run" needs to have @version'
fi
if [[ "$package" == *@latest ]] && [[ "$package" != knative.dev* ]]; then
warning 'Using @latest version for external dependencies is unsafe. Use numbered version!'
fi
shift 1
GORUN_PATH="${GORUN_PATH:-$(go env GOPATH)}"
# Some CI environments may have non-writable GOPATH
if ! [ -w "${GORUN_PATH}" ]; then
GORUN_PATH="$(mktemp -t -d -u gopath.XXXXXXXX)"
fi
export GORUN_PATH
GOPATH="${GORUN_PATH}" \
GOFLAGS='' \
GO111MODULE='' \
go run "$package" "$@"
}
# Run a go tool, installing it first if necessary. # Run a go tool, installing it first if necessary.
# Parameters: $1 - tool package/dir for go install. # Parameters: $1 - tool package/dir for go install.
# $2 - tool to run. # $2 - tool to run.
# $3..$n - parameters passed to the tool. # $3..$n - parameters passed to the tool.
# Deprecated: use go_run instead
function run_go_tool() { function run_go_tool() {
warning 'The "run_go_tool" function is deprecated. Use "go_run" instead.'
local package=$1 local package=$1
local tool=$2
local install_failed=0
# If no `@version` is provided, default to adding `@latest` # If no `@version` is provided, default to adding `@latest`
if [[ "$package" != *@* ]]; then if [[ "$package" != *@* ]]; then
package=$package@latest package=$package@latest
fi fi
if [[ -z "$(which ${tool})" ]]; then
GOFLAGS="" go install "$package" || install_failed=1
fi
(( install_failed )) && return ${install_failed}
shift 2 shift 2
${tool} "$@" go_run "$package" "$@"
} }
# Add function call to trap # Add function call to trap
@ -623,7 +650,7 @@ function go_update_deps() {
else else
group "Upgrading to release ${RELEASE}" group "Upgrading to release ${RELEASE}"
fi fi
FLOATING_DEPS+=( $(run_go_tool knative.dev/test-infra/buoy buoy float ${REPO_ROOT_DIR}/go.mod "${buoyArgs[@]}") ) FLOATING_DEPS+=( $(go_run knative.dev/test-infra/buoy@latest buoy float ${REPO_ROOT_DIR}/go.mod "${buoyArgs[@]}") )
if [[ ${#FLOATING_DEPS[@]} > 0 ]]; then if [[ ${#FLOATING_DEPS[@]} > 0 ]]; then
echo "Floating deps to ${FLOATING_DEPS[@]}" echo "Floating deps to ${FLOATING_DEPS[@]}"
go get -d ${FLOATING_DEPS[@]} go get -d ${FLOATING_DEPS[@]}
@ -684,13 +711,10 @@ function go_mod_gopath_hack() {
echo "${TMP_DIR}" echo "${TMP_DIR}"
} }
# Run kntest tool, error out and ask users to install it if it's not currently installed. # Run kntest tool
# Parameters: $1..$n - parameters passed to the tool. # Parameters: $1..$n - parameters passed to the tool.
function run_kntest() { function run_kntest() {
if [[ ! -x "$(command -v kntest)" ]]; then go_run knative.dev/test-infra/tools/kntest/cmd/kntest@latest "$@"
echo "--- FAIL: kntest not installed, please clone knative test-infra repo and run \`go install ./tools/kntest/cmd/kntest\` to install it"; return 1;
fi
kntest "$@"
} }
# Run go-licenses to update licenses. # Run go-licenses to update licenses.
@ -701,14 +725,16 @@ function update_licenses() {
local dst=$1 local dst=$1
local dir=$2 local dir=$2
shift shift
run_go_tool github.com/google/go-licenses go-licenses save "${dir}" --save_path="${dst}" --force || \ go_run github.com/google/go-licenses@v1.2.0 \
save "${dir}" --save_path="${dst}" --force || \
{ echo "--- FAIL: go-licenses failed to update licenses"; return 1; } { echo "--- FAIL: go-licenses failed to update licenses"; return 1; }
} }
# Run go-licenses to check for forbidden licenses. # Run go-licenses to check for forbidden licenses.
function check_licenses() { function check_licenses() {
# Check that we don't have any forbidden licenses. # Check that we don't have any forbidden licenses.
run_go_tool github.com/google/go-licenses go-licenses check "${REPO_ROOT_DIR}/..." || \ go_run github.com/google/go-licenses@v1.2.0 \
check "${REPO_ROOT_DIR}/..." || \
{ echo "--- FAIL: go-licenses failed the license check"; return 1; } { echo "--- FAIL: go-licenses failed the license check"; return 1; }
} }

View File

@ -185,7 +185,7 @@ function run_unit_tests() {
# Default unit test runner that runs all go tests in the repo. # Default unit test runner that runs all go tests in the repo.
function default_unit_test_runner() { function default_unit_test_runner() {
report_go_test -race -count 1 ./... report_go_test -short -race -count 1 ./...
} }
# Run integration tests. If there's no `integration_tests` function, run the # Run integration tests. If there's no `integration_tests` function, run the

View File

@ -18,7 +18,6 @@
# See README.md for instructions on how to use it. # See README.md for instructions on how to use it.
source $(dirname "${BASH_SOURCE[0]}")/library.sh source $(dirname "${BASH_SOURCE[0]}")/library.sh
set -x
# Organization name in GitHub; defaults to Knative. # Organization name in GitHub; defaults to Knative.
readonly ORG_NAME="${ORG_NAME:-knative}" readonly ORG_NAME="${ORG_NAME:-knative}"
@ -108,7 +107,7 @@ export GITHUB_TOKEN=""
# Convenience function to run the hub tool. # Convenience function to run the hub tool.
# Parameters: $1..$n - arguments to hub. # Parameters: $1..$n - arguments to hub.
function hub_tool() { function hub_tool() {
run_go_tool github.com/github/hub hub $@ gorun github.com/github/hub@v2.14.2 "$@"
} }
# Shortcut to "git push" that handles authentication. # Shortcut to "git push" that handles authentication.

2
vendor/modules.txt vendored
View File

@ -286,7 +286,7 @@ gopkg.in/go-playground/webhooks.v3/github
gopkg.in/yaml.v2 gopkg.in/yaml.v2
# honnef.co/go/tools v0.0.1-2020.1.5 # honnef.co/go/tools v0.0.1-2020.1.5
## explicit ## explicit
# knative.dev/hack v0.0.0-20220721014222-a6450400b5f1 # knative.dev/hack v0.0.0-20220722185521-123a2783c4d8
## explicit ## explicit
knative.dev/hack knative.dev/hack
# go.opencensus.io => go.opencensus.io v0.20.2 # go.opencensus.io => go.opencensus.io v0.20.2