Skip to content

Commit bd5ef74

Browse files
test: add downstream check for spring-cloud-gcp (#3092)
Fixes https://togithub.com/googleapis/sdk-platform-java/issues/2534 The check takes 2 minutes
1 parent 699074e commit bd5ef74

File tree

4 files changed

+103
-10
lines changed

4 files changed

+103
-10
lines changed

.github/workflows/downstream.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,20 @@ jobs:
4747
run: ./.kokoro/presubmit/common_test.sh
4848
- name: Perform downstream compatibility testing
4949
run: REPOS_UNDER_TEST="${{ matrix.repo }}" ./.kokoro/presubmit/downstream-compatibility.sh
50+
downstream-compatibility-spring-generator:
51+
runs-on: ubuntu-22.04
52+
strategy:
53+
fail-fast: false
54+
steps:
55+
- uses: actions/checkout@v3
56+
- uses: actions/setup-java@v3
57+
with:
58+
java-version: 17
59+
distribution: temurin
60+
- run: mvn -version
61+
- name: Install xmllint
62+
run: |
63+
sudo apt-get update
64+
sudo apt-get -y install libxml2-utils
65+
- name: Perform downstream compatibility testing
66+
run: ./.kokoro/presubmit/downstream-compatibility-spring.sh

.kokoro/presubmit/common.sh

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16+
commonScriptDir=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
17+
1618
# In the given directory ($1),
1719
# update the pom.xml's dependency on the given artifact ($2) to the given version ($3)
1820
# ex: update_dependency google-cloud-java/google-cloud-jar-parent google-cloud-shared-dependencies 1.2.3
@@ -70,20 +72,41 @@ function parse_pom_version {
7072
# ex: find_last_release_version java-bigtable
7173
# ex: find_last_release_version java-storage 2.22.x
7274
function find_last_release_version {
75+
repo=$1
7376
branch=${2-"main"} # Default to using main branch
74-
curl -s -o "versions_$1.txt" "https://raw.githubusercontent.com/googleapis/$1/$branch/versions.txt"
77+
org=${3-"googleapis"}
78+
curl -s -o "versions_${repo}.txt" "https://raw.githubusercontent.com/${org}/${repo}/${branch}/versions.txt"
7579

7680
# First check to see if there's an entry for the overall repo. Used for google-cloud-java.
77-
primary_artifact=$(grep -E "^$1" "versions_$1.txt" | head -n 1)
78-
if [ -z "$primary_artifact" ]; then
81+
primary_artifact=$(grep -E "^${repo}" "versions_${repo}.txt" | head -n 1)
82+
if [ -z "${primary_artifact}" ]; then
7983
# Otherwise, use the first google-cloud-* artifact's version.
8084
primary_artifact=$(grep -E "^google-cloud-" "versions_$1.txt" | head -n 1)
8185
fi
82-
if [ -z "$primary_artifact" ]; then
86+
if [ -z "${primary_artifact}" ]; then
8387
echo "Unable to identify primary artifact for $1"
8488
exit 1
8589
fi
8690

8791
parts=($(echo "$primary_artifact" | tr ":" "\n"))
8892
echo "${parts[1]}"
8993
}
94+
95+
# copies settings.xml from the root of sdk-platform-java into Maven's home
96+
# folder
97+
function setup_maven_mirror {
98+
echo "Setup maven mirror"
99+
mkdir -p "${HOME}/.m2"
100+
cp "${commonScriptDir}/../../settings.xml" "${HOME}/.m2"
101+
}
102+
103+
function install_repo_modules {
104+
target_projects="$1"
105+
projects_arg=""
106+
if [ -n "${target_projects}" ]; then
107+
projects_arg="--projects ${target_projects}"
108+
fi
109+
echo "Installing this repo's modules to local maven."
110+
mvn -q -B -ntp install ${projects_arg} \
111+
-Dcheckstyle.skip -Dfmt.skip -DskipTests -T 1C
112+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
# Copyright 2024 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+
# This script is only meant to test spring-cloud-gpc, specifically on its
17+
# autoconfig generation workflow
18+
19+
set -eox pipefail
20+
21+
# Get the directory of the build script
22+
scriptDir=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
23+
cd "${scriptDir}/../.." # cd to the root of this repo
24+
source "$scriptDir/common.sh"
25+
26+
install_repo_modules
27+
GAPIC_GENERATOR_VERSION=$(parse_pom_version "gapic-generator-java-bom")
28+
echo "Install complete. gapic-generator-java-bom = $GAPIC_GENERATOR_VERSION"
29+
30+
pushd gapic-generator-java/target
31+
# Download and configure spring-cloud-gcp for testing
32+
last_release=$(find_last_release_version "spring-cloud-gcp" "main" "GoogleCloudPlatform")
33+
git clone "https://github.com/GoogleCloudPlatform/spring-cloud-gcp.git" --depth=1 --branch "v$last_release"
34+
update_all_poms_dependency "spring-cloud-gcp" "gapic-generator-java-bom" "${GAPIC_GENERATOR_VERSION}"
35+
36+
# Install spring-cloud-gcp modules
37+
pushd spring-cloud-gcp/spring-cloud-generator
38+
../mvnw \
39+
-U \
40+
--batch-mode \
41+
--no-transfer-progress \
42+
--show-version \
43+
--threads 1.5C \
44+
--define maven.test.skip=true \
45+
--define maven.javadoc.skip=true \
46+
install
47+
48+
49+
# Generate showcase autoconfig
50+
./scripts/generate-showcase.sh
51+
pushd showcase/showcase-spring-starter
52+
mvn verify
53+
popd # showcase/showcase-spring-starter
54+
55+
popd # spring-cloud-gcp/spring-cloud-generator
56+
popd # gapic-generator-java/target

.kokoro/presubmit/downstream-compatibility.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,15 @@ if [ -z "${REPOS_UNDER_TEST}" ]; then
2121
exit 1
2222
fi
2323

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

29-
echo "Setup maven mirror"
30-
mkdir -p "${HOME}/.m2"
31-
cp settings.xml "${HOME}/.m2"
30+
setup_maven_mirror
3231

33-
echo "Installing this repo's modules to local maven."
34-
mvn -q -B -ntp install --projects '!gapic-generator-java' \
35-
-Dcheckstyle.skip -Dfmt.skip -DskipTests -T 1C
32+
install_repo_modules '!gapic-generator-java'
3633
SHARED_DEPS_VERSION=$(parse_pom_version java-shared-dependencies)
3734
echo "Install complete. java-shared-dependencies = $SHARED_DEPS_VERSION"
3835

0 commit comments

Comments
 (0)