Skip to content

Commit ab4bd15

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

File tree

3 files changed

+45
-27
lines changed

3 files changed

+45
-27
lines changed

.kokoro/nightly/common.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
# Copyright 2025 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# Checks that the protobuf compatibility scripts provide non-empty input
17+
function validate_protobuf_compatibility_script_inputs {
18+
# Comma-delimited list of repos to test
19+
if [ -z "${REPOS_UNDER_TEST}" ]; then
20+
echo "REPOS_UNDER_TEST Env Var must be set. This script expects a"
21+
echo "comma-delimited list: i.e REPOS_UNDER_TEST=\"java-bigtable,java-bigquery\""
22+
exit 1
23+
fi
24+
25+
# A single version of Protobuf-Java runtime to test
26+
if [ -z "${PROTOBUF_RUNTIME_VERSION}" ]; then
27+
echo "PROTOBUF_RUNTIME_VERSION Env Var must be set. This script expects a single "
28+
echo "Protobuf-Java runtime version i.e. PROTOBUF_RUNTIME_VERSION=\"4.28.3\""
29+
exit 1
30+
fi
31+
}

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

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,10 @@
1515

1616
set -eo pipefail
1717

18-
# Comma-delimited list of repos to test with the local java-shared-dependencies
19-
if [ -z "${REPOS_UNDER_TEST}" ]; then
20-
echo "REPOS_UNDER_TEST must be set to run downstream-protobuf-binary-compatibility.sh"
21-
echo "Expects a comma-delimited list: i.e REPOS_UNDER_TEST=\"java-bigtable,java-bigquery\""
22-
exit 1
23-
fi
18+
scriptDir=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
19+
source "${scriptDir}/common.sh"
2420

25-
# Version of Protobuf-Java runtime to compile with
26-
if [ -z "${PROTOBUF_RUNTIME_VERSION}" ]; then
27-
echo "PROTOBUF_RUNTIME_VERSION must be set to run downstream-protobuf-binary-compatibility.sh"
28-
echo "Expects a single Protobuf-Java runtime version i.e. PROTOBUF_RUNTIME_VERSION=\"4.28.3\""
29-
exit 1
30-
fi
21+
validate_protobuf_compatibility_script_inputs
3122

3223
# Create two mappings of possible API names (Key: Maven Artifact ID Prefix, Value: Maven Group ID)
3324
# for the libraries that should be tested.
@@ -36,6 +27,7 @@ declare -A monorepo_handwritten_libraries
3627
monorepo_handwritten_libraries["grafeas"]="io.grafeas"
3728
monorepo_handwritten_libraries["google-cloud-vertexai"]="com.google.cloud"
3829
monorepo_handwritten_libraries["google-cloud-resourcemanager"]="com.google.cloud"
30+
monorepo_handwritten_libraries["google-cloud-translate"]="com.google.cloud"
3931

4032
# 2. These are the mappings of all the downstream handwritten libraries' artifacts
4133
declare -A downstream_handwritten_libraries
@@ -48,8 +40,10 @@ function build_artifact_list() {
4840
for artifact_id_prefix in "${!api_maven_mapping[@]}"; do
4941
group_id="${api_maven_mapping[${artifact_id_prefix}]}"
5042

51-
# Match all artifacts that start with the artifact_id_prefix to exclude any proto and grpc modules.
52-
repo_artifact_list=$(cat "versions.txt" | grep "^${artifact_id_prefix}" || true)
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)
5347

5448
# Only proceed if there are matching elements
5549
if [ -n "${repo_artifact_list}" ]; then
@@ -100,8 +94,10 @@ for repo in ${REPOS_UNDER_TEST//,/ }; do # Split on comma
10094
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}"
10195
echo "Linkage Checker Program Arguments: ${program_args}"
10296
mvn -B -ntp exec:java -Dexec.args="${program_args}" -P exec-linkage-checker
97+
else
98+
echo "Unable to find any matching artifacts to test in ${repo}"
99+
exit 1
103100
fi
104-
echo "done"
105101
done
106102
popd
107103
popd

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

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,10 @@
1515

1616
set -eo pipefail
1717

18-
# Comma-delimited list of repos to test with the local java-shared-dependencies
19-
if [ -z "${REPOS_UNDER_TEST}" ]; then
20-
echo "REPOS_UNDER_TEST must be set to run downstream-protobuf-source-compatibility.sh"
21-
echo "Expects a comma-delimited list: i.e REPOS_UNDER_TEST=\"java-bigtable,java-bigquery\""
22-
exit 1
23-
fi
18+
scriptDir=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
19+
source "${scriptDir}/common.sh"
2420

25-
# Version of Protobuf-Java runtime to compile with
26-
if [ -z "${PROTOBUF_RUNTIME_VERSION}" ]; then
27-
echo "PROTOBUF_RUNTIME_VERSION must be set to run downstream-protobuf-source-compatibility.sh"
28-
echo "Expects a single Protobuf-Java runtime version i.e. PROTOBUF_RUNTIME_VERSION=\"4.28.3\""
29-
exit 1
30-
fi
21+
validate_protobuf_compatibility_script_inputs
3122

3223
for repo in ${REPOS_UNDER_TEST//,/ }; do # Split on comma
3324
# Perform source-compatibility testing on main (latest changes)

0 commit comments

Comments
 (0)