Skip to content

Commit 999d585

Browse files
committed
chore: Add test for latest protobuf version
1 parent 5456b52 commit 999d585

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

.kokoro/build.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,79 @@ source ${scriptDir}/common.sh
2727
mvn -version
2828
echo ${JOB_TYPE}
2929

30+
# Store the current Java version since the version may change when installing sdk-platform-java
31+
current_java_home=$JAVA_HOME
32+
33+
# testing-infra-docker has Java 11 installed in java8 docker container. Use this as sdk-platform-java
34+
# needs Java 11+ to run with GraalVM. For GH actions, JAVA11_HOME does not exist and would skip this.
35+
if [ ! -z "${JAVA11_HOME}" ]; then
36+
export JAVA_HOME="${JAVA11_HOME}"
37+
export PATH=${JAVA_HOME}/bin:$PATH
38+
fi
39+
40+
# Get the current proto runtime version used in this repo
41+
CURRENT_PROTO_VERSION=$(mvn -ntp help:effective-pom |
42+
sed -n "/<artifactId>protobuf-java<\/artifactId>/,/<\/dependency>/ {
43+
/<version>/{
44+
s/<version>\(.*\)<\/version>/\1/p
45+
q
46+
}
47+
}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
48+
echo "The current proto version is: ${CURRENT_PROTO_VERSION}"
49+
50+
# Find the latest proto runtime version available
51+
LATEST_PROTO_VERSION=$(curl -s https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java/maven-metadata.xml | sed -n '/<release>/s/.*<release>\(.*\)<\/release>.*/\1/p')
52+
echo "The latest proto version is: ${LATEST_PROTO_VERSION}"
53+
54+
# Only reinstall shared-deps again to test for a newer proto version
55+
if [[ "${CURRENT_PROTO_VERSION}" != "${LATEST_PROTO_VERSION}" ]]; then
56+
pushd /tmp
57+
git clone https://github.com/googleapis/sdk-platform-java.git
58+
pushd sdk-platform-java
59+
pushd gapic-generator-java-pom-parent
60+
sed -i "/<protobuf.version>.*<\/protobuf.version>/s/\(.*<protobuf.version>\).*\(<\/protobuf.version>\)/\1${LATEST_PROTO_VERSION}\2/" pom.xml
61+
# sdk-platform-java
62+
popd
63+
64+
pushd sdk-platform-java-config
65+
# Get current Shared-Deps version in sdk-platform-java
66+
SHARED_DEPS_VERSION=$(mvn -ntp help:effective-pom |
67+
sed -n "/<artifactId>sdk-platform-java-config<\/artifactId>/,/<\/dependency>/ {
68+
/<version>/{
69+
s/<version>\(.*\)<\/version>/\1/p
70+
q
71+
}
72+
}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
73+
echo "Shared-Deps Version: ${SHARED_DEPS_VERSION}"
74+
# sdk-platform-java
75+
popd
76+
77+
mvn clean install -q -ntp \
78+
-DskipTests=true \
79+
-Dclirr.skip=true \
80+
-Denforcer.skip=true \
81+
-T 1C
82+
# /tmp
83+
popd
84+
85+
# Back to the original directory of the repo
86+
popd
87+
# Find all the poms with a reference to shared-deps and update to the new local version
88+
poms=($(find . -name pom.xml))
89+
for pom in "${poms[@]}"; do
90+
if grep -q "sdk-platform-java-config" "${pom}"; then
91+
echo "Updating the pom: ${pom} to use shared-deps version: ${SHARED_DEPS_VERSION}"
92+
sed -i -E "/<groupId>com.google.cloud<\/groupId>.*<artifactId>sdk-platform-java-config<\/artifactId>/ {
93+
s/(<version>)[^<]+(<\/version>)/\1${SHARED_DEPS_VERSION}\2/
94+
}" "${pom}"
95+
fi
96+
done
97+
fi
98+
99+
# Reset back to the original Java version if changed
100+
export JAVA_HOME="${current_java_home}"
101+
export PATH=${JAVA_HOME}/bin:$PATH
102+
30103
# attempt to install 3 times with exponential backoff (starting with 10 seconds)
31104
retry_with_backoff 3 10 \
32105
mvn install -B -V -ntp \

0 commit comments

Comments
 (0)