Skip to content
Closed
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
12 changes: 10 additions & 2 deletions .toys/kokoro-ci.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +165 to +169

Choose a reason for hiding this comment

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

medium

This logic can be improved for readability and maintainability. The directory names are repeated from earlier in the file (lines 157-158) and the chained != checks are less clear than using Array#include?.

Consider defining the list of cloudsql directories as a constant or local variable at a higher scope, for example:

CLOUDSQL_DIRS = %w[
  appengine/rails-cloudsql-postgres
  appengine/rails-cloudsql-mysql
].freeze

Then you could use it to simplify the logic in both places. Here, it would look like this:

@products.delete_if do |dir|
  dir.start_with?("appengine/") && !CLOUDSQL_DIRS.include?(dir)
end

And on lines 157-158, the deletion could be simplified to:

CLOUDSQL_DIRS.each { |dir| @products.delete dir }

This would make the code DRY and easier to update.

end
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
Loading