From 177fe92acbb214483552db2dfa433c137a6d0d4b Mon Sep 17 00:00:00 2001 From: suztomo Date: Mon, 28 Oct 2019 08:16:52 -0400 Subject: [PATCH 1/6] Draft of bom-upper-bounds-check.sh --- .kokoro/bom-upper-bounds-check.sh | 51 +++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 .kokoro/bom-upper-bounds-check.sh diff --git a/.kokoro/bom-upper-bounds-check.sh b/.kokoro/bom-upper-bounds-check.sh new file mode 100755 index 000000000000..7a3926b697b2 --- /dev/null +++ b/.kokoro/bom-upper-bounds-check.sh @@ -0,0 +1,51 @@ +#!/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. + +# Presubmit to ensure the dependencies of the Google Libraries BOM, with the modification of change +# in the PR, pick up the highest versions among transitive dependencies. +# https://maven.apache.org/enforcer/enforcer-rules/requireUpperBoundDeps.html + +set -eo pipefail +# Display commands being run. +set -x + +cd github/google-cloud-java/ + +# Print out tool version +echo $JOB_TYPE +java -version +mvn -version +git version + +mvn install -DskipTests=true -Dmaven.javadoc.skip=true -Dgcloud.download.skip=true -B -V + +# Example version: '0.116.1-alpha-SNAPSHOT' +VERSION_POM=google-cloud-bom/pom.xml +# The property key for this repository in Google Libraries BOM +VERSION_KEY=google.cloud.java.version +VERSION=`grep '' $VERSION_POM |head -1 |perl -nle 'print $1 if m|(.+)|'` + +if [ -z "${VERSION}" ]; then + echo "Version is not found in ${VERSION_POM}" + exit 1 +fi +echo "Version: ${VERSION}" + +# Run the upper bound check against Google Libraries BOM in cloud-opensource-java +git clone https://github.com/GoogleCloudPlatform/cloud-opensource-java.git +cd cloud-opensource-java/boms/upper-bounds-check + +# This project has the enforcer rule with requireUpperBoundDeps +mvn validate -D${VERSION_KEY}=${VERSION} From f0cc490664d3ad38e9766befb078816e53c7e3af Mon Sep 17 00:00:00 2001 From: suztomo Date: Mon, 28 Oct 2019 08:28:59 -0400 Subject: [PATCH 2/6] Format --- .kokoro/bom-upper-bounds-check.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.kokoro/bom-upper-bounds-check.sh b/.kokoro/bom-upper-bounds-check.sh index 7a3926b697b2..be52e162bdc5 100755 --- a/.kokoro/bom-upper-bounds-check.sh +++ b/.kokoro/bom-upper-bounds-check.sh @@ -31,10 +31,10 @@ git version mvn install -DskipTests=true -Dmaven.javadoc.skip=true -Dgcloud.download.skip=true -B -V -# Example version: '0.116.1-alpha-SNAPSHOT' VERSION_POM=google-cloud-bom/pom.xml # The property key for this repository in Google Libraries BOM VERSION_KEY=google.cloud.java.version +# Example version: '0.116.1-alpha-SNAPSHOT' VERSION=`grep '' $VERSION_POM |head -1 |perl -nle 'print $1 if m|(.+)|'` if [ -z "${VERSION}" ]; then @@ -45,7 +45,6 @@ echo "Version: ${VERSION}" # Run the upper bound check against Google Libraries BOM in cloud-opensource-java git clone https://github.com/GoogleCloudPlatform/cloud-opensource-java.git -cd cloud-opensource-java/boms/upper-bounds-check - # This project has the enforcer rule with requireUpperBoundDeps +cd cloud-opensource-java/boms/upper-bounds-check mvn validate -D${VERSION_KEY}=${VERSION} From e8da764212761a3da74058f72ced72d13d96fc2b Mon Sep 17 00:00:00 2001 From: Tomo Suzuki Date: Mon, 28 Oct 2019 11:28:05 -0400 Subject: [PATCH 3/6] Added comment --- .kokoro/bom-upper-bounds-check.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.kokoro/bom-upper-bounds-check.sh b/.kokoro/bom-upper-bounds-check.sh index be52e162bdc5..52a2c00cbbf2 100755 --- a/.kokoro/bom-upper-bounds-check.sh +++ b/.kokoro/bom-upper-bounds-check.sh @@ -29,13 +29,14 @@ java -version mvn -version git version +# Make artifacts available for 'mvn validate' at the bottom mvn install -DskipTests=true -Dmaven.javadoc.skip=true -Dgcloud.download.skip=true -B -V -VERSION_POM=google-cloud-bom/pom.xml # The property key for this repository in Google Libraries BOM VERSION_KEY=google.cloud.java.version # Example version: '0.116.1-alpha-SNAPSHOT' -VERSION=`grep '' $VERSION_POM |head -1 |perl -nle 'print $1 if m|(.+)|'` +VERSION_POM=google-cloud-bom/pom.xml +VERSION=`perl -nle 'print $1 if m|(.+)|' $VERSION_POM |head -1` if [ -z "${VERSION}" ]; then echo "Version is not found in ${VERSION_POM}" @@ -45,6 +46,6 @@ echo "Version: ${VERSION}" # Run the upper bound check against Google Libraries BOM in cloud-opensource-java git clone https://github.com/GoogleCloudPlatform/cloud-opensource-java.git -# This project has the enforcer rule with requireUpperBoundDeps +# This upper-bounds-check project has the enforcer rule with requireUpperBoundDeps cd cloud-opensource-java/boms/upper-bounds-check mvn validate -D${VERSION_KEY}=${VERSION} From 1aa0e98559a539dbcda28a84e76b2130a422e6c6 Mon Sep 17 00:00:00 2001 From: Tomo Suzuki Date: Mon, 28 Oct 2019 12:33:01 -0400 Subject: [PATCH 4/6] Kokoro build file --- .kokoro/presubmit/bom-upper-bounds.cfg | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .kokoro/presubmit/bom-upper-bounds.cfg diff --git a/.kokoro/presubmit/bom-upper-bounds.cfg b/.kokoro/presubmit/bom-upper-bounds.cfg new file mode 100644 index 000000000000..1a49238a0d60 --- /dev/null +++ b/.kokoro/presubmit/bom-upper-bounds.cfg @@ -0,0 +1,12 @@ +# 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/java8" +} + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/google-cloud-java/.kokoro/bom-upper-bounds-check.sh" +} From 9df505853444436c3752cd0b492bfc9f8ede4953 Mon Sep 17 00:00:00 2001 From: Tomo Suzuki Date: Mon, 28 Oct 2019 13:49:27 -0400 Subject: [PATCH 5/6] Install libraries-bom before validate --- .kokoro/bom-upper-bounds-check.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.kokoro/bom-upper-bounds-check.sh b/.kokoro/bom-upper-bounds-check.sh index 52a2c00cbbf2..936bc855bf72 100755 --- a/.kokoro/bom-upper-bounds-check.sh +++ b/.kokoro/bom-upper-bounds-check.sh @@ -46,6 +46,10 @@ echo "Version: ${VERSION}" # Run the upper bound check against Google Libraries BOM in cloud-opensource-java git clone https://github.com/GoogleCloudPlatform/cloud-opensource-java.git + +cd cloud-opensource-java/boms/cloud-oss-bom +mvn install + # This upper-bounds-check project has the enforcer rule with requireUpperBoundDeps -cd cloud-opensource-java/boms/upper-bounds-check +cd ../upper-bounds-check mvn validate -D${VERSION_KEY}=${VERSION} From b66e454838a35d2c0bbede40f60a91654563766e Mon Sep 17 00:00:00 2001 From: suztomo Date: Mon, 28 Oct 2019 21:25:11 -0400 Subject: [PATCH 6/6] xmllint --- .kokoro/bom-upper-bounds-check.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.kokoro/bom-upper-bounds-check.sh b/.kokoro/bom-upper-bounds-check.sh index 936bc855bf72..9bdd09ca6b80 100755 --- a/.kokoro/bom-upper-bounds-check.sh +++ b/.kokoro/bom-upper-bounds-check.sh @@ -34,9 +34,10 @@ mvn install -DskipTests=true -Dmaven.javadoc.skip=true -Dgcloud.download.skip=tr # The property key for this repository in Google Libraries BOM VERSION_KEY=google.cloud.java.version -# Example version: '0.116.1-alpha-SNAPSHOT' +# Read the version of POM. Example version: '0.116.1-alpha-SNAPSHOT' VERSION_POM=google-cloud-bom/pom.xml -VERSION=`perl -nle 'print $1 if m|(.+)|' $VERSION_POM |head -1` +# Namespace (xmlns) prevents xmllint from specifying tag names in XPath +VERSION=`sed -e 's/xmlns=".*"//' $VERSION_POM | xmllint --xpath '/project/version/text()' -` if [ -z "${VERSION}" ]; then echo "Version is not found in ${VERSION_POM}"