1#!/bin/bash 2# Copyright 2019 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 16set -eo pipefail 17 18SHOWCASE_VERSION=0.27.0 19 20## Get the directory of the build script 21scriptDir=$(realpath "$(dirname "${BASH_SOURCE[0]}")") 22## cd to the parent directory, i.e. the root of the git repo 23cd "${scriptDir}/../.." 24 25if [ -z "${MODULES_UNDER_TEST}" ]; then 26 echo "MODULES_UNDER_TEST must be set to run downstream-build.sh" 27 exit 1 28fi 29 30# Use GCP Maven Mirror 31mkdir -p "${HOME}/.m2" 32cp settings.xml "${HOME}/.m2" 33 34### Round 1 35# Publish this repo's modules to local maven to make them available for downstream libraries 36mvn -B -ntp install --projects '!gapic-generator-java' \ 37 -Dcheckstyle.skip -Dfmt.skip -DskipTests 38 39# Read the shared dependencies version 40# Namespace (xmlns) prevents xmllint from specifying tag names in XPath 41SHARED_DEPS_VERSION=$(sed -e 's/xmlns=".*"//' java-shared-dependencies/pom.xml | xmllint --xpath '/project/version/text()' -) 42 43if [ -z "${SHARED_DEPS_VERSION}" ]; then 44 echo "Shared dependencies version is not found in pom.xml" 45 exit 1 46fi 47 48### Round 2 49# Update the shared-dependencies version in google-cloud-jar-parent 50git clone "https://github.com/googleapis/google-cloud-java.git" --depth=1 51pushd google-cloud-java/google-cloud-jar-parent 52xmllint --shell pom.xml <<EOF 53setns x=http://maven.apache.org/POM/4.0.0 54cd .//x:artifactId[text()="google-cloud-shared-dependencies"] 55cd ../x:version 56set ${SHARED_DEPS_VERSION} 57save pom.xml 58EOF 59 60echo "Modifications to java-shared-dependencies:" 61git diff 62echo 63popd 64 65### Round 3 66# Run showcase tests in GraalVM 67 68# Start showcase server 69mkdir -p /usr/src/showcase 70curl --location https://github.com/googleapis/gapic-showcase/releases/download/v"${SHOWCASE_VERSION}"/gapic-showcase-"${SHOWCASE_VERSION}"-linux-amd64.tar.gz --output /usr/src/showcase/showcase-"${SHOWCASE_VERSION}"-linux-amd64.tar.gz 71pushd /usr/src/showcase/ 72tar -xf showcase-* 73./gapic-showcase run & 74 75# Run showcase tests with `native` profile 76popd 77pushd showcase 78mvn test -Pnative,-showcase -Denforcer.skip=true -ntp -B 79popd 80 81### Round 4 82# Run the updated java-shared-dependencies BOM against google-cloud-java 83pushd google-cloud-java 84source ./.kokoro/common.sh 85RETURN_CODE=0 86setup_application_credentials 87setup_cloud "$MODULES_UNDER_TEST" 88run_graalvm_tests "$MODULES_UNDER_TEST" 89 90 91 92exit $RETURN_CODE 93