-
-
Notifications
You must be signed in to change notification settings - Fork 910
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
Use Ruby 2.7 for development and CI #1310
Conversation
guialbuk
commented
Jun 22, 2020
- User Ruby 2.7 for gem development
- Add Ruby 2.7 to CI matrix
- Update other Ruby versions
- Use bundler 1.x for Ruby 2.4 and 2.5 to keep Rails 4.2 compatibility
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice! I just had one comment below.
Gemfile
Outdated
@@ -1,7 +1,7 @@ | |||
source 'https://rubygems.org' | |||
|
|||
gem 'appraisal', '2.2.0' | |||
gem 'bundler', '~> 1.1' | |||
gem 'bundler' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it still useful to keep Bundler 1.x for development. Every so often, I find that tests fail on Rails 4.2, so in order to debug this I will re-run the tests locally using the rails_4_2
appraisal. I feel like Bundler 2.x doesn't work with Rails 4.2 (or it may be Ruby 2.4/2.5, as you put in your comment above, I'm not sure). So I feel like we might need to keep this? What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @mcmire
Yeah, bundler 1.x is still needed for Rails 2.4 specs.
I removed the version restriction so the combination of Rails + Ruby can choose the most appropriate version.
Ruby 2.7 has no support for Bundler 1.x and Rails 4.2 requires bundler < 2
in its gemspec
:
https://github.com/rails/rails/blob/c0cb0cbf976a3cf8ad1b0e2d0f813602a712e997/rails.gemspec#L30
The solution was to only use Bundler 1.x for Ruby 2.4 and 2.5, supported by Rails 4.2:
Lines 32 to 42 in 6757e32
# Use Bundler 1.x for Ruby 2.4/2.5 and Rails 4.2 | |
- | | |
if ruby --version | grep -E "2.(4|5)." | |
then | |
gem update --system '2.7.8' --no-document | |
gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true | |
gem install bundler -v '< 2' --no-document | |
else | |
gem update --system --no-document | |
gem update bundler --no-document | |
fi |
After these CI improvements, I feel like removing support for Ruby 2.4 and Rails 4.2. This would the codebase simpler and easier to contribute to. Some shims and ActiveRecord matches, especially belongs_to
would benefit from that. But that's for a major release 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh ok. So maybe this one's okay. What about the one in rails_4_2.gemfile
, would you have to change that one then, at least?
Hey, so I took another look at this and I still don't think that using Bundler 2 in development is going to work. The reason for this is that part of the routine for setting up development (or updating dependencies in general, in fact) is to run |
@mcmire Thanks 👍 I'll do more tests in TravisCI with Ruby 2.7 + Bundler 1.x. |
@guialbuk I'm gonna try to see if I can figure this out today if that's alright with you! |
# Source: <https://docs.travis-ci.com/user/languages/ruby/#bundler-20> | ||
before_install: | ||
- gem update --system '2.7.8' --no-document | ||
- rm -f ~/.rvm/rubies/ruby-*/bin/bundle | ||
- gem update --system --force --no-document |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the version dependency on this because I was getting deadlock issues when using a version of RubyGems prior to 3.1.0.
cache: bundler | ||
cache: | ||
directories: | ||
- /home/travis/.rvm/gems/ruby-2.7.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caching was not working properly before. cache: bundler
assumes that the install
command is not being overridden — if that is the case then Bundler will use vendor/bundle
as the installation path. However, since we are overriding install
and we are not providing a --path
to bundle install
, Travis will install gems in a global location, which happens to be under /home/travis/.rvm/gems/ruby-<version>
. Here I'm listing out all of the possible cache paths because it will change depending on which Ruby version the build is running under.
@mcmire Thanks a lot for looking into that. You ended up with a simple and elegant solution. |
* Use Ruby 2.7 for gem development * Add Ruby 2.7 to CI matrix * Update other Ruby versions * Fix Bundler caching * Upgrade to newest version of RubyGems to prevent deadlock Co-authored-by: Elliot Winkler <[email protected]>
194a470
to
97b9701
Compare