2019-11-05 20:10:36 +00:00
|
|
|
require "json"
|
|
|
|
|
2019-04-12 00:28:00 +00:00
|
|
|
namespace :kokoro do
|
|
|
|
task :load_env_vars do
|
2020-12-22 23:10:52 +00:00
|
|
|
load_env_vars
|
2019-04-12 00:28:00 +00:00
|
|
|
end
|
|
|
|
|
2021-01-01 23:54:02 +00:00
|
|
|
task :dry_run do
|
|
|
|
ENV["DRY_RUN"] = "true"
|
|
|
|
end
|
|
|
|
|
2019-04-12 00:28:00 +00:00
|
|
|
task :presubmit do
|
2020-12-28 01:31:47 +00:00
|
|
|
Rake::Task["kokoro:run_tests"].invoke
|
2019-04-12 00:28:00 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
task :continuous do
|
2020-12-28 01:31:47 +00:00
|
|
|
Rake::Task["kokoro:run_tests"].invoke
|
2019-04-12 00:28:00 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
task :nightly do
|
2020-12-28 01:31:47 +00:00
|
|
|
Rake::Task["kokoro:run_tests"].invoke
|
2019-04-12 00:28:00 +00:00
|
|
|
end
|
2019-11-05 20:10:36 +00:00
|
|
|
|
|
|
|
task :post do
|
2019-11-07 02:46:59 +00:00
|
|
|
require_relative "rakelib/devsite/link_checker.rb"
|
2019-11-05 20:10:36 +00:00
|
|
|
|
|
|
|
link_checker = LinkChecker.new
|
|
|
|
link_checker.run
|
|
|
|
exit link_checker.exit_status
|
|
|
|
end
|
|
|
|
|
|
|
|
task :release do
|
2021-01-01 23:54:02 +00:00
|
|
|
require_relative "rakelib/releaser.rb"
|
|
|
|
|
|
|
|
load_env_vars if ENV["KOKORO_GFILE_DIR"]
|
|
|
|
package = ENV["PACKAGE"]
|
|
|
|
raise "PACKAGE missing" unless package
|
|
|
|
dry_run = ENV["DRY_RUN"]
|
|
|
|
|
|
|
|
if package == "ALL_GENERATED"
|
|
|
|
Dir.glob("generated/google-apis-*") do |gem_dir|
|
|
|
|
gem_name = File.basename(gem_dir)
|
|
|
|
releaser = Releaser.new(gem_name, gem_dir, dry_run: dry_run)
|
|
|
|
if releaser.needs_gem_publish?
|
|
|
|
releaser.publish_gem
|
|
|
|
releaser.publish_docs
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
releaser = Releaser.new(package, package, dry_run: dry_run)
|
|
|
|
releaser.publish_gem if releaser.needs_gem_publish?
|
|
|
|
releaser.publish_docs
|
|
|
|
end
|
2020-10-27 18:28:52 +00:00
|
|
|
end
|
|
|
|
|
2020-12-28 01:31:47 +00:00
|
|
|
task :run_tests do
|
2021-01-01 23:10:23 +00:00
|
|
|
gem_directories = ["google-apis-core", "google-apis-generator", "google-api-client"]
|
2020-12-31 22:55:59 +00:00
|
|
|
gem_directories.each do |dir|
|
|
|
|
next unless File.file?(File.join(dir, "Gemfile"))
|
|
|
|
cd dir do
|
2020-12-28 01:31:47 +00:00
|
|
|
Bundler.with_clean_env do
|
2020-12-31 22:55:59 +00:00
|
|
|
sh "bundle install"
|
2020-12-28 01:31:47 +00:00
|
|
|
sh "bundle exec rake spec"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-04-12 00:28:00 +00:00
|
|
|
end
|
|
|
|
|
2020-10-27 18:28:52 +00:00
|
|
|
def load_env_vars
|
|
|
|
service_account = "#{ENV['KOKORO_GFILE_DIR']}/service-account.json"
|
|
|
|
raise "#{service_account} is not a file" unless File.file? service_account
|
|
|
|
ENV["GOOGLE_APPLICATION_CREDENTIALS"] = service_account
|
|
|
|
filename = "#{ENV['KOKORO_GFILE_DIR']}/ruby_env_vars.json"
|
|
|
|
raise "#{filename} is not a file" unless File.file? filename
|
|
|
|
env_vars = JSON.parse File.read(filename)
|
|
|
|
env_vars.each { |k, v| ENV[k] ||= v }
|
|
|
|
end
|
|
|
|
|
2019-04-12 00:28:00 +00:00
|
|
|
def header str, token = "#"
|
|
|
|
line_length = str.length + 8
|
2019-11-05 20:10:36 +00:00
|
|
|
puts
|
2019-04-12 00:28:00 +00:00
|
|
|
puts token * line_length
|
|
|
|
puts "#{token * 3} #{str} #{token * 3}"
|
|
|
|
puts token * line_length
|
2019-11-05 20:10:36 +00:00
|
|
|
puts
|
2019-04-12 00:28:00 +00:00
|
|
|
end
|