diff --git a/.kokoro/build.bat b/.kokoro/build.bat index d51c702cb..c76f2bc2f 100644 --- a/.kokoro/build.bat +++ b/.kokoro/build.bat @@ -1,8 +1,11 @@ REM This file runs tests for merges, PRs, and nightlies. -REM There are a few rules for what tests are run: -REM * PRs run all non-acceptance tests for every library. -REM * Merges run all non-acceptance tests for every library, and acceptance tests for all altered libraries. -REM * Nightlies run all acceptance tests for every library. -REM Currently only runs tests on 2.5.1 -"C:\Program Files\Git\bin\bash.exe" github/google-api-ruby-client/.kokoro/windows.sh +SET url="https://raw.githubusercontent.com/googleapis/google-cloud-ruby/master/.kokoro/build.bat" + +SET "download=powershell -C Invoke-WebRequest -Uri %url% -OutFile master-build.bat" + +SET EXIT_STATUS=1 + +%download% && master-build.bat && SET EXIT_STATUS=0 + +EXIT %EXIT_STATUS% diff --git a/.kokoro/build.sh b/.kokoro/build.sh index fd0421892..7f4e00fbb 100755 --- a/.kokoro/build.sh +++ b/.kokoro/build.sh @@ -1,34 +1,4 @@ #!/bin/bash -# This file runs tests for merges, PRs, and nightlies. -# There are a few rules for what tests are run: -# * PRs run all non-acceptance tests for every library. -# * Merges run all non-acceptance tests for every library, and acceptance tests for all altered libraries. -# * Nightlies run all acceptance tests for every library. - -set -eo pipefail - -# Debug: show build environment -env | grep KOKORO - -cd github/google-api-ruby-client/ - -versions=($RUBY_VERSIONS) - -# Temporary workaround for a known bundler+docker issue: -# https://github.com/bundler/bundler/issues/6154 -export BUNDLE_GEMFILE= - -# Capture failures -EXIT_STATUS=0 # everything passed -function set_failed_status { - EXIT_STATUS=1 -} - -for version in "${versions[@]}"; do - rbenv global "$version" - echo "Using Ruby $version" - (bundle update && bundle exec rake) || set_failed_status -done - -exit $EXIT_STATUS \ No newline at end of file +script_url="https://raw.githubusercontent.com/googleapis/google-cloud-ruby/master/.kokoro/build.sh" +curl -o master-build.sh $script_url && source master-build.sh diff --git a/.kokoro/common.cfg b/.kokoro/common.cfg deleted file mode 100644 index b6ca6d114..000000000 --- a/.kokoro/common.cfg +++ /dev/null @@ -1,22 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Download trampoline resources. These will be in ${KOKORO_GFILE_DIR} -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" - -# All builds use the trampoline script to run in docker. -build_file: "google-api-ruby-client/.kokoro/trampoline.sh" - -# Download secrets from Cloud Storage. -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-api-ruby-client" - -# Tell the trampoline which build file to use. -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/google-api-ruby-client/.kokoro/build.sh" -} - -action { - define_artifacts { - regex: "**/*sponge_log.xml" - } -} \ No newline at end of file diff --git a/.kokoro/continuous/common.cfg b/.kokoro/continuous/common.cfg index 865ec6db6..9ddc8dad9 100644 --- a/.kokoro/continuous/common.cfg +++ b/.kokoro/continuous/common.cfg @@ -17,4 +17,9 @@ gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-ruby" env_vars: { key: "JOB_TYPE" value: "continuous" -} \ No newline at end of file +} + +env_vars: { + key: "REPO_DIR" + value: "github/google-api-ruby-client" +} diff --git a/.kokoro/continuous/windows.cfg b/.kokoro/continuous/windows.cfg index 53d85495b..1fd4552f6 100644 --- a/.kokoro/continuous/windows.cfg +++ b/.kokoro/continuous/windows.cfg @@ -1,3 +1,19 @@ # Format: //devtools/kokoro/config/proto/build.proto -build_file: "google-api-ruby-client/.kokoro/build.bat" \ No newline at end of file +build_file: "google-api-ruby-client/.kokoro/trampoline.bat" + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/yoshi-ruby/windows" +} + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/google-api-ruby-client/.kokoro/build.bat" +} + +env_vars: { + key: "REPO_DIR" + value: "google-api-ruby-client" +} diff --git a/.kokoro/osx.sh b/.kokoro/osx.sh index fd1375d38..8be8ec054 100644 --- a/.kokoro/osx.sh +++ b/.kokoro/osx.sh @@ -1,35 +1,4 @@ #!/bin/bash -# This file runs tests for merges, PRs, and nightlies. -# There are a few rules for what tests are run: -# * PRs run all non-acceptance tests for every library. -# * Merges run all non-acceptance tests for every library, and acceptance tests for all altered libraries. -# * Nightlies run all acceptance tests for every library. -# * Currently only runs tests on 2.5.0 - -set -eo pipefail - -# Debug: show build environment -env | grep KOKORO - -cd github/google-api-ruby-client/ - -# Print out Ruby version -ruby --version - -# Temporary workaround for a known bundler+docker issue: -# https://github.com/bundler/bundler/issues/6154 -export BUNDLE_GEMFILE= - -# Capture failures -EXIT_STATUS=0 # everything passed -function set_failed_status { - EXIT_STATUS=1 -} - -gem install bundler --version 1.17.3 - - -(bundle update && bundle exec rake) || set_failed_status - -exit $EXIT_STATUS +script_url="https://raw.githubusercontent.com/googleapis/google-cloud-ruby/master/.kokoro/osx.sh" +curl -o master-osx.sh $script_url && source master-osx.sh diff --git a/.kokoro/presubmit/common.cfg b/.kokoro/presubmit/common.cfg index d38b1e72b..2e7d7a321 100644 --- a/.kokoro/presubmit/common.cfg +++ b/.kokoro/presubmit/common.cfg @@ -16,4 +16,9 @@ gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-ruby" env_vars: { key: "JOB_TYPE" value: "presubmit" -} \ No newline at end of file +} + +env_vars: { + key: "REPO_DIR" + value: "github/google-api-ruby-client" +} diff --git a/.kokoro/presubmit/windows.cfg b/.kokoro/presubmit/windows.cfg index 53d85495b..1fd4552f6 100644 --- a/.kokoro/presubmit/windows.cfg +++ b/.kokoro/presubmit/windows.cfg @@ -1,3 +1,19 @@ # Format: //devtools/kokoro/config/proto/build.proto -build_file: "google-api-ruby-client/.kokoro/build.bat" \ No newline at end of file +build_file: "google-api-ruby-client/.kokoro/trampoline.bat" + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/yoshi-ruby/windows" +} + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/google-api-ruby-client/.kokoro/build.bat" +} + +env_vars: { + key: "REPO_DIR" + value: "google-api-ruby-client" +} diff --git a/.kokoro/trampoline.bat b/.kokoro/trampoline.bat new file mode 100644 index 000000000..1634b0710 --- /dev/null +++ b/.kokoro/trampoline.bat @@ -0,0 +1,10 @@ + +SET url="https://raw.githubusercontent.com/googleapis/google-cloud-ruby/master/.kokoro/trampoline.bat" + +SET "download=powershell -C Invoke-WebRequest -Uri %url% -OutFile master-trampoline.bat" + +SET EXIT_STATUS=1 + +%download% && master-trampoline.bat && SET EXIT_STATUS=0 + +EXIT %EXIT_STATUS% diff --git a/.kokoro/trampoline.sh b/.kokoro/trampoline.sh index 75fdbf984..4325866e0 100644 --- a/.kokoro/trampoline.sh +++ b/.kokoro/trampoline.sh @@ -1,24 +1,4 @@ #!/bin/bash -# Copyright 2017 Google Inc. -# -# 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 -# Always run the cleanup script, regardless of the success of bouncing into -# the container. -function cleanup() { - chmod +x ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh - ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh - echo "cleanup"; -} -trap cleanup EXIT -python3 "${KOKORO_GFILE_DIR}/trampoline_v1.py" \ No newline at end of file + +script_url="https://raw.githubusercontent.com/googleapis/google-cloud-ruby/master/.kokoro/trampoline.sh" +curl -o master-trampoline.sh $script_url && source master-trampoline.sh diff --git a/.kokoro/windows.sh b/.kokoro/windows.sh deleted file mode 100644 index 9dec41f5c..000000000 --- a/.kokoro/windows.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -# This file runs tests for merges, PRs, and nightlies. -# There are a few rules for what tests are run: -# * PRs run all non-acceptance tests for every library. -# * Merges run all non-acceptance tests for every library, and acceptance tests for all altered libraries. -# * Nightlies run all acceptance tests for every library. -# * Currently only runs tests on 2.5.1 - -set -eo pipefail - -# Debug: show build environment -env | grep KOKORO - -cd github/google-api-ruby-client/ - -# Print out Ruby version -ruby --version - -# Temporary workaround for a known bundler+docker issue: -# https://github.com/bundler/bundler/issues/6154 -export BUNDLE_GEMFILE= - -# Capture failures -EXIT_STATUS=0 # everything passed -function set_failed_status { - EXIT_STATUS=1 -} - -(bundle update && bundle exec rake) || set_failed_status - -exit $EXIT_STATUS \ No newline at end of file diff --git a/Rakefile b/Rakefile index dc9a4dcd2..bcb9ab422 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,34 @@ require "bundler/gem_tasks" task default: :spec + +namespace :kokoro do + task :load_env_vars do + service_account = "#{ENV['KOKORO_GFILE_DIR']}/service-account.json" + ENV["GOOGLE_APPLICATION_CREDENTIALS"] = service_account + filename = "#{ENV['KOKORO_GFILE_DIR']}/env_vars.json" + env_vars = JSON.parse File.read(filename) + env_vars.each { |k, v| ENV[k] = v } + end + + task :presubmit do + Rake::Task["spec"].invoke + end + + task :continuous do + Rake::Task["spec"].invoke + end + + task :nightly do + Rake::Task["spec"].invoke + end +end + +def header str, token = "#" + line_length = str.length + 8 + puts "" + puts token * line_length + puts "#{token * 3} #{str} #{token * 3}" + puts token * line_length + puts "" +end