Skip to content

Commit

Permalink
ci: Add Downstream Protobuf-Java Source Compatibility Test
Browse files Browse the repository at this point in the history
  • Loading branch information
lqiu96 committed Dec 3, 2024
1 parent 254e9ff commit 6a28d36
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
on:
workflow_dispatch:
inputs:
protobuf_versions:
description: 'Comma separated list of Protobuf-Java versions (i.e. "3.25.5","4.28.3")'
# Default value for workflow_dispatch flow. If updating default value, update below as well.
default: '"3.25.5","4.28.3"'
required: true
schedule:
- cron: '0 1 * * *' # Nightly at 1am

name: Downstream Source Compatibility Nightly
jobs:
downstream-protobuf-source-test:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
repo:
- 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
# Specify the Protobuf versions here as well because the default values above are only supplied from
# the workflow_dispatch flow. Without this, the nightly workflow doesn't have a default input otherwise
# and would resolve to ''. When updating, update both places to keep default values consistent.
protobuf-version: ${{ fromJSON(format('[{0}]', inputs.protobuf_versions || '"3.25.5","4.28.3"')) }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
- run: mvn -version
- name: Perform downstream compatibility testing
run: REPOS_UNDER_TEST="${{ matrix.repo }}" PROTOBUF_RUNTIME_VERSION="${{ matrix.protobuf-version}}" ./.kokoro/presubmit/downstream-protobuf-source-compatibility.sh
53 changes: 53 additions & 0 deletions .kokoro/presubmit/downstream-protobuf-source-compatibility.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/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"
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"
exit 1
fi

# Get the directory of the build script
scriptDir=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
cd "${scriptDir}/../.." # cd to the root of this repo
source "$scriptDir/common.sh"

setup_maven_mirror

echo "Testing with Protobuf-Java v${PROTOBUF_RUNTIME_VERSION}"

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

0 comments on commit 6a28d36

Please sign in to comment.