diff --git a/.toys/kokoro-ci.rb b/.toys/kokoro-ci.rb index 7659846b6..73ca73502 100644 --- a/.toys/kokoro-ci.rb +++ b/.toys/kokoro-ci.rb @@ -148,17 +148,27 @@ def list_products # Filter out products whose tests will not run on the current Ruby version # def filter_by_ruby_versions + rails_cloudsql = [ + "appengine/rails-cloudsql-postgres", + "appengine/rails-cloudsql-mysql" + ] + unless newest_ruby? # Spanner tests are too slow. Run only on newest. @products.delete "spanner" # run/rails uses Rails 7 and requires newest Ruby. @products.delete "run/rails" + # Rails 7 cloud-sql samples require Ruby 3.2+, so run only on newest. + @products.delete_if { |dir| rails_cloudsql.include? dir } end if newest_ruby? # getting-started uses an old Rails and is incompatible with newest. @products.delete_if { |dir| dir.start_with? "getting-started/" } - # appengine tests are slow and some use an old Rails. Run only on oldest. - @products.delete_if { |dir| dir.start_with? "appengine/" } + # appengine tests are slow and some use an old Rails. Run only on oldest, + # except for rails-cloudsql which require newest Ruby because they use Rails 7. + @products.delete_if do |dir| + dir.start_with?("appengine/") && !rails_cloudsql.include?(dir) + end end end @@ -257,7 +267,7 @@ def install_gcloud_cli return if defined? @gcloud_cli_installed exec ["gcloud", "config", "set", "disable_prompts", "True"] exec ["gcloud", "config", "set", "project", assert_env("E2E_GOOGLE_CLOUD_PROJECT")] - exec ["gcloud", "config", "set", "app/promote_by_default", "false"] + exec ["gcloud", "config", "set", "app/promote_by_default", "false"] exec ["gcloud", "auth", "activate-service-account", "--key-file", gac_path] exec ["gcloud", "info"] @gcloud_cli_installed = true @@ -283,7 +293,7 @@ def test_globals # Run tests in the given directory. # def test_product dir - is_e2e = !presubmit? && newest_ruby? || dir.start_with?("run/") || dir.start_with?("appengine/") + is_e2e = (!presubmit? && newest_ruby?) || dir.start_with?("run/") || dir.start_with?("appengine/") ENV["E2E"] = is_e2e.to_s ENV["TEST_DIR"] = dir start_time = Time.now.to_i @@ -319,7 +329,7 @@ def test_rspec dir # def test_minitest dir test_exec "MINITEST:#{dir}" do - test_files = Dir.glob("test/**/*_test.rb") + test_files = Dir.glob "test/**/*_test.rb" args = ["-Itest", "-w"] args += ["-", "--junit", "--junit-filename=sponge_log.xml"] unless presubmit? exec_ruby args, in: :controller do |controller| @@ -339,7 +349,7 @@ def test_exec name, command = nil puts "**** RUNNING: #{name} ...", :cyan, :bold result = if command - exec(command) + exec command elsif block_given? yield end @@ -371,7 +381,8 @@ def gac_path def presubmit? unless defined? @is_presubmit - @is_presubmit = (/system-tests/ =~ assert_env("KOKORO_BUILD_ARTIFACTS_SUBDIR")).nil? + dir = assert_env "KOKORO_BUILD_ARTIFACTS_SUBDIR" + @is_presubmit = (/system-tests/ =~ dir).nil? end @is_presubmit end diff --git a/appengine/rails-cloudsql-mysql/Gemfile b/appengine/rails-cloudsql-mysql/Gemfile index a0586e4d2..7f69b9114 100644 --- a/appengine/rails-cloudsql-mysql/Gemfile +++ b/appengine/rails-cloudsql-mysql/Gemfile @@ -13,6 +13,7 @@ # limitations under the License. source "https://rubygems.org" +ruby ">= 3.2.0" git_source :github do |repo_name| repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include? "/" diff --git a/appengine/rails-cloudsql-mysql/app.yaml b/appengine/rails-cloudsql-mysql/app.yaml index 56879ad60..dee928f50 100644 --- a/appengine/rails-cloudsql-mysql/app.yaml +++ b/appengine/rails-cloudsql-mysql/app.yaml @@ -18,6 +18,8 @@ entrypoint: bundle exec rackup --port $PORT env: flex runtime: ruby +runtime_config: + operating_system: "ubuntu22" # [END step_1] env_variables: diff --git a/appengine/rails-cloudsql-postgres/Gemfile b/appengine/rails-cloudsql-postgres/Gemfile index 67abc5919..10f93103f 100644 --- a/appengine/rails-cloudsql-postgres/Gemfile +++ b/appengine/rails-cloudsql-postgres/Gemfile @@ -13,6 +13,7 @@ # limitations under the License. source "https://rubygems.org" +ruby ">= 3.2.0" git_source :github do |repo_name| repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include? "/" diff --git a/appengine/rails-cloudsql-postgres/app.yaml b/appengine/rails-cloudsql-postgres/app.yaml index 56879ad60..dee928f50 100644 --- a/appengine/rails-cloudsql-postgres/app.yaml +++ b/appengine/rails-cloudsql-postgres/app.yaml @@ -18,6 +18,8 @@ entrypoint: bundle exec rackup --port $PORT env: flex runtime: ruby +runtime_config: + operating_system: "ubuntu22" # [END step_1] env_variables: