Skip to content

Commit e58dc76

Browse files
committed
chore: Address PR comments
1 parent ab4bd15 commit e58dc76

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

.kokoro/nightly/downstream-protobuf-binary-compatibility.sh

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@ function build_artifact_list() {
4040
for artifact_id_prefix in "${!api_maven_mapping[@]}"; do
4141
group_id="${api_maven_mapping[${artifact_id_prefix}]}"
4242

43-
# Match all artifacts that start with the $artifact_id_prefix or grpc to exclude any proto modules.
44-
# grpc-* module are included as gRPC-Java controls their Protobuf version and may generate code
45-
# using a different version of Protobuf
46-
repo_artifact_list=$(cat "versions.txt" | grep -E "^(${artifact_id_prefix}|grpc)" || true)
43+
# Match all artifacts that start with the $artifact_id_prefix exclude any non-relevant modules.
44+
repo_artifact_list=$(cat "versions.txt" | grep -E "^${artifact_id_prefix}" || true)
4745

4846
# Only proceed if there are matching elements
4947
if [ -n "${repo_artifact_list}" ]; then
@@ -60,6 +58,26 @@ function build_artifact_list() {
6058
artifact_list="${artifact_list},${repo_artifact_list}"
6159
fi
6260
fi
61+
62+
# grpc-* module are included as gRPC-Java controls their Protobuf version and may generate code
63+
# using a different version of Protobuf
64+
grpc_repo_artifact_list=$(cat "versions.txt" | grep -E "^grpc" || true)
65+
66+
# Only proceed if there are matching elements
67+
if [ -n "${grpc_repo_artifact_list}" ]; then
68+
# Exclude any matches to BOM artifacts or emulators. The repo artifact list will look like:
69+
# "com.google.cloud:google-cloud-accessapproval:2.60.0-SNAPSHOT,com.google.cloud:google-cloud-aiplatform:3.60.0-SNAPSHOT,"
70+
grpc_repo_artifact_list=$(echo "${grpc_repo_artifact_list}" | awk -F: "{\$1=\"${group_id}:\"\$1; \$2=\"\"; print}" OFS=: | sed 's/::/:/' | tr '\n' ',')
71+
# Remove the trailing comma after the last entry
72+
grpc_repo_artifact_list=${grpc_repo_artifact_list%,}
73+
74+
# The first entry added is not separated with a comma. Avoids generating `,{ARTIFACT_LIST}`
75+
if [ -z "${artifact_list}" ]; then
76+
grpc_artifact_list="${grpc_repo_artifact_list}"
77+
else
78+
grpc_artifact_list="${grpc_artifact_list},${grpc_repo_artifact_list}"
79+
fi
80+
fi
6381
done
6482
}
6583

@@ -78,6 +96,7 @@ for repo in ${REPOS_UNDER_TEST//,/ }; do # Split on comma
7896
mvn -B -ntp install -T 1C -DskipTests -Dclirr.skip -Denforcer.skip
7997

8098
artifact_list=""
99+
grpc_artifact_list=""
81100
if [ "${repo}" == "google-cloud-java" ]; then
82101
build_artifact_list monorepo_handwritten_libraries
83102
else
@@ -89,11 +108,18 @@ for repo in ${REPOS_UNDER_TEST//,/ }; do # Split on comma
89108

90109
echo "Artifact List: ${artifact_list}"
91110
# Only run Linkage Checker if the repo has any relevant artifacts to test for
92-
if [ -n "${artifact_list}" ]; then
111+
if [ -n "${artifact_list}" ] && [ -n "${grpc_artifact_list}" ]; then
93112
# The `-s` argument filters the linkage check problems that stem from the artifact
113+
# There are two calls to Linkage Checker: 1. repo's handwritten modules 2. repo's gRPC modules
114+
# This is because mvn has a limit on the number of program arguments you can pass in
115+
94116
program_args="-r --artifacts ${artifact_list},com.google.protobuf:protobuf-java:${PROTOBUF_RUNTIME_VERSION},com.google.protobuf:protobuf-java-util:${PROTOBUF_RUNTIME_VERSION} -s ${artifact_list}"
95117
echo "Linkage Checker Program Arguments: ${program_args}"
96118
mvn -B -ntp exec:java -Dexec.args="${program_args}" -P exec-linkage-checker
119+
120+
program_args="-r --artifacts ${artifact_list},com.google.protobuf:protobuf-java:${PROTOBUF_RUNTIME_VERSION},com.google.protobuf:protobuf-java-util:${PROTOBUF_RUNTIME_VERSION} -s ${grpc_artifact_list}"
121+
echo "Linkage Checker Program Arguments for gRPC Modules: ${program_args}"
122+
mvn -B -ntp exec:java -Dexec.args="${program_args}" -P exec-linkage-checker
97123
else
98124
echo "Unable to find any matching artifacts to test in ${repo}"
99125
exit 1

0 commit comments

Comments
 (0)