From 95457b8208efc63edfd077922696fe2b3bb1da53 Mon Sep 17 00:00:00 2001 From: Riccardo Carlesso Date: Thu, 19 Mar 2026 09:29:03 +0100 Subject: [PATCH 1/2] fix(appengine): modernize rails-cloudsql gae flex ruby examples --- .toys/kokoro-ci.rb | 12 ++++++++++-- appengine/rails-cloudsql-mysql/Gemfile | 1 + appengine/rails-cloudsql-mysql/app.yaml | 2 ++ appengine/rails-cloudsql-postgres/Gemfile | 1 + appengine/rails-cloudsql-postgres/app.yaml | 2 ++ 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.toys/kokoro-ci.rb b/.toys/kokoro-ci.rb index 7659846b6..ebe1a51f2 100644 --- a/.toys/kokoro-ci.rb +++ b/.toys/kokoro-ci.rb @@ -153,12 +153,20 @@ def filter_by_ruby_versions @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 "appengine/rails-cloudsql-postgres" + @products.delete "appengine/rails-cloudsql-mysql" 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/") && + dir != "appengine/rails-cloudsql-postgres" && + dir != "appengine/rails-cloudsql-mysql" + end end 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: From 04dde9c2ff174febd9b9de061381741c032061c3 Mon Sep 17 00:00:00 2001 From: Riccardo Carlesso Date: Thu, 19 Mar 2026 10:29:00 +0100 Subject: [PATCH 2/2] fix(kokoro): resolve rubocop lint errors and gemini code assist simplification --- .toys/kokoro-ci.rb | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/.toys/kokoro-ci.rb b/.toys/kokoro-ci.rb index ebe1a51f2..73ca73502 100644 --- a/.toys/kokoro-ci.rb +++ b/.toys/kokoro-ci.rb @@ -148,14 +148,18 @@ 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 "appengine/rails-cloudsql-postgres" - @products.delete "appengine/rails-cloudsql-mysql" + @products.delete_if { |dir| rails_cloudsql.include? dir } end if newest_ruby? # getting-started uses an old Rails and is incompatible with newest. @@ -163,9 +167,7 @@ def filter_by_ruby_versions # 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/") && - dir != "appengine/rails-cloudsql-postgres" && - dir != "appengine/rails-cloudsql-mysql" + dir.start_with?("appengine/") && !rails_cloudsql.include?(dir) end end end @@ -265,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 @@ -291,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 @@ -327,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| @@ -347,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 @@ -379,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