Skip to content

Commit

Permalink
test: add downstream check for spring-cloud-gcp (#3092)
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomarquezp authored Aug 29, 2024
1 parent 699074e commit bd5ef74
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 10 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/downstream.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,20 @@ jobs:
run: ./.kokoro/presubmit/common_test.sh
- name: Perform downstream compatibility testing
run: REPOS_UNDER_TEST="${{ matrix.repo }}" ./.kokoro/presubmit/downstream-compatibility.sh
downstream-compatibility-spring-generator:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
- run: mvn -version
- name: Install xmllint
run: |
sudo apt-get update
sudo apt-get -y install libxml2-utils
- name: Perform downstream compatibility testing
run: ./.kokoro/presubmit/downstream-compatibility-spring.sh
31 changes: 27 additions & 4 deletions .kokoro/presubmit/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

commonScriptDir=$(realpath "$(dirname "${BASH_SOURCE[0]}")")

# In the given directory ($1),
# update the pom.xml's dependency on the given artifact ($2) to the given version ($3)
# ex: update_dependency google-cloud-java/google-cloud-jar-parent google-cloud-shared-dependencies 1.2.3
Expand Down Expand Up @@ -70,20 +72,41 @@ function parse_pom_version {
# ex: find_last_release_version java-bigtable
# ex: find_last_release_version java-storage 2.22.x
function find_last_release_version {
repo=$1
branch=${2-"main"} # Default to using main branch
curl -s -o "versions_$1.txt" "https://raw.githubusercontent.com/googleapis/$1/$branch/versions.txt"
org=${3-"googleapis"}
curl -s -o "versions_${repo}.txt" "https://raw.githubusercontent.com/${org}/${repo}/${branch}/versions.txt"

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

parts=($(echo "$primary_artifact" | tr ":" "\n"))
echo "${parts[1]}"
}

# copies settings.xml from the root of sdk-platform-java into Maven's home
# folder
function setup_maven_mirror {
echo "Setup maven mirror"
mkdir -p "${HOME}/.m2"
cp "${commonScriptDir}/../../settings.xml" "${HOME}/.m2"
}

function install_repo_modules {
target_projects="$1"
projects_arg=""
if [ -n "${target_projects}" ]; then
projects_arg="--projects ${target_projects}"
fi
echo "Installing this repo's modules to local maven."
mvn -q -B -ntp install ${projects_arg} \
-Dcheckstyle.skip -Dfmt.skip -DskipTests -T 1C
}
56 changes: 56 additions & 0 deletions .kokoro/presubmit/downstream-compatibility-spring.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash
# Copyright 2024 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.

# This script is only meant to test spring-cloud-gpc, specifically on its
# autoconfig generation workflow

set -eox pipefail

# 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"

install_repo_modules
GAPIC_GENERATOR_VERSION=$(parse_pom_version "gapic-generator-java-bom")
echo "Install complete. gapic-generator-java-bom = $GAPIC_GENERATOR_VERSION"

pushd gapic-generator-java/target
# Download and configure spring-cloud-gcp for testing
last_release=$(find_last_release_version "spring-cloud-gcp" "main" "GoogleCloudPlatform")
git clone "https://github.com/GoogleCloudPlatform/spring-cloud-gcp.git" --depth=1 --branch "v$last_release"
update_all_poms_dependency "spring-cloud-gcp" "gapic-generator-java-bom" "${GAPIC_GENERATOR_VERSION}"

# Install spring-cloud-gcp modules
pushd spring-cloud-gcp/spring-cloud-generator
../mvnw \
-U \
--batch-mode \
--no-transfer-progress \
--show-version \
--threads 1.5C \
--define maven.test.skip=true \
--define maven.javadoc.skip=true \
install


# Generate showcase autoconfig
./scripts/generate-showcase.sh
pushd showcase/showcase-spring-starter
mvn verify
popd # showcase/showcase-spring-starter

popd # spring-cloud-gcp/spring-cloud-generator
popd # gapic-generator-java/target
9 changes: 3 additions & 6 deletions .kokoro/presubmit/downstream-compatibility.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,15 @@ if [ -z "${REPOS_UNDER_TEST}" ]; then
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"

echo "Setup maven mirror"
mkdir -p "${HOME}/.m2"
cp settings.xml "${HOME}/.m2"
setup_maven_mirror

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

Expand Down

0 comments on commit bd5ef74

Please sign in to comment.