Skip to content

Fix undefined Rails version for other repos sub-builds #2569

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 27, 2022
Merged
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
24 changes: 13 additions & 11 deletions Gemfile-rails-dependencies
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
version_file = File.expand_path("../.rails-version", __FILE__)

# This is required for Ruby 3.1, because in Ruby 3.1 these gems were moved to
# bundled gems from default gems. This issue was fixed in Rails Rails 7.0.1.
# Discussion can be found here - https://github.com/mikel/mail/pull/1439
def add_net_gems_dependency
if RUBY_VERSION >= '3.1'
gem 'net-smtp', require: false
gem 'net-imap', require: false
gem 'net-pop', require: false
end
end

case version = ENV['RAILS_VERSION'] || (File.exist?(version_file) && File.read(version_file).chomp) || ''
when /main/
gem "rails", :git => "https://github.com/rails/rails.git"
Expand All @@ -15,25 +26,16 @@ when /stable$/
gem rails_gem, :git => "https://github.com/rails/rails.git", :branch => version
end
when nil, false, ""
add_net_gems_dependency # TODO: remove when we use switch to "~> 7.0.0" that declares dependency on those gems on itself
gem "rails", "~> 6.0.0"
gem "puma"
gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
gem 'selenium-webdriver', require: false
else
add_net_gems_dependency if version.split(' ').last < '7.0'
gem "rails", version
gem "sprockets", '~> 3.0' if RUBY_VERSION < '2.5'
gem "puma"
gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
gem 'selenium-webdriver', require: false
end

# This is required for Ruby 3.1 and Rails 6.1.x as of time
# of writing, because in Ruby 3.1 these gems are no longer
# automatically included. This issue was fixed on the Rails
# side in Rails 7.0.1, but is not yet fixed in the Rails 6.1.x
# branch. Discussion can be found here - https://github.com/mikel/mail/pull/1439
if RUBY_VERSION >= '3.1' && version.split(' ').last < '7.0'
Copy link
Member

Choose a reason for hiding this comment

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

Maybe just do version = ... at the top and run the case statement of a local variable?

Copy link
Member Author

Choose a reason for hiding this comment

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

We skip this for:

  • pre 6.1 because it doesn't have Action Mailbox
  • 7.0.1+ because it does the same (presumably) itself

The only -stable build left is 5-2-stable that we'll drop.

In any case, this doesn't hurt on 3.1. And there's no other way to work around this for 6.1.

I don't really want to overcomplicate this.

Ideally, we could:

- version = ENV['RAILS_VERSION'] || (File.exist?(version_file) && File.read(version_file).chomp) || ''
+ version = ENV['RAILS_VERSION'] || (File.exist?(version_file) && File.read(version_file).chomp) || "~> 6.0.0"

and combine the last two branches.

This would allow to keep && version.split(' ').last < '7.0'.
Is it worth it?

Copy link
Member

Choose a reason for hiding this comment

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

Or we could return from the case statement a skip variable? Seems like skipping it on rails 7 is a good idea to ensure we don't change its behaviour?

gem 'net-smtp', require: false
gem 'net-imap', require: false
gem 'net-pop', require: false
end