Skip to content

Commit

Permalink
ci: Add downstream native image testing (#1247)
Browse files Browse the repository at this point in the history
* ci: Add downstream native image testing

* ci: Parameterize MODULES_UNDER_TEST in .kokoro/presubmit/common.cfg
  • Loading branch information
burkedavison authored Jan 17, 2023
1 parent 8624f7d commit 41c45b1
Show file tree
Hide file tree
Showing 5 changed files with 149 additions and 6 deletions.
6 changes: 0 additions & 6 deletions .kokoro/common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,3 @@ gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"

# All builds use the trampoline script to run in docker.
build_file: "gapic-generator-java/.kokoro/trampoline.sh"

# Tell the trampoline which build file to use.
env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/gapic-generator-java/.kokoro/build.sh"
}
36 changes: 36 additions & 0 deletions .kokoro/presubmit/common.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/gapic-generator-java/.kokoro/presubmit/downstream-build.sh"
}

# TODO: remove this after we've migrated all tests and scripts
env_vars: {
key: "GCLOUD_PROJECT"
value: "cloud-java-ci-test"
}

env_vars: {
key: "GOOGLE_CLOUD_PROJECT"
value: "cloud-java-ci-test"
}

env_vars: {
key: "GOOGLE_APPLICATION_CREDENTIALS"
value: "secret_manager/cloud-java-ci-it-service-account"
}

env_vars: {
key: "SECRET_MANAGER_KEYS"
value: "cloud-java-ci-it-service-account"
}

# Defines the google-cloud-java modules to be tested downstream tested with GraalVM native image
# builds.
env_vars: {
key: "MODULES_UNDER_TEST"
value: "java-os-login,java-asset" # OS login's ITSystemTest exercises gax-java's native image
# reflect-config.json.
# Asset not required - added only as a sanity check.
}
99 changes: 99 additions & 0 deletions .kokoro/presubmit/downstream-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!/bin/bash
# Copyright 2019 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.

set -eo pipefail

## Get the directory of the build script
scriptDir=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
## cd to the parent directory, i.e. the root of the git repo
cd "${scriptDir}/.."

if [ -z "${MODULES_UNDER_TEST}" ]; then
echo "MODULES_UNDER_TEST must be set to run downstream-build.sh"
exit 1
fi

# Use GCP Maven Mirror
mkdir -p "${HOME}/.m2"
cp settings.xml "${HOME}/.m2"

### Round 1
# Publish this repo's modules to local maven to make them available for downstream libraries
mvn -B -ntp install --projects '!gapic-generator-java' \
-Dcheckstyle.skip -Dfmt.skip -DskipTests

# Read current BOM version
GAPIC_BOM_VERSION=$(sed -e 's/xmlns=".*"//' gapic-generator-java-bom/pom.xml | xmllint --xpath '/project/version/text()' -)

### Round 2
# Run the updated GAPIC BOM against HEAD of java-shared-dependencies
git clone "https://github.com/googleapis/java-shared-dependencies.git" --depth=1
pushd java-shared-dependencies/first-party-dependencies

# Replace GAPIC BOM version
xmllint --shell pom.xml <<EOF
setns x=http://maven.apache.org/POM/4.0.0
cd .//x:artifactId[text()="gapic-generator-java-bom"]
cd ../x:version
set ${GAPIC_BOM_VERSION}
save pom.xml
EOF

echo "Modifications to java-shared-dependencies:"
git diff
echo

cd ..
mvn verify install -B -V -ntp -fae \
-DskipTests=true \
-Dmaven.javadoc.skip=true \
-Dgcloud.download.skip=true \
-Denforcer.skip=true

# Namespace (xmlns) prevents xmllint from specifying tag names in XPath
SHARED_DEPS_VERSION=$(sed -e 's/xmlns=".*"//' pom.xml | xmllint --xpath '/project/version/text()' -)

if [ -z "${SHARED_DEPS_VERSION}" ]; then
echo "Shared dependencies version is not found in pom.xml"
exit 1
fi
popd

### Round 3
# Run the updated java-shared-dependencies BOM against google-cloud-java
git clone "https://github.com/googleapis/google-cloud-java.git" --depth=1
pushd google-cloud-java/google-cloud-jar-parent

# Replace java-shared-dependencies version
xmllint --shell pom.xml <<EOF
setns x=http://maven.apache.org/POM/4.0.0
cd .//x:artifactId[text()="google-cloud-shared-dependencies"]
cd ../x:version
set ${SHARED_DEPS_VERSION}
save pom.xml
EOF

echo "Modifications to google-cloud-java:"
git diff
echo

cd ..
source ./.kokoro/common.sh
RETURN_CODE=0
setup_application_credentials
setup_cloud "$MODULES_UNDER_TEST"
install_modules
run_graalvm_tests "$MODULES_UNDER_TEST"
exit $RETURN_CODE
7 changes: 7 additions & 0 deletions .kokoro/presubmit/graalvm-native-17-downstream.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Format: //devtools/kokoro/config/proto/build.proto

# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/graalvm17:22.3.0"
}
7 changes: 7 additions & 0 deletions .kokoro/presubmit/graalvm-native-downstream.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Format: //devtools/kokoro/config/proto/build.proto

# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/graalvm:22.3.0"
}

0 comments on commit 41c45b1

Please sign in to comment.