Skip to content
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

Merged
merged 1 commit into from
Aug 24, 2020

Conversation

guialbuk
Copy link
Collaborator

  • 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

@guialbuk guialbuk requested a review from mcmire June 23, 2020 03:17
Copy link
Collaborator

@mcmire mcmire left a 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'
Copy link
Collaborator

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?

Copy link
Collaborator Author

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:

# 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 😄

Copy link
Collaborator

@mcmire mcmire Jun 23, 2020

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?

@mcmire
Copy link
Collaborator

mcmire commented Jul 9, 2020

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 bundle exec appraisal install. (I mistakenly took it out of the bin/setup script recently but I'm working on putting it back in.) Unfortunately, this won't work when using Bundler 2 because the rails_4_2 appraisal won't allow it. So we have to be on Bundler 1.x for that to work. And I don't know about Ruby 2.7 not supporting Bundler 1.x, because I just tried pulling down your branch here and switching to Bundler 1.x under Ruby 2.7 and that seems to have worked. Try doing gem install bundler:1.17.3 then running bundle exec appraisal install and you'll see what I mean.

@guialbuk
Copy link
Collaborator Author

@mcmire Thanks 👍 I'll do more tests in TravisCI with Ruby 2.7 + Bundler 1.x.
I got some failures there but I'll dig deeper to find a way to use Bundler 1.x for all versions in CI

@mcmire
Copy link
Collaborator

mcmire commented Aug 23, 2020

@guialbuk I'm gonna try to see if I can figure this out today if that's alright with you!

@mcmire
Copy link
Collaborator

mcmire commented Aug 23, 2020

@guialbuk I think I got something to work. Wanna take another look at this? If you're good with it, I'd like to merge it in so that we can merge in #1314.

# 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
Copy link
Collaborator

@mcmire mcmire Aug 23, 2020

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.

.travis.yml Outdated Show resolved Hide resolved
.travis.yml Outdated Show resolved Hide resolved
cache: bundler
cache:
directories:
- /home/travis/.rvm/gems/ruby-2.7.1
Copy link
Collaborator

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.

@guialbuk
Copy link
Collaborator Author

@mcmire Thanks a lot for looking into that. You ended up with a simple and elegant solution.
I'd approve the PR, but GitHub does not allow me as I created it 😄
Cheers!

* 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 <elliot.winkler@gmail.com>
@mcmire mcmire force-pushed the use-ruby-2.7-for-development-and-ci branch from 194a470 to 97b9701 Compare August 24, 2020 03:04
@mcmire mcmire merged commit 97b9701 into master Aug 24, 2020
@mcmire mcmire deleted the use-ruby-2.7-for-development-and-ci branch August 24, 2020 03:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants