upgrade to latest dependencies (#4408)

bumping knative.dev/hack b96d65a...96aac1c:
  > 96aac1c Add wait_until_object_exists library function (# 96)
  > 29f86c2 fix latest version when running in GitHub actions (# 103)
  > 0f69979 Update community files (# 102)
  > b284d49 fix the latest_version function (# 101)
  > 42a2ccb Release use `knative-vX.Y.Z` tag and infer go module tag version automatically (# 98)
  > a42c72a Update community files (# 95)
  > 810ab22 Make go_update_deps module-release aware (# 93)
  > f1228dd Update community files (# 90)

Signed-off-by: Knative Automation <automation@knative.team>
This commit is contained in:
knative-automation 2021-11-12 12:49:37 -08:00 committed by GitHub
parent 706480e4d1
commit d846d32263
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 135 additions and 44 deletions

2
go.mod
View File

@ -30,7 +30,7 @@ require (
gopkg.in/go-playground/webhooks.v3 v3.13.0
gopkg.in/yaml.v2 v2.3.0
honnef.co/go/tools v0.0.1-2020.1.5 // indirect
knative.dev/hack v0.0.0-20211028194650-b96d65a5ff5e
knative.dev/hack v0.0.0-20211108170701-96aac1c30be3
)
replace go.opencensus.io => go.opencensus.io v0.20.2

4
go.sum
View File

@ -542,8 +542,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.5 h1:nI5egYTGJakVyOryqLs1cQO5dO0ksin5XXs2pspk75k=
honnef.co/go/tools v0.0.1-2020.1.5/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
knative.dev/hack v0.0.0-20211028194650-b96d65a5ff5e h1:0Hw2xdWYbcs2JRJnOLzAVh7APOtgro7gSno0228mnDg=
knative.dev/hack v0.0.0-20211028194650-b96d65a5ff5e/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI=
knative.dev/hack v0.0.0-20211108170701-96aac1c30be3 h1:oSvRgnKoU308k7aXbPV3iL5Zh5kBGM2Ptar4hyeda+A=
knative.dev/hack v0.0.0-20211108170701-96aac1c30be3/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI=
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/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=

View File

@ -64,6 +64,31 @@ fi
# On a Prow job, redirect stderr to stdout so it's synchronously added to log
(( IS_PROW )) && exec 2>&1
# Return the major version of a release.
# For example, "v0.2.1" returns "0"
# Parameters: $1 - release version label.
function major_version() {
local release="${1//v/}"
local tokens=(${release//\./ })
echo "${tokens[0]}"
}
# Return the minor version of a release.
# For example, "v0.2.1" returns "2"
# Parameters: $1 - release version label.
function minor_version() {
local tokens=(${1//\./ })
echo "${tokens[1]}"
}
# Return the release build number of a release.
# For example, "v0.2.1" returns "1".
# Parameters: $1 - release version label.
function patch_version() {
local tokens=(${1//\./ })
echo "${tokens[2]}"
}
# Print error message and exit 1
# Parameters: $1..$n - error message to be displayed
function abort() {
@ -161,6 +186,32 @@ function wait_until_object_does_not_exist() {
return 1
}
# Waits until the given object exists.
# Parameters: $1 - the kind of the object.
# $2 - object's name.
# $3 - namespace (optional).
function wait_until_object_exists() {
local KUBECTL_ARGS="get $1 $2"
local DESCRIPTION="$1 $2"
if [[ -n $3 ]]; then
KUBECTL_ARGS="get -n $3 $1 $2"
DESCRIPTION="$1 $3/$2"
fi
echo -n "Waiting until ${DESCRIPTION} exists"
for i in {1..150}; do # timeout after 5 minutes
if kubectl ${KUBECTL_ARGS} > /dev/null 2>&1; then
echo -e "\n${DESCRIPTION} exists"
return 0
fi
echo -n "."
sleep 2
done
echo -e "\n\nERROR: timeout waiting for ${DESCRIPTION} to exist"
kubectl ${KUBECTL_ARGS}
return 1
}
# Waits until all pods are running in the given namespace.
# This function handles some edge cases that `kubectl wait` does not support,
# and it provides nice debug info on the state of the pod if it failed,
@ -746,6 +797,7 @@ function current_branch() {
# Get the branch name from Prow's env var, see https://github.com/kubernetes/test-infra/blob/master/prow/jobs.md.
# Otherwise, try getting the current branch from git.
(( IS_PROW )) && branch_name="${PULL_BASE_REF:-}"
[[ -z "${branch_name}" ]] && branch_name="${GITHUB_BASE_REF:-}"
[[ -z "${branch_name}" ]] && branch_name="$(git rev-parse --abbrev-ref HEAD)"
echo "${branch_name}"
}
@ -810,33 +862,56 @@ function shellcheck_new_files() {
fi
}
# Note: if using Github checkout action please ensure you fetch all tags prior to calling
# this function
#
# ie.
# - uses: actions/checkout@v2
# with:
# fetch-depth: 0
#
# See: https://github.com/actions/checkout#fetch-all-history-for-all-tags-and-branches
function latest_version() {
# This function works "best effort" and works on Prow but not necessarily locally.
# The problem is finding the latest release. If a release occurs on the same commit which
# was branched from main, then the tag will be an ancestor to any commit derived from main.
# That was the original logic. Additionally in a release branch, the tag is always an ancestor.
# However, if the release commit ends up not the first commit from main, then the tag is not
# an ancestor of main, so we can't use `git describe` to find the most recent versioned tag. So
# we just sort all the tags and find the newest versioned one.
# But when running locally, we cannot(?) know if the current branch is a fork of main or a fork
# of a release branch. That's where this function will malfunction when the last release did not
# occur on the first commit -- it will try to run the upgrade tests from an older version instead
# of the most recent release.
# Workarounds include:
# Tag the first commit of the release branch. Say release-0.75 released v0.75.0 from the second commit
# Then tag the first commit in common between main and release-0.75 with `v0.75`.
# Always name your local fork master or main.
if [ $(current_branch) = "master" ] || [ $(current_branch) = "main" ]; then
# For main branch, simply use git tag without major version, this will work even
# if the release tag is not in the main
git tag -l "v[0-9]*" | sort -r --version-sort | head -n1
else
local semver=$(git describe --match "v[0-9]*" --abbrev=0)
local major_minor=$(echo "$semver" | cut -d. -f1-2)
local branch_name="$(current_branch)"
# Get the latest patch release for the major minor
git tag -l "${major_minor}*" | sort -r --version-sort | head -n1
# Use the latest release for main
if [[ "$branch_name" == "main" ]] || [[ "$branch_name" == "master" ]]; then
git tag -l "*$(git tag -l "*v[0-9]*" | cut -d '-' -f2 | sort -r --version-sort | head -n1)*"
return
fi
# Ideally we shouldn't need to treat release branches differently but
# there are scenarios where git describe will return newer tags than
# the ones on the current branch
#
# ie. create a PR pulling commits from 0.24 into a release-0.23 branch
if [[ "$branch_name" == "release-"* ]]; then
# Infer major, minor version from the branch name
local tag="${branch_name##release-}"
else
# Nearest tag with the `knative-` prefix
local tag=$(git describe --abbrev=0 --match "knative-v[0-9]*")
# Fallback to older tag scheme vX.Y.Z
[[ -z "${tag}" ]] && tag=$(git describe --abbrev=0 --match "v[0-9]*")
# Drop the prefix
tag="${tag##knative-}"
fi
local major_version="$(major_version ${tag})"
local minor_version="$(minor_version ${tag})"
# Hardcode the jump back from 1.0
if [ "$major_version" = "1" ] && [ "$minor_version" = "0" ]; then
local tag_filter='v0.26*'
else
# Adjust the minor down by one
local tag_filter="*v$major_version.$(( minor_version - 1 ))*"
fi
# Get the latest patch release for the major minor
git tag -l "${tag_filter}" | sort -r --version-sort | head -n1
}
# Initializations that depend on previous functions.

View File

@ -131,14 +131,6 @@ function master_version() {
echo "${tokens[0]}.${tokens[1]}"
}
# Return the release build number of a release.
# For example, "v0.2.1" returns "1".
# Parameters: $1 - release version label.
function release_build_number() {
local tokens=(${1//\./ })
echo "${tokens[2]}"
}
# Return the short commit SHA from a release tag.
# For example, "v20010101-deadbeef" returns "deadbeef".
function hash_from_tag() {
@ -171,7 +163,10 @@ function prepare_auto_release() {
PUBLISH_RELEASE=1
git fetch --all || abort "error fetching branches/tags from remote"
local tags="$(git tag | cut -d 'v' -f2 | cut -d '.' -f1-2 | sort -V | uniq)"
# Support two different formats for tags
# - knative-v1.0.0
# - v1.0.0
local tags="$(git tag | cut -d '-' -f2 | cut -d 'v' -f2 | cut -d '.' -f1-2 | sort -V | uniq)"
local branches="$( { (git branch -r | grep upstream/release-) ; (git branch | grep release-); } | cut -d '-' -f2 | sort -V | uniq)"
echo "Versions released (from tags): [" "${tags}" "]"
@ -210,7 +205,10 @@ function prepare_dot_release() {
git fetch --all || abort "error fetching branches/tags from remote"
# List latest release
local releases # don't combine with the line below, or $? will be 0
releases="$(hub_tool release)"
# Support tags in two formats
# - knative-v1.0.0
# - v1.0.0
releases="$(hub_tool release | cut -d '-' -f2)"
echo "Current releases are: ${releases}"
[[ $? -eq 0 ]] || abort "cannot list releases"
# If --release-branch passed, restrict to that release
@ -234,7 +232,9 @@ function prepare_dot_release() {
[[ -n "${major_minor_version}" ]] || abort "cannot get release major/minor version"
# Ensure there are new commits in the branch, otherwise we don't create a new release
setup_branch
local last_release_commit="$(git rev-list -n 1 "${last_version}")"
# Use the original tag (ie. potentially with a knative- prefix) when determining the last version commit sha
local github_tag="$(hub_tool release | grep "${last_version}")"
local last_release_commit="$(git rev-list -n 1 "${github_tag}")"
local release_branch_commit="$(git rev-list -n 1 upstream/"${RELEASE_BRANCH}")"
[[ -n "${last_release_commit}" ]] || abort "cannot get last release commit"
[[ -n "${release_branch_commit}" ]] || abort "cannot get release branch last commit"
@ -246,13 +246,13 @@ function prepare_dot_release() {
exit 0
fi
# Create new release version number
local last_build="$(release_build_number "${last_version}")"
local last_build="$(patch_version "${last_version}")"
RELEASE_VERSION="${major_minor_version}.$(( last_build + 1 ))"
echo "Will create release ${RELEASE_VERSION} at commit ${release_branch_commit}"
# If --release-notes not used, copy from the latest release
if [[ -z "${RELEASE_NOTES}" ]]; then
RELEASE_NOTES="$(mktemp)"
hub_tool release show -f "%b" "${last_version}" > "${RELEASE_NOTES}"
hub_tool release show -f "%b" "${github_tag}" > "${RELEASE_NOTES}"
echo "Release notes from ${last_version} copied to ${RELEASE_NOTES}"
fi
}
@ -595,6 +595,8 @@ function publish_to_github() {
local description="$(mktemp)"
local attachments_dir="$(mktemp -d)"
local commitish=""
local github_tag="knative-${TAG}"
# Copy files to a separate dir
for artifact in $@; do
cp ${artifact} "${attachments_dir}"/
@ -604,8 +606,22 @@ function publish_to_github() {
if [[ -n "${RELEASE_NOTES}" ]]; then
cat "${RELEASE_NOTES}" >> "${description}"
fi
git tag -a "${TAG}" -m "${title}"
git_push tag "${TAG}"
git tag -a "${github_tag}" -m "${title}"
git_push tag "${github_tag}"
# Include a tag for the go module version
#
# v1.0.0 = v0.27.0
# v1.0.1 = v0.27.1
# v1.1.1 = v0.28.1
#
# See: https://github.com/knative/hack/pull/97
if [[ "$TAG" == "v1"* ]]; then
local release_minor=$(minor_version $TAG)
local go_module_version="v0.$(( release_minor + 27 )).$(patch_version $TAG)"
git tag -a "${go_module_version}" -m "${title}"
git_push tag "${go_module_version}"
fi
[[ -n "${RELEASE_BRANCH}" ]] && commitish="--commitish=${RELEASE_BRANCH}"
for i in {2..0}; do
@ -613,7 +629,7 @@ function publish_to_github() {
${attachments[@]} \
--file="${description}" \
"${commitish}" \
"${TAG}" && return 0
"${github_tag}" && return 0
if [[ "${i}" -gt 0 ]]; then
echo "Error publishing the release, retrying in 15s..."
sleep 15

2
vendor/modules.txt vendored
View File

@ -296,7 +296,7 @@ gopkg.in/go-playground/webhooks.v3/github
gopkg.in/yaml.v2
# honnef.co/go/tools v0.0.1-2020.1.5
## explicit
# knative.dev/hack v0.0.0-20211028194650-b96d65a5ff5e
# knative.dev/hack v0.0.0-20211108170701-96aac1c30be3
## explicit
knative.dev/hack
# go.opencensus.io => go.opencensus.io v0.20.2