Skip to content

Commit d7579ba

Browse files
authored
ci: Add Downstream Protobuf-Java Source Compatibility Test (#3405)
Set up a nightly CI job that tests Protobuf compatibility with downstream libraries. This step of the CI job is to test source compatibility. The nightly job will check the compatibility of these libraries with the latest in Protobuf-Java 3.x and and 4.x. This job can be manually invoked with the Protobuf-Java versions as a list. Future steps may introduce testing for binary compatibility.
1 parent 35f1310 commit d7579ba

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
required: true
11+
schedule:
12+
- cron: '0 1 * * *' # Nightly at 1am
13+
14+
name: Downstream Protobuf Compatibility Check Nightly
15+
jobs:
16+
downstream-protobuf-test:
17+
# Checks if PR comes from Release-Please branch or if invoked from nightly job
18+
if: github.head_ref == 'release-please--branches--main' || github.event_name == 'schedule'
19+
runs-on: ubuntu-22.04
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
repo:
24+
- google-cloud-java
25+
- java-bigtable
26+
- java-bigquery
27+
- java-bigquerystorage
28+
- java-datastore
29+
- java-firestore
30+
- java-logging
31+
- java-logging-logback
32+
- java-pubsub
33+
- java-pubsublite
34+
- java-spanner-jdbc
35+
- java-spanner
36+
- java-storage
37+
- java-storage-nio
38+
# Default Protobuf-Java versions to use are specified here. Without this, the nightly workflow won't know
39+
# which values to use and would resolve to ''.
40+
protobuf-version: ${{ fromJSON(format('[{0}]', inputs.protobuf_runtime_versions || '"3.25.5","4.28.3"')) }}
41+
steps:
42+
- uses: actions/checkout@v4
43+
- uses: actions/setup-java@v4
44+
with:
45+
java-version: 17
46+
distribution: temurin
47+
- name: Print Protobuf-Java testing version
48+
run: echo "Testing with Protobuf-Java v${{ matrix.protobuf-version }}"
49+
- name: Perform downstream source compatibility testing
50+
run: REPOS_UNDER_TEST="${{ matrix.repo }}" PROTOBUF_RUNTIME_VERSION="${{ matrix.protobuf-version}}" ./.kokoro/nightly/downstream-protobuf-source-compatibility.sh
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
# Comma-delimited list of repos to test with the local java-shared-dependencies
19+
if [ -z "${REPOS_UNDER_TEST}" ]; then
20+
echo "REPOS_UNDER_TEST must be set to run downstream-protobuf-source-compatibility.sh"
21+
echo "Expects a comma-delimited list: i.e REPOS_UNDER_TEST=\"java-bigtable,java-bigquery\""
22+
exit 1
23+
fi
24+
25+
# Version of Protobuf-Java runtime to compile with
26+
if [ -z "${PROTOBUF_RUNTIME_VERSION}" ]; then
27+
echo "PROTOBUF_RUNTIME_VERSION must be set to run downstream-protobuf-source-compatibility.sh"
28+
echo "Expects a single Protobuf-Java runtime version i.e. PROTOBUF_RUNTIME_VERSION=\"4.28.3\""
29+
exit 1
30+
fi
31+
32+
for repo in ${REPOS_UNDER_TEST//,/ }; do # Split on comma
33+
# Perform source-compatibility testing on main (latest changes)
34+
git clone "https://github.com/googleapis/$repo.git" --depth=1
35+
pushd "$repo"
36+
37+
# Compile the Handwritten Library with the Protobuf-Java version to test source compatibility
38+
# Run unit tests to help check for any behavior differences (dependant on coverage)
39+
mvn clean test -B -V -ntp \
40+
-Dclirr.skip=true \
41+
-Denforcer.skip=true \
42+
-Dmaven.javadoc.skip=true \
43+
-Dprotobuf.version=${PROTOBUF_RUNTIME_VERSION} \
44+
-T 1C
45+
popd
46+
done

0 commit comments

Comments
 (0)