Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions .toys/kokoro-ci.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +169 to +171

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This condition can be simplified by checking for inclusion in an array of the rails-cloudsql samples. This improves readability and makes it easier to add more exceptions in the future. A similar list of samples is used on lines 157-158; using an array here could be the first step toward removing that duplication by defining the array once and using it in both places.

    @products.delete_if do |dir|
      dir.start_with?("appengine/") &&
        !["appengine/rails-cloudsql-postgres",
          "appengine/rails-cloudsql-mysql"].include?(dir)
    end

end
end

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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|
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions appengine/rails-cloudsql-mysql/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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? "/"
Expand Down
2 changes: 2 additions & 0 deletions appengine/rails-cloudsql-mysql/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
entrypoint: bundle exec rackup --port $PORT
env: flex
runtime: ruby
runtime_config:
operating_system: "ubuntu22"
# [END step_1]

env_variables:
Expand Down
1 change: 1 addition & 0 deletions appengine/rails-cloudsql-postgres/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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? "/"
Expand Down
2 changes: 2 additions & 0 deletions appengine/rails-cloudsql-postgres/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
entrypoint: bundle exec rackup --port $PORT
env: flex
runtime: ruby
runtime_config:
operating_system: "ubuntu22"
# [END step_1]

env_variables:
Expand Down