Infer versions for E2E tests from current branch (#1627)

* Infer versions for E2E tests from current branch

* Fix var export

* Reflect review feedback
This commit is contained in:
David Simansky 2022-03-14 14:29:18 +01:00 committed by GitHub
parent 0ba5250ea1
commit d75836c4f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 6 deletions

View File

@ -66,9 +66,22 @@ function knative_setup() {
install_istio install_istio
fi fi
local serving_version=${KNATIVE_SERVING_VERSION:-latest} # Serving and Eventing 'latest' is based on branch context
header "Installing Knative Serving (${serving_version})" # On `main` it means 'nightly' manifests
# On `release-*` it means corresponding `release-*` manifests
# The described behavior is achieved through hack/library.sh start_latest_knative_serving()
local serving_version="latest"
local eventing_version="latest"
# PR check variant triggering presubmit-integration-tests-latest-release
# should check current client main branch code on latest available release
# e.g. PR to 'main' on Serving and Eventing 1.3.0
if [ "${LATEST_RELEASE}" == "true" ]; then
serving_version="$(get_latest_release_version "serving")"
eventing_version="$(get_latest_release_version "eventing")"
fi
header "Installing Knative Serving (${serving_version})"
if [ "${serving_version}" = "latest" ]; then if [ "${serving_version}" = "latest" ]; then
start_latest_knative_serving start_latest_knative_serving
else else
@ -80,9 +93,7 @@ function knative_setup() {
--type merge -p '{"data": {"ingress.class":"'${INGRESS_CLASS}'"}}' --type merge -p '{"data": {"ingress.class":"'${INGRESS_CLASS}'"}}'
fi fi
local eventing_version=${KNATIVE_EVENTING_VERSION:-latest}
header "Installing Knative Eventing (${eventing_version})" header "Installing Knative Eventing (${eventing_version})"
if [ "${eventing_version}" = "latest" ]; then if [ "${eventing_version}" = "latest" ]; then
start_latest_knative_eventing start_latest_knative_eventing
start_latest_eventing_sugar_controller start_latest_eventing_sugar_controller
@ -97,3 +108,25 @@ function test_setup() {
echo ">> Uploading test images..." echo ">> Uploading test images..."
${REPO_ROOT_DIR}/test/upload-test-images.sh || return 1 ${REPO_ROOT_DIR}/test/upload-test-images.sh || return 1
} }
# Retrieve latest version from given Knative repository tags
# On 'main' branch the latest released version is returned
# On 'release-x.y' branch the latest patch version for 'x.y.*' is returned
# Similar to hack/library.sh get_latest_knative_yaml_source()
function get_latest_release_version() {
local repo_name="$1"
local major_minor=""
if is_release_branch; then
local branch_name
branch_name="$(current_branch)"
major_minor="${branch_name##release-}"
fi
local version
version="$(git ls-remote --tags --ref https://github.com/knative/"${repo_name}".git \
| grep "${major_minor}" \
| cut -d '-' -f2 \
| cut -d 'v' -f2 \
| sort -Vr \
| head -n 1)"
echo "${version}"
}

View File

@ -17,7 +17,6 @@
# This script is used in Knative/test-infra as a custom prow job to run the # This script is used in Knative/test-infra as a custom prow job to run the
# integration tests against Knative Serving / Eventing of a specific version. # integration tests against Knative Serving / Eventing of a specific version.
export KNATIVE_SERVING_VERSION="`git ls-remote --tags --ref https://github.com/knative/serving.git | cut -d '-' -f2 | cut -d 'v' -f2 | sort -Vr | head -n 1`" export LATEST_RELEASE="true"
export KNATIVE_EVENTING_VERSION="`git ls-remote --tags --ref https://github.com/knative/eventing.git | cut -d '-' -f2 | cut -d 'v' -f2 | sort -Vr | head -n 1`"
$(dirname $0)/presubmit-tests.sh --integration-tests $(dirname $0)/presubmit-tests.sh --integration-tests