From 2b6e931869ae87fec2d220bfbb6d96cd3cfb50f1 Mon Sep 17 00:00:00 2001 From: Mridula <66699525+mpeddada1@users.noreply.github.com> Date: Tue, 13 Feb 2024 19:38:35 +0000 Subject: [PATCH] chore: use sdk-platform-java-config in downstream checks for spanner and pubsub; update junit-vintage to 5.10.2 (#746) * chore: use sdk-platform-java-config in downstream checks for spanner and pubsub --- .kokoro/client-library-check.sh | 83 ++++++++++++++++++++++++++---- native-image-shared-config/pom.xml | 4 +- 2 files changed, 74 insertions(+), 13 deletions(-) diff --git a/.kokoro/client-library-check.sh b/.kokoro/client-library-check.sh index 52cc5298..03bdeab0 100755 --- a/.kokoro/client-library-check.sh +++ b/.kokoro/client-library-check.sh @@ -21,6 +21,55 @@ set -eo pipefail # Display commands being run. set -x +function get_current_version_from_versions_txt() { + versions=$1 + key=$2 + version=$(grep "$key:" "${versions}" | cut -d: -f3) # 3rd field is current + echo "${version}" +} + +function get_released_version_from_versions_txt() { + versions=$1 + key=$2 + version=$(grep "$key:" "${versions}" | cut -d: -f2) # 2nd field is release + echo "${version}" +} + +function replace_java_shared_config_version() { + version=$1 + # replace version + xmllint --shell <(cat pom.xml) << EOF + setns x=http://maven.apache.org/POM/4.0.0 + cd .//x:artifactId[text()="google-cloud-shared-config"] + cd ../x:version + set ${version} + save pom.xml +EOF +} + +function replace_java_shared_dependencies_version() { + version=$1 + # replace version + xmllint --shell <(cat pom.xml) << EOF + setns x=http://maven.apache.org/POM/4.0.0 + cd .//x:properties/x:google-cloud-shared-dependencies.version + set ${version} + save pom.xml +EOF +} + +function replace_sdk_platform_java_config_version() { + version=$1 + # replace version + xmllint --shell <(cat pom.xml) << EOF + setns x=http://maven.apache.org/POM/4.0.0 + cd .//x:artifactId[text()="sdk-platform-java-config"] + cd ../x:version + set ${version} + save pom.xml +EOF +} + if [[ $# -ne 2 ]]; then echo "Usage: $0 " @@ -42,13 +91,26 @@ mvn install -DskipTests=true -Dmaven.javadoc.skip=true -Dgcloud.download.skip=tr # Read the current version of this BOM in the POM. Example version: '0.116.1-alpha-SNAPSHOT' VERSION_POM=java-shared-config/pom.xml # Namespace (xmlns) prevents xmllint from specifying tag names in XPath -VERSION=`sed -e 's/xmlns=".*"//' ${VERSION_POM} | xmllint --xpath '/project/version/text()' -` +JAVA_SHARED_CONFIG_VERSION=`sed -e 's/xmlns=".*"//' ${VERSION_POM} | xmllint --xpath '/project/version/text()' -` -if [ -z "${VERSION}" ]; then +if [ -z "${JAVA_SHARED_CONFIG_VERSION}" ]; then echo "Version is not found in ${VERSION_POM}" exit 1 fi -echo "Version: ${VERSION}" +echo "Version: ${JAVA_SHARED_CONFIG_VERSION}" + +# Update java-shared-config in sdk-platform-java-config +git clone "https://github.com/googleapis/sdk-platform-java.git" --depth=1 +pushd sdk-platform-java +SDK_PLATFORM_JAVA_CONFIG_VERSION=$(get_current_version_from_versions_txt versions.txt "google-cloud-shared-dependencies") +RELEASED_SHARED_DEPENDENCIES_VERSION=$(get_released_version_from_versions_txt versions.txt "google-cloud-shared-dependencies") +pushd sdk-platform-java-config + +# Use released version of google-cloud-shared-dependencies to avoid verifying SNAPSHOT changes. +replace_java_shared_config_version "${JAVA_SHARED_CONFIG_VERSION}" +replace_java_shared_dependencies_version "${RELEASED_SHARED_DEPENDENCIES_VERSION}" +mvn install -DskipTests=true -Dmaven.javadoc.skip=true -Dgcloud.download.skip=true -B -V -q +popd # Check this BOM against a few java client libraries # java-bigquery @@ -60,14 +122,13 @@ fi pushd ${REPO} -# replace version -xmllint --shell <(cat pom.xml) << EOF -setns x=http://maven.apache.org/POM/4.0.0 -cd .//x:artifactId[text()="google-cloud-shared-config"] -cd ../x:version -set ${VERSION} -save pom.xml -EOF +# TODO(#748): Replace the version of sdk-platform-java-config for all libraries. This logic will no longer +# be needed after the rest of the handwritten libraries are migrated to use this artifact. +if [ "$REPO" == "java-spanner" ] || [ "$REPO" == "java-pubsub" ]; then + replace_sdk_platform_java_config_version "${SDK_PLATFORM_JAVA_CONFIG_VERSION}" +else + replace_java_shared_config_version "${JAVA_SHARED_CONFIG_VERSION}" +fi case ${JOB_TYPE} in dependencies) diff --git a/native-image-shared-config/pom.xml b/native-image-shared-config/pom.xml index e40e8c63..d3075458 100644 --- a/native-image-shared-config/pom.xml +++ b/native-image-shared-config/pom.xml @@ -171,7 +171,7 @@ org.junit.vintage junit-vintage-engine - 5.9.3 + 5.10.2 test @@ -185,7 +185,7 @@ org.junit.vintage junit-vintage-engine - 5.9.3 + 5.10.2