diff --git a/.toys/kokoro-ci.rb b/.toys/kokoro-ci.rb index 7659846b6..4aecaec19 100644 --- a/.toys/kokoro-ci.rb +++ b/.toys/kokoro-ci.rb @@ -133,7 +133,7 @@ def list_products # Currently, we include the rails tests for the run/rails tutorial. omit_list = ["run/rails/test"] @products = [] - (Dir.glob("*/Gemfile") + Dir.glob("*/*/Gemfile")).each do |gemfile| + Dir.glob("*/**/Gemfile").each do |gemfile| dir = File.dirname gemfile if (File.directory?("#{dir}/test") && !omit_list.include?("#{dir}/test")) || (File.directory?("#{dir}/spec") && !omit_list.include?("#{dir}/spec")) || @@ -208,7 +208,7 @@ def start_app_engine_services # Launch cloud sql proxy instances for cloud-sql tests # def start_cloud_sql_services - if @products.include? "cloud-sql/mysql" + if tests_product? "cloud-sql/mysql" puts "Starting Cloud SQL Proxy for MySQL", :bold connection_name = assert_env "MYSQL_INSTANCE_CONNECTION_NAME" process = exec ["/bin/cloud_sql_proxy", @@ -218,7 +218,7 @@ def start_cloud_sql_services ENV["MYSQL_CLOUD_SQL_PROXY_PROCESS_ID"] = process.pid.to_s @kill_on_cleanup << process end - if @products.include? "cloud-sql/postgres" + if tests_product? "cloud-sql/postgres" puts "Starting Cloud SQL Proxy for Postgres", :bold connection_name = assert_env "POSTGRES_INSTANCE_CONNECTION_NAME" process = exec ["/bin/cloud_sql_proxy", @@ -228,7 +228,7 @@ def start_cloud_sql_services ENV["POSTGRES_CLOUD_SQL_PROXY_PROCESS_ID"] = process.pid.to_s @kill_on_cleanup << process end - if @products.include? "cloud-sql/postgres" + if tests_product? "cloud-sql/sqlserver" puts "Starting Cloud SQL Proxy for SQL Server", :bold connection_name = assert_env "SQLSERVER_INSTANCE_CONNECTION_NAME" process = exec ["/bin/cloud_sql_proxy", @@ -369,6 +369,13 @@ def gac_path @gac_path ||= ENV["GOOGLE_APPLICATION_CREDENTIALS"] end +# Products are the sample directories themselves, but samples can also be +# nested underneath a product (for example cloud-sql/mysql/activerecord under +# cloud-sql/mysql), so match on the directory prefix rather than the exact name. +def tests_product? name + @products.any? { |dir| dir == name || dir.start_with?("#{name}/") } +end + def presubmit? unless defined? @is_presubmit @is_presubmit = (/system-tests/ =~ assert_env("KOKORO_BUILD_ARTIFACTS_SUBDIR")).nil?