Skip to content

Commit dbc6eee

Browse files
committed
chore: restore nightly protobuf compatibility check
1 parent 5f2e056 commit dbc6eee

4 files changed

Lines changed: 136 additions & 78 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
on:
2+
pull_request:
3+
# Runs on PRs targeting main, but will be filtered for Release PRs
4+
branches:
5+
- 'main'
6+
workflow_dispatch:
7+
inputs:
8+
protobuf_runtime_versions:
9+
description: 'Comma separated list of Protobuf-Java versions (i.e. "3.25.x","4.x.y").
10+
Note: Surround each version in the list with quotes ("")'
11+
required: true
12+
schedule:
13+
- cron: '0 1 * * *' # Nightly at 1am
14+
15+
# This job intends to test the compatibility of Protobuf runtime version against modules in the monorepo.
16+
name: sdk-platform-java Downstream Protobuf Compatibility Check Nightly
17+
jobs:
18+
downstream-protobuf-test:
19+
# This job runs if any of the three conditions match:
20+
# 1. PR is raised from Release-Please (PR comes from branch: release-please--branches-main)
21+
# 2. Job is invoked by the nightly job (scheduled event)
22+
# 3. Job is manually invoked via Github UI (workflow_dispatch event)
23+
if: github.head_ref == 'release-please--branches--main' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
24+
runs-on: ubuntu-22.04
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
module:
29+
- java-bigtable
30+
- java-bigquery
31+
- java-bigquerystorage
32+
- java-datastore
33+
- java-firestore
34+
- java-grafeas
35+
- java-logging
36+
- java-logging-logback
37+
- java-pubsub
38+
- java-resourcemanager
39+
- java-showcase
40+
- java-spanner
41+
- java-spanner-jdbc
42+
- java-storage
43+
- java-storage-nio
44+
- java-translate
45+
# Default Protobuf-Java versions to use are specified here. Without this, the nightly workflow won't know
46+
# which values to use and would resolve to ''.
47+
protobuf-version: ${{ fromJSON(format('[{0}]', inputs.protobuf_runtime_versions || '"4.35.0"')) }}
48+
steps:
49+
- name: Checkout monorepo
50+
uses: actions/checkout@v4
51+
- uses: actions/setup-java@v4
52+
with:
53+
java-version: 8
54+
distribution: temurin
55+
- run: echo "JAVA8_HOME=${JAVA_HOME}" >> $GITHUB_ENV
56+
# Java Client Libraries are compiled with Java 11 and target Java 8. Java 11 is required because GraalVM
57+
# minimum support is for Java 11.
58+
- uses: actions/setup-java@v4
59+
with:
60+
java-version: 11
61+
distribution: temurin
62+
- name: Print Protobuf-Java testing version
63+
run: echo "Testing with Protobuf-Java v${{ matrix.protobuf-version }}"
64+
- name: Perform downstream source compatibility testing
65+
run: MODULES_UNDER_TEST="${{ matrix.module }}" PROTOBUF_RUNTIME_VERSION="${{ matrix.protobuf-version }}" ./sdk-platform-java/.kokoro/nightly/downstream-protobuf-source-compatibility.sh
66+
- name: Perform downstream binary compatibility testing
67+
run: MODULES_UNDER_TEST="${{ matrix.module }}" PROTOBUF_RUNTIME_VERSION="${{ matrix.protobuf-version }}" ./sdk-platform-java/.kokoro/nightly/downstream-protobuf-binary-compatibility.sh

sdk-platform-java/.kokoro/nightly/common.sh

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,12 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
# For google-cloud-java, only test specific handwritten libraries included in the monorepo. This is to
17-
# help speed up the execution as building the entire repo is an expensive operation. Specify the nested
18-
# `google-cloud-*` path (except for grafeas as it doesn't have one) because maven -pl will only build the
19-
# specified folder (i.e. parent folder) and ignore all the related sub-modules inside
20-
google_cloud_java_handwritten_maven_args="java-grafeas,java-vertexai/google-cloud-vertexai,java-resourcemanager/google-cloud-resourcemanager,java-translate/google-cloud-translate"
21-
2216
# Checks that the protobuf compatibility scripts provide non-empty input
2317
function validate_protobuf_compatibility_script_inputs {
24-
# Comma-delimited list of repos to test
25-
if [ -z "${REPOS_UNDER_TEST}" ]; then
26-
echo "REPOS_UNDER_TEST Env Var must be set. This script expects a"
27-
echo "comma-delimited list: i.e REPOS_UNDER_TEST=\"java-bigtable,java-bigquery\""
18+
# Comma-delimited list of modules to test
19+
if [ -z "${MODULES_UNDER_TEST}" ]; then
20+
echo "MODULES_UNDER_TEST Env Var must be set. This script expects a"
21+
echo "comma-delimited list: i.e MODULES_UNDER_TEST=\"java-bigtable,java-bigquery\""
2822
exit 1
2923
fi
3024

sdk-platform-java/.kokoro/nightly/downstream-protobuf-binary-compatibility.sh

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -20,44 +20,53 @@ source "${scriptDir}/common.sh"
2020

2121
validate_protobuf_compatibility_script_inputs
2222

23+
monorepoRoot=$(realpath "${scriptDir}/../../..")
24+
2325
# Declare a map of downstream handwritten libraries and the relevant artifacts to test. The map stores a
24-
# K/V pairing of (Key: repo name, Value: comma separate list of Group ID:Artifact ID pairings). Note: The
25-
# value list doesn't hold the version and this needs to be parsed from the repo's versions.txt file
26-
declare -A repo_linkage_checker_arguments
27-
repo_linkage_checker_arguments["google-cloud-java"]="io.grafeas:grafeas,com.google.cloud:google-cloud-vertexai,com.google.cloud:google-cloud-resourcemanager,com.google.cloud:google-cloud-translate,com.google.api.grpc:grpc-google-cloud-vertexai-v1,com.google.api.grpc:grpc-google-cloud-vertexai-v1beta1,com.google.api.grpc:grpc-google-cloud-resourcemanager-v3,com.google.api.grpc:grpc-google-cloud-translate-v3,com.google.api.grpc:grpc-google-cloud-translate-v3beta1"
28-
repo_linkage_checker_arguments["java-bigtable"]="com.google.cloud:google-cloud-bigtable,com.google.api.grpc:grpc-google-cloud-bigtable-admin-v2,com.google.api.grpc:grpc-google-cloud-bigtable-v2"
29-
repo_linkage_checker_arguments["java-bigquery"]="com.google.cloud:google-cloud-bigquery"
30-
repo_linkage_checker_arguments["java-bigquerystorage"]="com.google.cloud:google-cloud-bigquerystorage,com.google.api.grpc:grpc-google-cloud-bigquerystorage-v1beta1,com.google.api.grpc:grpc-google-cloud-bigquerystorage-v1beta2,com.google.api.grpc:grpc-google-cloud-bigquerystorage-v1,com.google.api.grpc:grpc-google-cloud-bigquerystorage-v1alpha"
31-
repo_linkage_checker_arguments["java-datastore"]="com.google.cloud:google-cloud-datastore,com.google.cloud.datastre:datastore-v1-proto-client,com.google.api.grpc:grpc-google-cloud-datastore-admin-v1"
32-
repo_linkage_checker_arguments["java-firestore"]="com.google.cloud:google-cloud-firestore,com.google.cloud:google-cloud-firestore-admin,com.google.api.grpc:grpc-google-cloud-firestore-admin-v1,com.google.api.grpc:grpc-google-cloud-firestore-v1"
33-
repo_linkage_checker_arguments["java-logging"]="com.google.cloud:google-cloud-logging,com.google.api.grpc:grpc-google-cloud-logging-v2"
34-
repo_linkage_checker_arguments["java-logging-logback"]="com.google.cloud:google-cloud-logging-logback"
35-
repo_linkage_checker_arguments["java-pubsub"]="com.google.cloud:google-cloud-pubsub,com.google.api.grpc:grpc-google-cloud-pubsub-v1"
36-
repo_linkage_checker_arguments["java-pubsublite"]="com.google.cloud:google-cloud-pubsublite,com.google.api.grpc:grpc-google-cloud-pubsublite-v1"
37-
repo_linkage_checker_arguments["java-spanner-jdbc"]="com.google.cloud:google-cloud-spanner-jdbc"
38-
repo_linkage_checker_arguments["java-spanner"]="com.google.cloud:google-cloud-spanner,com.google.cloud:google-cloud-spanner-executor,com.google.api.grpc:grpc-google-cloud-spanner-v1,com.google.api.grpc:grpc-google-cloud-spanner-admin-instance-v1,com.google.api.grpc:grpc-google-cloud-spanner-admin-database-v1,com.google.api.grpc:grpc-google-cloud-spanner-executor-v1"
39-
repo_linkage_checker_arguments["java-storage"]="com.google.cloud:google-cloud-storage,com.google.api.grpc:gapic-google-cloud-storage-v2,com.google.api.grpc:grpc-google-cloud-storage-v2,com.google.cloud:google-cloud-storage-control,com.google.api.grpc:grpc-google-cloud-storage-control-v2"
40-
repo_linkage_checker_arguments["java-storage-nio"]="com.google.cloud:google-cloud-nio"
26+
# K/V pairing of (Key: module name, Value: comma separate list of Group ID:Artifact ID pairings). Note: The
27+
# value list doesn't hold the version and this needs to be parsed from the monorepo's versions.txt file
28+
declare -A module_linkage_checker_arguments
29+
module_linkage_checker_arguments["java-grafeas"]="io.grafeas:grafeas"
30+
module_linkage_checker_arguments["java-resourcemanager"]="com.google.cloud:google-cloud-resourcemanager,com.google.api.grpc:grpc-google-cloud-resourcemanager-v3"
31+
module_linkage_checker_arguments["java-translate"]="com.google.cloud:google-cloud-translate,com.google.api.grpc:grpc-google-cloud-translate-v3,com.google.api.grpc:grpc-google-cloud-translate-v3beta1"
32+
module_linkage_checker_arguments["java-bigtable"]="com.google.cloud:google-cloud-bigtable,com.google.api.grpc:grpc-google-cloud-bigtable-admin-v2,com.google.api.grpc:grpc-google-cloud-bigtable-v2"
33+
module_linkage_checker_arguments["java-bigquery"]="com.google.cloud:google-cloud-bigquery"
34+
module_linkage_checker_arguments["java-bigquerystorage"]="com.google.cloud:google-cloud-bigquerystorage,com.google.api.grpc:grpc-google-cloud-bigquerystorage-v1beta1,com.google.api.grpc:grpc-google-cloud-bigquerystorage-v1beta2,com.google.api.grpc:grpc-google-cloud-bigquerystorage-v1,com.google.api.grpc:grpc-google-cloud-bigquerystorage-v1alpha"
35+
module_linkage_checker_arguments["java-datastore"]="com.google.cloud:google-cloud-datastore,com.google.cloud.datastre:datastore-v1-proto-client,com.google.api.grpc:grpc-google-cloud-datastore-admin-v1"
36+
module_linkage_checker_arguments["java-firestore"]="com.google.cloud:google-cloud-firestore,com.google.cloud:google-cloud-firestore-admin,com.google.api.grpc:grpc-google-cloud-firestore-admin-v1,com.google.api.grpc:grpc-google-cloud-firestore-v1"
37+
module_linkage_checker_arguments["java-logging"]="com.google.cloud:google-cloud-logging,com.google.api.grpc:grpc-google-cloud-logging-v2"
38+
module_linkage_checker_arguments["java-logging-logback"]="com.google.cloud:google-cloud-logging-logback"
39+
module_linkage_checker_arguments["java-pubsub"]="com.google.cloud:google-cloud-pubsub,com.google.api.grpc:grpc-google-cloud-pubsub-v1"
40+
module_linkage_checker_arguments["java-showcase"]="com.google.showcase:gapic-showcase,com.google.api.grpc:grpc-gapic-showcase-v1beta1"
41+
module_linkage_checker_arguments["java-spanner-jdbc"]="com.google.cloud:google-cloud-spanner-jdbc"
42+
module_linkage_checker_arguments["java-spanner"]="com.google.cloud:google-cloud-spanner,com.google.cloud:google-cloud-spanner-executor,com.google.api.grpc:grpc-google-cloud-spanner-v1,com.google.api.grpc:grpc-google-cloud-spanner-admin-instance-v1,com.google.api.grpc:grpc-google-cloud-spanner-admin-database-v1,com.google.api.grpc:grpc-google-cloud-spanner-executor-v1"
43+
module_linkage_checker_arguments["java-storage"]="com.google.cloud:google-cloud-storage,com.google.api.grpc:gapic-google-cloud-storage-v2,com.google.api.grpc:grpc-google-cloud-storage-v2,com.google.cloud:google-cloud-storage-control,com.google.api.grpc:grpc-google-cloud-storage-control-v2"
44+
module_linkage_checker_arguments["java-storage-nio"]="com.google.cloud:google-cloud-nio"
4145

4246
# This function requires access to the versions.txt to retrieve the versions for the artifacts
4347
# It will try to match the artifact_id in the versions.txt file and attach it to form the GAV
4448
# The GAV list is required by Linkage Checker as program arguments
4549
function build_program_arguments() {
46-
artifact_list="${repo_linkage_checker_arguments[$1]}"
50+
artifact_list="${module_linkage_checker_arguments[$1]}"
4751

4852
for artifact in ${artifact_list//,/ }; do # Split on comma
4953
artifact_id=$(echo "${artifact}" | cut -d ':' -f2)
5054

5155
# The grep query tries to match `{artifact_id}:{released_version}:{current_version}`.
5256
# The artifact_id must be exact otherwise multiple entries may match
53-
version=$(cat "versions.txt" | grep -E "^${artifact_id}:.*:.*$" | cut -d ':' -f3)
54-
repo_gav_coordinate="${artifact}:${version}"
57+
version=$(cat "${monorepoRoot}/versions.txt" | grep -E "^${artifact_id}:.*:.*$" | cut -d ':' -f3 || true)
58+
# Unreleased internal test modules like java-showcase are not tracked in versions.txt,
59+
# so fallback to 0.0.1-SNAPSHOT for linkage checking.
60+
if [ -z "${version}" ]; then
61+
version="0.0.1-SNAPSHOT"
62+
fi
63+
module_gav_coordinate="${artifact}:${version}"
5564

5665
# The first entry added is not separated with a comma. Avoids generating `,{ARTIFACT_LIST}`
5766
if [ -z "${linkage_checker_arguments}" ]; then
58-
linkage_checker_arguments="${repo_gav_coordinate}"
67+
linkage_checker_arguments="${module_gav_coordinate}"
5968
else
60-
linkage_checker_arguments="${linkage_checker_arguments},${repo_gav_coordinate}"
69+
linkage_checker_arguments="${linkage_checker_arguments},${module_gav_coordinate}"
6170
fi
6271
done
6372
}
@@ -70,34 +79,30 @@ mvn -B -ntp clean compile -T 1C
7079
# Linkage Checker tool resides in the /dependencies subfolder
7180
pushd dependencies
7281

73-
# REPOS_UNDER_TEST Env Var accepts a comma separated list of googleapis repos to test. For Github CI,
74-
# this will be a single repo as Github will build a matrix of repos with each repo being tested in parallel.
75-
# For local invocation, you can pass a list of repos to test multiple repos together.
76-
for repo in ${REPOS_UNDER_TEST//,/ }; do # Split on comma
77-
# Perform testing on main (with latest changes). Shallow copy as history is not important
78-
git clone "https://github.com/googleapis/${repo}.git" --depth=1
79-
pushd "${repo}"
80-
81-
if [ "${repo}" == "google-cloud-java" ]; then
82-
# The `-am` command also builds anything these libraries depend on (i.e. proto-* and grpc-* sub modules)
83-
mvn clean install -B -V -ntp -T 1C -DskipTests -Dclirr.skip -Denforcer.skip -Dmaven.javadoc.skip \
84-
-pl "${google_cloud_java_handwritten_maven_args}" -am
85-
else
86-
# Install all repo modules to ~/.m2 (there can be multiple relevant artifacts to test i.e. core, admin, control)
87-
mvn clean install -B -V -ntp -T 1C -DskipTests -Dclirr.skip -Denforcer.skip -Dmaven.javadoc.skip
82+
# MODULES_UNDER_TEST Env Var accepts a comma separated list of monorepo submodules to test. For Github CI,
83+
# this will be a single module as Github will build a matrix of modules with each being tested in parallel.
84+
# For local invocation, you can pass a list of modules to test multiple modules together.
85+
for module in ${MODULES_UNDER_TEST//,/ }; do # Split on comma
86+
module_dir="${monorepoRoot}/${module}"
87+
if [ ! -d "${module_dir}" ]; then
88+
echo "Directory ${module_dir} does not exist. Skipping or failed."
89+
exit 1
8890
fi
8991

92+
pushd "${module_dir}"
93+
# Install all module artifacts to ~/.m2 (there can be multiple relevant artifacts to test i.e. core, admin, control)
94+
mvn clean install -B -V -ntp -T 1C -DskipTests -Dclirr.skip -Denforcer.skip -Dmaven.javadoc.skip
9095

9196
linkage_checker_arguments=""
92-
build_program_arguments "${repo}"
97+
build_program_arguments "${module}"
9398

9499
# Linkage Checker /dependencies
95100
popd
96101

97102
echo "Artifact List: ${linkage_checker_arguments}"
98103
# The `-s` argument filters the linkage check problems that stem from the artifact
99104
program_args="-r --artifacts ${linkage_checker_arguments},com.google.protobuf:protobuf-java:${PROTOBUF_RUNTIME_VERSION},com.google.protobuf:protobuf-java-util:${PROTOBUF_RUNTIME_VERSION} -s ${linkage_checker_arguments}"
100-
echo "Running Linkage Checker on the repo's handwritten modules"
105+
echo "Running Linkage Checker on the module's handwritten artifacts"
101106
echo "Linkage Checker Program Arguments: ${program_args}"
102107
mvn -B -ntp exec:java -Dexec.args="${program_args}" -P exec-linkage-checker
103108
done

sdk-platform-java/.kokoro/nightly/downstream-protobuf-source-compatibility.sh

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,19 @@ source "${scriptDir}/common.sh"
2020

2121
validate_protobuf_compatibility_script_inputs
2222

23-
# REPOS_UNDER_TEST Env Var accepts a comma separated list of googleapis repos to test. For Github CI,
24-
# this will be a single repo as Github will build a matrix of repos with each repo being tested in parallel.
25-
# For local invocation, you can pass a list of repos to test multiple repos together.
26-
for repo in ${REPOS_UNDER_TEST//,/ }; do # Split on comma
27-
# Perform source-compatibility testing on main (latest changes)
28-
git clone "https://github.com/googleapis/$repo.git" --depth=1
29-
pushd "$repo"
23+
monorepoRoot=$(realpath "${scriptDir}/../../..")
24+
25+
# MODULES_UNDER_TEST Env Var accepts a comma separated list of monorepo submodules to test. For Github CI,
26+
# this will be a single module as Github will build a matrix of modules with each being tested in parallel.
27+
# For local invocation, you can pass a list of modules to test multiple modules together.
28+
for module in ${MODULES_UNDER_TEST//,/ }; do # Split on comma
29+
module_dir="${monorepoRoot}/${module}"
30+
if [ ! -d "${module_dir}" ]; then
31+
echo "Directory ${module_dir} does not exist. Skipping or failed."
32+
exit 1
33+
fi
34+
35+
pushd "${module_dir}"
3036

3137
# Compile with Java 11 and run the tests with Java 8 JVM
3238
mvn compile -T 1C
@@ -39,29 +45,15 @@ for repo in ${REPOS_UNDER_TEST//,/ }; do # Split on comma
3945
surefire_opt="-Djvm=${JAVA_HOME}/bin/java"
4046
fi
4147

42-
# Compile the Handwritten Library with the Protobuf-Java version to test source compatibility
48+
# Compile the library with the Protobuf-Java version to test source compatibility
4349
# Run unit tests to help check for any behavior differences (dependant on coverage)
44-
if [ "${repo}" == "google-cloud-java" ]; then
45-
# The `-am` command also builds anything these libraries depend on (i.e. proto-* and grpc-* sub modules)
46-
mvn test -B -V -ntp \
47-
-Dclirr.skip \
48-
-Denforcer.skip \
49-
-Dmaven.javadoc.skip \
50-
-Denforcer.skip \
51-
-Dprotobuf.version=${PROTOBUF_RUNTIME_VERSION} \
52-
-pl "${google_cloud_java_handwritten_maven_args}" -am \
53-
"${surefire_opt}" \
54-
-T 1C
55-
else
56-
mvn test -B -V -ntp \
57-
-Dclirr.skip \
58-
-Denforcer.skip \
59-
-Dmaven.javadoc.skip \
60-
-Denforcer.skip \
61-
-Dprotobuf.version=${PROTOBUF_RUNTIME_VERSION} \
62-
"${surefire_opt}" \
63-
-T 1C
64-
fi
50+
mvn test -B -V -ntp \
51+
-Dclirr.skip \
52+
-Denforcer.skip \
53+
-Dmaven.javadoc.skip \
54+
-Dprotobuf.version=${PROTOBUF_RUNTIME_VERSION} \
55+
"${surefire_opt}" \
56+
-T 1C
6557

6658
popd
6759
done

0 commit comments

Comments
 (0)