From cfdc2e602b2a146dd3aa3670725e70d9393f046b Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Mon, 30 Mar 2020 15:54:28 -0700 Subject: [PATCH] chore: use java helper for templates (#195) https://github.com/googleapis/java-storage/commit/b0ffd0b9c41123b096d32a3e4fdd1210d6279e2a commit b0ffd0b9c41123b096d32a3e4fdd1210d6279e2a Author: Jeff Ching Date: Wed Mar 18 17:04:08 2020 -0700 chore: use java helper for templates (#195) We are cleaning up usage of common templates in synthtool. This allows us the cleanup usage in a centralized place rather than in 60+ repos --- .kokoro/build.sh | 19 ++++++---------- .kokoro/common.sh | 44 -------------------------------------- .kokoro/dependencies.sh | 15 ++++--------- .kokoro/linkage-monitor.sh | 22 ++++++------------- renovate.json | 6 ++---- synth.metadata | 10 ++++----- synth.py | 7 ++---- 7 files changed, 27 insertions(+), 96 deletions(-) delete mode 100644 .kokoro/common.sh diff --git a/.kokoro/build.sh b/.kokoro/build.sh index 86bb6be34..f833a0621 100755 --- a/.kokoro/build.sh +++ b/.kokoro/build.sh @@ -20,22 +20,17 @@ scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}")) ## cd to the parent directory, i.e. the root of the git repo cd ${scriptDir}/.. -# include common functions -source ${scriptDir}/common.sh - # Print out Java version java -version echo ${JOB_TYPE} -# attempt to install 3 times with exponential backoff (starting with 10 seconds) -retry_with_backoff 3 10 \ - mvn install -B -V \ - -DskipTests=true \ - -Dclirr.skip=true \ - -Denforcer.skip=true \ - -Dmaven.javadoc.skip=true \ - -Dgcloud.download.skip=true \ - -T 1C +mvn install -B -V \ + -DskipTests=true \ + -Dclirr.skip=true \ + -Denforcer.skip=true \ + -Dmaven.javadoc.skip=true \ + -Dgcloud.download.skip=true \ + -T 1C # if GOOGLE_APPLICATION_CREDIENTIALS is specified as a relative path prepend Kokoro root directory onto it if [[ ! -z "${GOOGLE_APPLICATION_CREDENTIALS}" && "${GOOGLE_APPLICATION_CREDENTIALS}" != /* ]]; then diff --git a/.kokoro/common.sh b/.kokoro/common.sh deleted file mode 100644 index a3bbc5f67..000000000 --- a/.kokoro/common.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -# Copyright 2020 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 - -function retry_with_backoff { - attempts_left=$1 - sleep_seconds=$2 - shift 2 - command=$@ - - echo "${command}" - ${command} - exit_code=$? - - if [[ $exit_code == 0 ]] - then - return 0 - fi - - # failure - if [[ ${attempts_left} > 0 ]] - then - echo "failure (${exit_code}), sleeping ${sleep_seconds}..." - sleep ${sleep_seconds} - new_attempts=$((${attempts_left} - 1)) - new_sleep=$((${sleep_seconds} * 2)) - retry_with_backoff ${new_attempts} ${new_sleep} ${command} - fi - - return $exit_code -} diff --git a/.kokoro/dependencies.sh b/.kokoro/dependencies.sh index 0aade871c..04a288b1a 100755 --- a/.kokoro/dependencies.sh +++ b/.kokoro/dependencies.sh @@ -15,13 +15,7 @@ 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}/.. - -# include common functions -source ${scriptDir}/common.sh +cd github/java-storage/ # Print out Java java -version @@ -30,9 +24,8 @@ echo $JOB_TYPE export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=128m" # this should run maven enforcer -retry_with_backoff 3 10 \ - mvn install -B -V \ - -DskipTests=true \ - -Dclirr.skip=true +mvn install -B -V \ + -DskipTests=true \ + -Dclirr.skip=true mvn -B dependency:analyze -DfailOnWarning=true diff --git a/.kokoro/linkage-monitor.sh b/.kokoro/linkage-monitor.sh index 759ab4e2c..158641cbe 100755 --- a/.kokoro/linkage-monitor.sh +++ b/.kokoro/linkage-monitor.sh @@ -17,26 +17,18 @@ set -eo pipefail # Display commands being run. set -x -## 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}/.. - -# include common functions -source ${scriptDir}/common.sh +cd github/java-storage/ # Print out Java version java -version echo ${JOB_TYPE} -# attempt to install 3 times with exponential backoff (starting with 10 seconds) -retry_with_backoff 3 10 \ - mvn install -B -V \ - -DskipTests=true \ - -Dclirr.skip=true \ - -Denforcer.skip=true \ - -Dmaven.javadoc.skip=true \ - -Dgcloud.download.skip=true +mvn install -B -V \ + -DskipTests=true \ + -Dclirr.skip=true \ + -Denforcer.skip=true \ + -Dmaven.javadoc.skip=true \ + -Dgcloud.download.skip=true # Kokoro job cloud-opensource-java/ubuntu/linkage-monitor-gcs creates this JAR JAR=linkage-monitor-latest-all-deps.jar diff --git a/renovate.json b/renovate.json index 1dcdf893f..fc6412701 100644 --- a/renovate.json +++ b/renovate.json @@ -56,9 +56,7 @@ }, { "packagePatterns": [ - "^com.google.cloud:google-cloud-storage", - "^com.google.cloud:libraries-bom", - "^com.google.cloud.samples:shared-configuration" + "^com.google.cloud:libraries-bom" ], "semanticCommitType": "chore", "semanticCommitScope": "deps" @@ -77,4 +75,4 @@ } ], "semanticCommits": true -} \ No newline at end of file +} diff --git a/synth.metadata b/synth.metadata index a1a030a11..66cd387f8 100644 --- a/synth.metadata +++ b/synth.metadata @@ -1,11 +1,11 @@ { - "updateTime": "2020-03-30T22:54:26.936389Z", + "updateTime": "2020-03-17T18:53:43.239577Z", "sources": [ { - "git": { - "name": "synthtool", - "remote": "https://github.com/googleapis/synthtool.git", - "sha": "a003d8655d3ebec2bbbd5fc3898e91e152265c67" + "template": { + "name": "java_library", + "origin": "synthtool.gcp", + "version": "2020.2.4" } } ] diff --git a/synth.py b/synth.py index f6413b30c..aa99a78bd 100644 --- a/synth.py +++ b/synth.py @@ -14,12 +14,9 @@ """This script is used to synthesize generated parts of this library.""" -import synthtool as s -import synthtool.gcp as gcp +import synthtool.languages.java -common_templates = gcp.CommonTemplates() -templates = common_templates.java_library() -s.copy(templates, excludes=[ +java.common_templates(excludes=[ 'README.md', '.kokoro/presubmit/integration.cfg' ])