Skip to content
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

ci: Add Downstream Protobuf-Java Source Compatibility Test #3405

Merged
merged 11 commits into from
Dec 12, 2024
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
on:
pull_request:
# Runs on PRs targeting main, but will be filtered for Release PRs
branches:
- 'main'
workflow_dispatch:
inputs:
protobuf_runtime_versions:
description: 'Comma separated list of Protobuf-Java versions (i.e. "3.25.x","4.x.y")'
required: true
schedule:
- cron: '0 1 * * *' # Nightly at 1am

name: Downstream Protobuf Compatibility Check Nightly
jobs:
downstream-protobuf-test:
# Checks if PR comes from Release-Please branch or if invoked from nightly job
if: github.head_ref == 'release-please--branches--main' || github.event_name == 'schedule'
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
repo:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are all of them dependent on protobuf-java? For example, I don't see java-storage-nio is dependent on protobuf-java. Or we are adding all handwritten libraries here in case they start depending on protobuf-java in the future?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a quick look and don't think they're all dependent on protobuf-java. java-storage-nio seems to be the odd one out that doesn't have any protobuf-java references at all and a few others have some references only in tests.

adding all handwritten libraries here in case they start depending on protobuf-java in the future

I think it'll be safer to keep all of the downstream libraries in here. Just to be safe in case there are references of Protobuf-Java added in source for downstream libraries.

- google-cloud-java
- java-bigtable
- java-bigquery
- java-bigquerystorage
- java-datastore
- java-firestore
- java-logging
- java-logging-logback
- java-pubsub
- java-pubsublite
- java-spanner-jdbc
- java-spanner
- java-storage
- java-storage-nio
# Default Protobuf-Java versions to use are specified here. Without this, the nightly workflow won't know
# which values to use and would resolve to ''.
protobuf-version: ${{ fromJSON(format('[{0}]', inputs.protobuf_runtime_versions || '"3.25.5","4.28.3"')) }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
- name: Print Protobuf-Java testing version
run: echo "Testing with Protobuf-Java v${{ matrix.protobuf-version }}"
- name: Perform downstream source compatibility testing
run: REPOS_UNDER_TEST="${{ matrix.repo }}" PROTOBUF_RUNTIME_VERSION="${{ matrix.protobuf-version}}" ./.kokoro/nightly/downstream-protobuf-source-compatibility.sh
46 changes: 46 additions & 0 deletions .kokoro/nightly/downstream-protobuf-source-compatibility.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash
# Copyright 2023 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

# Comma-delimited list of repos to test with the local java-shared-dependencies
if [ -z "${REPOS_UNDER_TEST}" ]; then
echo "REPOS_UNDER_TEST must be set to run downstream-protobuf-source-compatibility.sh"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we provide more detailed error hint if they are not supplied? For example, what are the expected format of the input etc. Same comment for PROTOBUF_RUNTIME_VERSION below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I can add an example

echo "Expects a comma-delimited list: i.e REPOS_UNDER_TEST=\"java-bigtable,java-bigquery\""
exit 1
fi

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

for repo in ${REPOS_UNDER_TEST//,/ }; do # Split on comma
# Perform source-compatibility testing on main (latest changes)
git clone "https://github.com/googleapis/$repo.git" --depth=1
pushd "$repo"

# Compile the Handwritten Library with the Protobuf-Java version to test source compatibility
# Run unit tests to help check for any behavior differences (dependant on coverage)
mvn clean test -B -V -ntp \
-Dclirr.skip=true \
-Denforcer.skip=true \
-Dmaven.javadoc.skip=true \
-Dprotobuf.version=${PROTOBUF_RUNTIME_VERSION} \
-T 1C
popd
done
Loading