[master] Auto-update dependencies (#2440)

Produced via:
  `./hack/update-deps.sh --upgrade && ./hack/update-codegen.sh`
/assign dprotaso grantr samodell
/cc dprotaso grantr samodell
This commit is contained in:
Matt Moore 2020-05-12 14:41:57 -07:00 committed by GitHub
parent ac18814564
commit c4b64a7a39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 85 additions and 37 deletions

4
Gopkg.lock generated
View File

@ -501,14 +501,14 @@
[[projects]]
branch = "master"
digest = "1:4fc77d1a195bf1eceaa2842e03d195140c03415c7645a11a07bf8cabc3b2a65d"
digest = "1:a0273906fa66a9119bf8a8b8b373084190cfb8a44a176d2d02b48cf46302ce40"
name = "knative.dev/test-infra"
packages = [
"scripts",
"tools/dep-collector",
]
pruneopts = "UT"
revision = "e71b1288c15c09476899c526a0d0b0ef7d2d7f20"
revision = "371b0a511a3b2d8e6e24f3bd880e32a48b426f5b"
[solve-meta]
analyzer-name = "dep"

View File

@ -26,7 +26,7 @@ readonly SERVING_GKE_VERSION=gke-latest
readonly SERVING_GKE_IMAGE=cos
# Conveniently set GOPATH if unset
if [[ -z "${GOPATH:-}" ]]; then
if [[ ! -v GOPATH ]]; then
export GOPATH="$(go env GOPATH)"
if [[ -z "${GOPATH}" ]]; then
echo "WARNING: GOPATH not set and go binary unable to provide it"
@ -34,9 +34,9 @@ if [[ -z "${GOPATH:-}" ]]; then
fi
# Useful environment variables
[[ -n "${PROW_JOB_ID:-}" ]] && IS_PROW=1 || IS_PROW=0
[[ -v PROW_JOB_ID ]] && IS_PROW=1 || IS_PROW=0
readonly IS_PROW
[[ -z "${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_NAME="$(basename ${REPO_ROOT_DIR})"
@ -389,8 +389,25 @@ function mktemp_with_extension() {
# $2 - check name as an identifier (e.g., GoBuild)
# $3 - failure message (can contain newlines), optional (means success)
function create_junit_xml() {
local xml="$(mktemp_with_extension "${ARTIFACTS}"/junit_XXXXXXXX xml)"
run_kntest junit --suite="$1" --name="$2" --err-msg="$3" --dest="${xml}" || return 1
local xml="$(mktemp_with_extension ${ARTIFACTS}/junit_XXXXXXXX xml)"
local failure=""
if [[ "$3" != "" ]]; then
# Transform newlines into HTML code.
# Also escape `<` and `>` as here: https://github.com/golang/go/blob/50bd1c4d4eb4fac8ddeb5f063c099daccfb71b26/src/encoding/json/encode.go#L48,
# this is temporary solution for fixing https://github.com/knative/test-infra/issues/1204,
# which should be obsolete once Test-infra 2.0 is in place
local msg="$(echo -n "$3" | sed 's/$/\&#xA;/g' | sed 's/</\\u003c/' | sed 's/>/\\u003e/' | sed 's/&/\\u0026/' | tr -d '\n')"
failure="<failure message=\"Failed\" type=\"\">${msg}</failure>"
fi
cat << EOF > "${xml}"
<testsuites>
<testsuite tests="1" failures="1" time="0.000" name="$1">
<testcase classname="" name="$2" time="0.0">
${failure}
</testcase>
</testsuite>
</testsuites>
EOF
}
# Runs a go test and generate a junit summary.
@ -499,24 +516,19 @@ function start_latest_knative_eventing() {
function run_go_tool() {
local tool=$2
local install_failed=0
local action="get"
[[ $1 =~ ^[\./].* ]] && action="install"
# Install the tool in the following situations:
# - The tool does not exist.
# - The tool needs to be installed from a local path.
# - Version of the tool is specificied in the given tool path.
# TODO(chizhg): derive a better versioning story for the tools being used.
if [[ -z "$(which "${tool}")" || "${action}" == "install" || "${tool}" =~ "@" ]]; then
if [[ -z "$(which ${tool})" ]]; then
local action=get
[[ $1 =~ ^[\./].* ]] && action=install
# Avoid running `go get` from root dir of the repository, as it can change go.sum and go.mod files.
# See discussions in https://github.com/golang/go/issues/27643.
if [[ ${action} == "get" && $(pwd) == "${REPO_ROOT_DIR}" ]]; then
local temp_dir="$(mktemp -d)"
# Swallow the output as we are returning the stdout in the end.
pushd "${temp_dir}" > /dev/null 2>&1
GOFLAGS="" go ${action} $1 || install_failed=1
GOFLAGS="" go ${action} "$1" || install_failed=1
popd > /dev/null 2>&1
else
GOFLAGS="" go ${action} $1 || install_failed=1
GOFLAGS="" go ${action} "$1" || install_failed=1
fi
fi
(( install_failed )) && return ${install_failed}
@ -524,17 +536,6 @@ function run_go_tool() {
${tool} "$@"
}
# Run "kntest" tool
# Parameters: $1..$n - parameters passed to the tool
function run_kntest() {
if [[ "${REPO_NAME}" == "test-infra" ]]; then
go run "${REPO_ROOT_DIR}"/kntest/cmd/kntest "$@"
else
# Always run the latest version.
run_go_tool knative.dev/test-infra/kntest/cmd/kntest@master "$@"
fi
}
# Run go-licenses to update licenses.
# Parameters: $1 - output file, relative to repo root dir.
# $2 - directory to inspect.
@ -652,6 +653,21 @@ function get_canonical_path() {
echo "$(cd ${path%/*} && echo $PWD/${path##*/})"
}
# List changed files in the current PR.
# This is implemented as a function so it can be mocked in unit tests.
# It will fail if a file name ever contained a newline character (which is bad practice anyway)
function list_changed_files() {
if [[ -v PULL_BASE_SHA ]] && [[ -v PULL_PULL_SHA ]]; then
# Avoid warning when there are more than 1085 files renamed:
# https://stackoverflow.com/questions/7830728/warning-on-diff-renamelimit-variable-when-doing-git-push
git config diff.renames 0
git --no-pager diff --name-only ${PULL_BASE_SHA}..${PULL_PULL_SHA}
else
# Do our best if not running in Prow
git diff --name-only HEAD^
fi
}
# Returns the current branch.
function current_branch() {
local branch_name=""
@ -694,6 +710,29 @@ function get_latest_knative_yaml_source() {
echo "https://storage.googleapis.com/knative-nightly/${repo_name}/latest/${yaml_name}.yaml"
}
function shellcheck_new_files() {
declare -a array_of_files
local failed=0
readarray -t -d '\n' array_of_files < <(list_changed_files)
for filename in "${array_of_files[@]}"; do
if echo "${filename}" | grep -q "^vendor/"; then
continue
fi
if file "${filename}" | grep -q "shell script"; then
# SC1090 is "Can't follow non-constant source"; we will scan files individually
if shellcheck -e SC1090 "${filename}"; then
echo "--- PASS: shellcheck on ${filename}"
else
echo "--- FAIL: shellcheck on ${filename}"
failed=1
fi
fi
done
if [[ ${failed} -eq 1 ]]; then
fail_script "shellcheck failures"
fi
}
# Initializations that depend on previous functions.
# These MUST come last.

View File

@ -46,15 +46,6 @@ function pr_only_contains() {
[[ -z "$(echo "${CHANGED_FILES}" | grep -v "\(${1// /\\|}\)$")" ]]
}
# List changed files in the current PR.
# This is implemented as a function so it can be mocked in unit tests.
function list_changed_files() {
# Avoid warning when there are more than 1085 files renamed:
# https://stackoverflow.com/questions/7830728/warning-on-diff-renamelimit-variable-when-doing-git-push
git config diff.renames 0
git --no-pager diff --name-only ${PULL_BASE_SHA}..${PULL_SHA}
}
# Initialize flags and context for presubmit tests:
# CHANGED_FILES, IS_PRESUBMIT_EXEMPT_PR and IS_DOCUMENTATION_PR.
function initialize_environment() {

View File

@ -0,0 +1,18 @@
#!/usr/bin/env bash
set -e
source "$(dirname "${BASH_SOURCE[0]}")/library.sh"
if (( ! IS_PROW )); then
echo "Local run of shellcheck-presubmit detected"
echo "This notably DOES NOT ACT LIKE THE GITHUB PRESUBMIT"
echo "The Github presubmit job only runs shellcheck on files you touch"
echo "There's no way to locally determine which files you touched:"
echo " as git is a distributed VCS, there is no notion of parent until merge"
echo " is attempted."
echo "So it checks the current content of all files changed in the previous commit"
echo " and/or currently staged."
fi
shellcheck_new_files