-
Notifications
You must be signed in to change notification settings - Fork 67
ci: Use Linkage Checker to test Binary Compatibility #3650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
a3ea5da
ci: Use Linkage Checker to test Binary Compatibility
lqiu96 b55c8ad
ci: Fix generating non-cloud api list
lqiu96 20a654c
ci: Fix exit code 1 for non-matching elements
lqiu96 35b4324
ci: Fix exit code 1 for non-matching elements
lqiu96 de0b889
ci: Create a map of non-cloud APIs
lqiu96 fe89f01
ci: Fix string interpolation issue with single quotes
lqiu96 cd0a03b
ci: Fix awk command
lqiu96 9d125ac
ch: Fix CI
lqiu96 dbe3051
chore: Clean up script
lqiu96 fe491b6
chore: Clean up script
lqiu96 002868d
chore: Clean up script
lqiu96 c20ca05
chore: Clean up script
lqiu96 b1b4d21
chore: Add mappings for the handwritten libraries
lqiu96 8a1aa88
chore: Fix typo
lqiu96 fa542c7
chore: Skip installing if repo is already built
lqiu96 7f295aa
ci: cd to downstream repo and build it
lqiu96 5237b8e
ci: cd back into root directory
lqiu96 c7a4b06
ci: use nested directories
lqiu96 1c07195
ci: use nested directories
lqiu96 49f658c
ci: use nested directories
lqiu96 dffa8fa
ci: Re-enable this for all handwritten libraries
lqiu96 edde57d
chore: Use function to build artifact list
lqiu96 594e5a8
chore: Use exec-linkage-checker maven profile
lqiu96 2c5e527
chore: Remove local install repo from source test
lqiu96 eaf2389
chore: Install artifacts for binary
lqiu96 e11cb7b
chore: Revert back to original source changes
lqiu96 ab4bd15
chore: Address PR comments
lqiu96 e58dc76
chore: Address PR comments
lqiu96 ee4177b
chore: Address PR comments
lqiu96 3b79741
chore: Run if there are either handwritten modules or gRPC modules
lqiu96 ad8544a
chore: Fix issue with gRPC modules to test
lqiu96 6b46510
chore: Add a few grpc modules for google-cloud-java
lqiu96 2fb338f
chore: Address PR comments
lqiu96 806fece
chore: update google-cloud-java deps
lqiu96 b746ed0
Merge branch 'main' into downstream-protobuf-binary-test
lqiu96 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| #!/bin/bash | ||
| # Copyright 2025 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| # Checks that the protobuf compatibility scripts provide non-empty input | ||
| function validate_protobuf_compatibility_script_inputs { | ||
| # Comma-delimited list of repos to test | ||
| if [ -z "${REPOS_UNDER_TEST}" ]; then | ||
| echo "REPOS_UNDER_TEST Env Var must be set. This script expects a" | ||
| echo "comma-delimited list: i.e REPOS_UNDER_TEST=\"java-bigtable,java-bigquery\"" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # A single version of Protobuf-Java runtime to test | ||
| if [ -z "${PROTOBUF_RUNTIME_VERSION}" ]; then | ||
| echo "PROTOBUF_RUNTIME_VERSION Env Var must be set. This script expects a single " | ||
| echo "Protobuf-Java runtime version i.e. PROTOBUF_RUNTIME_VERSION=\"4.28.3\"" | ||
| exit 1 | ||
| fi | ||
| } |
96 changes: 96 additions & 0 deletions
96
.kokoro/nightly/downstream-protobuf-binary-compatibility.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| #!/bin/bash | ||
| # Copyright 2025 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| set -eo pipefail | ||
|
|
||
| scriptDir=$(realpath "$(dirname "${BASH_SOURCE[0]}")") | ||
| source "${scriptDir}/common.sh" | ||
|
|
||
| validate_protobuf_compatibility_script_inputs | ||
|
|
||
| # Declare a map of downstream handwritten libraries and the relevant artifacts to test. The map stores a | ||
| # K/V pairing of (Key: repo name, Value: comma separate list of Group ID:Artifact ID pairings). Note: The | ||
| # value list doesn't hold the version and this needs to be parsed from the repo's versions.txt file | ||
| declare -A repo_linkage_checker_arguments | ||
| 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" | ||
| 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" | ||
| repo_linkage_checker_arguments["java-bigquery"]="com.google.cloud:google-cloud-bigquery" | ||
| 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" | ||
| 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" | ||
| 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" | ||
| repo_linkage_checker_arguments["java-logging"]="com.google.cloud:google-cloud-logging,com.google.api.grpc:grpc-google-cloud-logging-v2" | ||
| repo_linkage_checker_arguments["java-logging-logback"]="com.google.cloud:google-cloud-logging-logback" | ||
| repo_linkage_checker_arguments["java-pubsub"]="com.google.cloud:google-cloud-pubsub,com.google.api.grpc:grpc-google-cloud-pubsub-v1" | ||
| repo_linkage_checker_arguments["java-pubsublite"]="com.google.cloud:google-cloud-pubsublite,com.google.api.grpc:grpc-google-cloud-pubsublite-v1" | ||
| repo_linkage_checker_arguments["java-spanner-jdbc"]="com.google.cloud:google-cloud-spanner-jdbc" | ||
| 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" | ||
| 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" | ||
| repo_linkage_checker_arguments["java-storage-nio"]="com.google.cloud:google-cloud-nio" | ||
|
|
||
| # This function requires access to the versions.txt to retrieve the versions for the artifacts | ||
| # It will try to match the artifact_id in the versions.txt file and attach it to form the GAV | ||
| # The GAV list is required by Linkage Checker as program arguments | ||
| function build_program_arguments() { | ||
| artifact_list="${repo_linkage_checker_arguments[$1]}" | ||
|
|
||
| for artifact in ${artifact_list//,/ }; do # Split on comma | ||
| artifact_id=$(echo "${artifact}" | cut -d ':' -f2) | ||
|
|
||
| # The grep query tries to match `{artifact_id}:{released_version}:{current_version}`. | ||
| # The artifact_id must be exact otherwise multiple entries may match | ||
| version=$(cat "versions.txt" | grep -E "^${artifact_id}:.*:.*$" | cut -d ':' -f3) | ||
| repo_gav_coordinate="${artifact}:${version}" | ||
|
|
||
| # The first entry added is not separated with a comma. Avoids generating `,{ARTIFACT_LIST}` | ||
| if [ -z "${linkage_checker_arguments}" ]; then | ||
| linkage_checker_arguments="${repo_gav_coordinate}" | ||
| else | ||
| linkage_checker_arguments="${linkage_checker_arguments},${repo_gav_coordinate}" | ||
| fi | ||
| done | ||
| } | ||
|
|
||
| # cloud-opensource-java contains the Linkage Checker tool | ||
| git clone https://github.com/GoogleCloudPlatform/cloud-opensource-java.git | ||
| pushd cloud-opensource-java | ||
| mvn -B -ntp clean compile -T 1C | ||
| # Linkage Checker tool resides in the /dependencies subfolder | ||
| pushd dependencies | ||
|
|
||
| # REPOS_UNDER_TEST Env Var accepts a comma separated list of googleapis repos to test. For Github CI, | ||
| # this will be a single repo as Github will build a matrix of repos with each repo being tested in parallel. | ||
| # For local invocation, you can pass a list of repos to test multiple repos together. | ||
| for repo in ${REPOS_UNDER_TEST//,/ }; do # Split on comma | ||
blakeli0 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # Perform testing on main (with latest changes). Shallow copy as history is not important | ||
| git clone "https://github.com/googleapis/${repo}.git" --depth=1 | ||
| pushd "${repo}" | ||
| # Install all repo modules to ~/.m2 (there can be multiple relevant artifacts to test i.e. core, admin, control) | ||
| mvn -B -ntp install -T 1C -DskipTests -Dclirr.skip -Denforcer.skip | ||
|
|
||
| linkage_checker_arguments="" | ||
| build_program_arguments "${repo}" | ||
|
|
||
| # Linkage Checker /dependencies | ||
| popd | ||
|
|
||
| echo "Artifact List: ${linkage_checker_arguments}" | ||
| # The `-s` argument filters the linkage check problems that stem from the artifact | ||
| 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}" | ||
| echo "Running Linkage Checker on the repo's handwritten modules" | ||
| echo "Linkage Checker Program Arguments: ${program_args}" | ||
| mvn -B -ntp exec:java -Dexec.args="${program_args}" -P exec-linkage-checker | ||
| done | ||
| popd | ||
| popd | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious why Linkage Checker can not be run with Java 11+?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure yet. I suspect there may be older incompatible dependency versions, but there isn't much info given in the error message. GoogleCloudPlatform/cloud-opensource-java#2395
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a slight concern when we drop Java 11, maybe it's worthwhile to at least put the issue into our backlog.