xref: /aosp_15_r20/external/sdk-platform-java/.kokoro/presubmit/downstream-build.sh (revision 882aa7c72c3cd3b66e72a261bdd69b93f7de7670)
1*882aa7c7SMatt Gilbride#!/bin/bash
2*882aa7c7SMatt Gilbride# Copyright 2019 Google LLC
3*882aa7c7SMatt Gilbride#
4*882aa7c7SMatt Gilbride# Licensed under the Apache License, Version 2.0 (the "License");
5*882aa7c7SMatt Gilbride# you may not use this file except in compliance with the License.
6*882aa7c7SMatt Gilbride# You may obtain a copy of the License at
7*882aa7c7SMatt Gilbride#
8*882aa7c7SMatt Gilbride#      http://www.apache.org/licenses/LICENSE-2.0
9*882aa7c7SMatt Gilbride#
10*882aa7c7SMatt Gilbride# Unless required by applicable law or agreed to in writing, software
11*882aa7c7SMatt Gilbride# distributed under the License is distributed on an "AS IS" BASIS,
12*882aa7c7SMatt Gilbride# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*882aa7c7SMatt Gilbride# See the License for the specific language governing permissions and
14*882aa7c7SMatt Gilbride# limitations under the License.
15*882aa7c7SMatt Gilbride
16*882aa7c7SMatt Gilbrideset -eo pipefail
17*882aa7c7SMatt Gilbride
18*882aa7c7SMatt GilbrideSHOWCASE_VERSION=0.27.0
19*882aa7c7SMatt Gilbride
20*882aa7c7SMatt Gilbride## Get the directory of the build script
21*882aa7c7SMatt GilbridescriptDir=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
22*882aa7c7SMatt Gilbride## cd to the parent directory, i.e. the root of the git repo
23*882aa7c7SMatt Gilbridecd "${scriptDir}/../.."
24*882aa7c7SMatt Gilbride
25*882aa7c7SMatt Gilbrideif [ -z "${MODULES_UNDER_TEST}" ]; then
26*882aa7c7SMatt Gilbride  echo "MODULES_UNDER_TEST must be set to run downstream-build.sh"
27*882aa7c7SMatt Gilbride  exit 1
28*882aa7c7SMatt Gilbridefi
29*882aa7c7SMatt Gilbride
30*882aa7c7SMatt Gilbride# Use GCP Maven Mirror
31*882aa7c7SMatt Gilbridemkdir -p "${HOME}/.m2"
32*882aa7c7SMatt Gilbridecp settings.xml "${HOME}/.m2"
33*882aa7c7SMatt Gilbride
34*882aa7c7SMatt Gilbride### Round 1
35*882aa7c7SMatt Gilbride# Publish this repo's modules to local maven to make them available for downstream libraries
36*882aa7c7SMatt Gilbridemvn -B -ntp install --projects '!gapic-generator-java' \
37*882aa7c7SMatt Gilbride  -Dcheckstyle.skip -Dfmt.skip -DskipTests
38*882aa7c7SMatt Gilbride
39*882aa7c7SMatt Gilbride# Read the shared dependencies version
40*882aa7c7SMatt Gilbride# Namespace (xmlns) prevents xmllint from specifying tag names in XPath
41*882aa7c7SMatt GilbrideSHARED_DEPS_VERSION=$(sed -e 's/xmlns=".*"//' java-shared-dependencies/pom.xml | xmllint --xpath '/project/version/text()' -)
42*882aa7c7SMatt Gilbride
43*882aa7c7SMatt Gilbrideif [ -z "${SHARED_DEPS_VERSION}" ]; then
44*882aa7c7SMatt Gilbride  echo "Shared dependencies version is not found in pom.xml"
45*882aa7c7SMatt Gilbride  exit 1
46*882aa7c7SMatt Gilbridefi
47*882aa7c7SMatt Gilbride
48*882aa7c7SMatt Gilbride### Round 2
49*882aa7c7SMatt Gilbride# Update the shared-dependencies version in google-cloud-jar-parent
50*882aa7c7SMatt Gilbridegit clone "https://github.com/googleapis/google-cloud-java.git" --depth=1
51*882aa7c7SMatt Gilbridepushd google-cloud-java/google-cloud-jar-parent
52*882aa7c7SMatt Gilbridexmllint --shell pom.xml <<EOF
53*882aa7c7SMatt Gilbridesetns x=http://maven.apache.org/POM/4.0.0
54*882aa7c7SMatt Gilbridecd .//x:artifactId[text()="google-cloud-shared-dependencies"]
55*882aa7c7SMatt Gilbridecd ../x:version
56*882aa7c7SMatt Gilbrideset ${SHARED_DEPS_VERSION}
57*882aa7c7SMatt Gilbridesave pom.xml
58*882aa7c7SMatt GilbrideEOF
59*882aa7c7SMatt Gilbride
60*882aa7c7SMatt Gilbrideecho "Modifications to java-shared-dependencies:"
61*882aa7c7SMatt Gilbridegit diff
62*882aa7c7SMatt Gilbrideecho
63*882aa7c7SMatt Gilbridepopd
64*882aa7c7SMatt Gilbride
65*882aa7c7SMatt Gilbride### Round 3
66*882aa7c7SMatt Gilbride# Run showcase tests in GraalVM
67*882aa7c7SMatt Gilbride
68*882aa7c7SMatt Gilbride# Start showcase server
69*882aa7c7SMatt Gilbridemkdir -p /usr/src/showcase
70*882aa7c7SMatt Gilbridecurl --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
71*882aa7c7SMatt Gilbridepushd /usr/src/showcase/
72*882aa7c7SMatt Gilbridetar -xf showcase-*
73*882aa7c7SMatt Gilbride./gapic-showcase run &
74*882aa7c7SMatt Gilbride
75*882aa7c7SMatt Gilbride# Run showcase tests with `native` profile
76*882aa7c7SMatt Gilbridepopd
77*882aa7c7SMatt Gilbridepushd showcase
78*882aa7c7SMatt Gilbridemvn test -Pnative,-showcase -Denforcer.skip=true -ntp -B
79*882aa7c7SMatt Gilbridepopd
80*882aa7c7SMatt Gilbride
81*882aa7c7SMatt Gilbride### Round 4
82*882aa7c7SMatt Gilbride# Run the updated java-shared-dependencies BOM against google-cloud-java
83*882aa7c7SMatt Gilbridepushd google-cloud-java
84*882aa7c7SMatt Gilbridesource ./.kokoro/common.sh
85*882aa7c7SMatt GilbrideRETURN_CODE=0
86*882aa7c7SMatt Gilbridesetup_application_credentials
87*882aa7c7SMatt Gilbridesetup_cloud "$MODULES_UNDER_TEST"
88*882aa7c7SMatt Gilbriderun_graalvm_tests "$MODULES_UNDER_TEST"
89*882aa7c7SMatt Gilbride
90*882aa7c7SMatt Gilbride
91*882aa7c7SMatt Gilbride
92*882aa7c7SMatt Gilbrideexit $RETURN_CODE
93