Skip to content

Commit 2605115

Browse files
authored
ci: Remove migrated libraries from downstream protobuf check (#12664)
1 parent 6675310 commit 2605115

File tree

4 files changed

+214
-24
lines changed

4 files changed

+214
-24
lines changed

.github/workflows/sdk-platform-java-downstream_protobuf_compatibility_check_nightly.yaml

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,44 +12,25 @@ on:
1212
schedule:
1313
- cron: '0 1 * * *' # Nightly at 1am
1414

15+
# This job intends to test the compatibility of the Protobuf version against repos not in the
16+
# monorepo. As repos are migrated to the monorepo, this job will be obsolete and turned off.
1517
name: sdk-platform-java Downstream Protobuf Compatibility Check Nightly
16-
env:
17-
BUILD_SUBDIR: sdk-platform-java
1818
jobs:
19-
filter:
20-
runs-on: ubuntu-latest
21-
outputs:
22-
library: ${{ steps.filter.outputs.library }}
23-
steps:
24-
- uses: actions/checkout@v4
25-
- uses: dorny/paths-filter@v3
26-
id: filter
27-
with:
28-
filters: |
29-
library:
30-
- 'sdk-platform-java/**'
3119
downstream-protobuf-test:
32-
needs: filter
3320
# This job runs if any of the three conditions match:
3421
# 1. PR is raised from Release-Please (PR comes from branch: release-please--branches-main)
3522
# 2. Job is invoked by the nightly job (scheduled event)
3623
# 3. Job is manually invoked via Github UI (workflow_dispatch event)
37-
if: needs.filter.outputs.library == 'true' && (github.head_ref == 'release-please--branches--main' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
24+
if: github.head_ref == 'release-please--branches--main' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
3825
runs-on: ubuntu-22.04
3926
strategy:
4027
fail-fast: false
4128
matrix:
4229
repo:
43-
- google-cloud-java
4430
- java-bigtable
45-
- java-bigquery
4631
- java-firestore
4732
- java-pubsub
4833
- java-pubsublite
49-
- java-spanner-jdbc
50-
- java-spanner
51-
- java-storage
52-
- java-storage-nio
5334
# Default Protobuf-Java versions to use are specified here. Without this, the nightly workflow won't know
5435
# which values to use and would resolve to ''.
5536
protobuf-version: ${{ fromJSON(format('[{0}]', inputs.protobuf_runtime_versions || '"4.33.5"')) }}
@@ -70,7 +51,7 @@ jobs:
7051
- name: Print Protobuf-Java testing version
7152
run: echo "Testing with Protobuf-Java v${{ matrix.protobuf-version }}"
7253
- name: Perform downstream source compatibility testing
73-
run: REPOS_UNDER_TEST="${{ matrix.repo }}" PROTOBUF_RUNTIME_VERSION="${{ matrix.protobuf-version }}" ./.kokoro/nightly/downstream-protobuf-source-compatibility.sh
54+
run: REPOS_UNDER_TEST="${{ matrix.repo }}" PROTOBUF_RUNTIME_VERSION="${{ matrix.protobuf-version }}" ./sdk-platform-java/.kokoro/nightly/downstream-protobuf-source-compatibility.sh
7455
- name: Perform downstream binary compatibility testing
75-
run: REPOS_UNDER_TEST="${{ matrix.repo }}" PROTOBUF_RUNTIME_VERSION="${{ matrix.protobuf-version }}" ./.kokoro/nightly/downstream-protobuf-binary-compatibility.sh
56+
run: REPOS_UNDER_TEST="${{ matrix.repo }}" PROTOBUF_RUNTIME_VERSION="${{ matrix.protobuf-version }}" ./sdk-platform-java/.kokoro/nightly/downstream-protobuf-binary-compatibility.sh
7657

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
# 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+
22+
# Checks that the protobuf compatibility scripts provide non-empty input
23+
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\""
28+
exit 1
29+
fi
30+
31+
# A single version of Protobuf-Java runtime to test
32+
if [ -z "${PROTOBUF_RUNTIME_VERSION}" ]; then
33+
echo "PROTOBUF_RUNTIME_VERSION Env Var must be set. This script expects a single "
34+
echo "Protobuf-Java runtime version i.e. PROTOBUF_RUNTIME_VERSION=\"4.28.3\""
35+
exit 1
36+
fi
37+
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
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+
set -eo pipefail
17+
18+
scriptDir=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
19+
source "${scriptDir}/common.sh"
20+
21+
validate_protobuf_compatibility_script_inputs
22+
23+
# 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"
41+
42+
# This function requires access to the versions.txt to retrieve the versions for the artifacts
43+
# It will try to match the artifact_id in the versions.txt file and attach it to form the GAV
44+
# The GAV list is required by Linkage Checker as program arguments
45+
function build_program_arguments() {
46+
artifact_list="${repo_linkage_checker_arguments[$1]}"
47+
48+
for artifact in ${artifact_list//,/ }; do # Split on comma
49+
artifact_id=$(echo "${artifact}" | cut -d ':' -f2)
50+
51+
# The grep query tries to match `{artifact_id}:{released_version}:{current_version}`.
52+
# 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}"
55+
56+
# The first entry added is not separated with a comma. Avoids generating `,{ARTIFACT_LIST}`
57+
if [ -z "${linkage_checker_arguments}" ]; then
58+
linkage_checker_arguments="${repo_gav_coordinate}"
59+
else
60+
linkage_checker_arguments="${linkage_checker_arguments},${repo_gav_coordinate}"
61+
fi
62+
done
63+
}
64+
65+
# TODO(https://github.com/GoogleCloudPlatform/cloud-opensource-java/issues/2395): Java 17+ support for Linkage Checker
66+
# cloud-opensource-java contains the Linkage Checker tool
67+
git clone https://github.com/GoogleCloudPlatform/cloud-opensource-java.git
68+
pushd cloud-opensource-java
69+
mvn -B -ntp clean compile -T 1C
70+
# Linkage Checker tool resides in the /dependencies subfolder
71+
pushd dependencies
72+
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
88+
fi
89+
90+
91+
linkage_checker_arguments=""
92+
build_program_arguments "${repo}"
93+
94+
# Linkage Checker /dependencies
95+
popd
96+
97+
echo "Artifact List: ${linkage_checker_arguments}"
98+
# The `-s` argument filters the linkage check problems that stem from the artifact
99+
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"
101+
echo "Linkage Checker Program Arguments: ${program_args}"
102+
mvn -B -ntp exec:java -Dexec.args="${program_args}" -P exec-linkage-checker
103+
done
104+
popd
105+
popd
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
# Copyright 2023 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+
set -eo pipefail
17+
18+
scriptDir=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
19+
source "${scriptDir}/common.sh"
20+
21+
validate_protobuf_compatibility_script_inputs
22+
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"
30+
31+
# Compile with Java 11 and run the tests with Java 8 JVM
32+
mvn compile -T 1C
33+
34+
# JAVA8_HOME is set by the GH Actions CI
35+
if [ -n "${JAVA8_HOME}" ]; then
36+
surefire_opt="-Djvm=${JAVA8_HOME}/bin/java"
37+
else
38+
# Provide a default value for local executions that don't configure JAVA8_HOME
39+
surefire_opt="-Djvm=${JAVA_HOME}/bin/java"
40+
fi
41+
42+
# Compile the Handwritten Library with the Protobuf-Java version to test source compatibility
43+
# 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
65+
66+
popd
67+
done

0 commit comments

Comments
 (0)