Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Restrict certain gems on certain versions of ruby #2750

Closed
wants to merge 5 commits into from

Conversation

robotdana
Copy link
Contributor

As rspec gitignores its Gemfile.lock it can mean new prs can fail with unrelated changes because bundler will get the most recent versions of gems which might have new and exciting incompatibilities. (as i found with #2749)

Also because the travis agents cache these bundles and don't force an update it can sometimes just work

Simplecov has changed ruby version requirements for simplecov-html
apparently. We could define the version of simplecov-html to install
but there's no benefit to running coverage on every version so lets
just install simplecov on newer versions like we do for rubocop
@robotdana robotdana changed the title Travis Restrict certain gems on certain versions of ruby Aug 13, 2020
@robotdana robotdana force-pushed the travis branch 5 times, most recently from dd418f9 to c35b6eb Compare August 13, 2020 23:20
@robotdana
Copy link
Contributor Author

Alright I think this probably needs to be a maintainer from here

  1. i think there should have an automated travis build that runs without the cached bundler directory (IF ENV or something) forcing the latest resolved versions of all gems so that its easy to tell what version incompatibilities have showed up and new prs don't have to deal with trying to get travis to setup before seeing if their tests pass in all rubies
    (still use the cached bundler directory for builds other than this automated build).
  2. make sure all the repos pass this (with changes like i've done here).
  3. ???
  4. profit

@@ -16,6 +16,8 @@ if RUBY_VERSION < '1.9.3'
gem 'rake', '< 11.0.0' # rake 11 requires Ruby 1.9.3 or later
elsif RUBY_VERSION < '2.0.0'
gem 'rake', '< 12.0.0' # rake 12 requires Ruby 2.0.0 or later
elsif RUBY_VERSION < '2.2.0'
gem 'rake', '< 13.0.0' # rake 13 requires Ruby 2.2.0 or later
else
gem 'rake', '> 12.3.2'
Copy link
Member

Choose a reason for hiding this comment

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

This should change to > 13.0.0 in this sort of matrix

@JonRowe
Copy link
Member

JonRowe commented Aug 14, 2020

As rspec gitignores its Gemfile.lock it can mean new prs can fail with unrelated changes because bundler will get the most recent versions of gems which might have new and exciting incompatibilities.

Its considered best practise to do so by the way, it ensures that builds don't go stale locked to some outdated dependency while your users get fresh ones, in fact we have cron builds that check main every week to find these problems (I reran one earlier when you first opened your other PR which passed in fact)

@pirj
Copy link
Member

pirj commented Aug 14, 2020

Sorry, I'm a bit out of context. What problem exactly this change is addressing, @robotdana ? Were there build failures?
We have had a fair share of similar kind of fixes on rspec-rails side, and it turns out that Bundler should be resolving versions considering the Ruby version constraint, but in certain situations it doesn't. I'd rather apply the effort there.

@robotdana
Copy link
Contributor Author

robotdana commented Aug 14, 2020

What problem exactly this change is addressing, @robotdana ? Were there build failures?

yeah there were sometimes build failures depending on whether the bundler cache was there or not (if it was there, bundler happily used the working versions and had no issues. if it wasn't there, then bundler would fetch the newest versions, which did have ruby version incompatibilities)

e.g. this build: https://travis-ci.org/github/rspec/rspec-core/jobs/717498044

I've just done a bit of reading on bundler and required_ruby_version, and i'm so much more confused than i was before. it seems like it should work. it demonstrably doesn't, at least, not consistently

in fact we have cron builds that check main every week to find these problems (I reran one earlier when you first opened your other PR which passed in fact)

if you mean the this build https://travis-ci.org/github/rspec/rspec-core/jobs/717567773 its doesn't necessarily consider the latest versions bundler would resolve instead whatever versions were cached, only updating things that it needs to to match the Gemfile.

@JonRowe
Copy link
Member

JonRowe commented Aug 14, 2020

I've noticed an increase in flakey builds due to bundler issues of late, but they are typically resolved with a job restart as I've demonstrated, but if these changes increase the reliability of the build I guess I'm for them

@pirj
Copy link
Member

pirj commented Aug 14, 2020

if you mean the this build

More those two changes actually rspec/rspec-rails#2366 rspec/rspec-rails#2360

I understand now, this is to protect from the same flakiness. But I still don't understand the need for the cache removal.

@robotdana
Copy link
Contributor Author

the intent was to force bundler to not use whatever versions that it has cached that still satisfy the gemfile, and instead fetch the latest version of the gem that satisfies the gemfile

@robotdana
Copy link
Contributor Author

though if bundler address this: rubygems/rubygems#3594 the problem goes away

@JonRowe
Copy link
Member

JonRowe commented Aug 14, 2020

Thats a very interesting issue, that sounds plausible thats what we're hitting, as with Travis kicking off a large amounts of builds simultaneously the chances of that happening go up.

@pirj
Copy link
Member

pirj commented Aug 14, 2020

instead fetch the latest version of the gem that satisfies the gemfile

I wouldn't rely on that

though if bundler address this: rubygems/rubygems#3594 the problem goes away

There's evidence that it's not as simple as that. rspec/rspec-rails#2366 (comment)

@pirj
Copy link
Member

pirj commented Dec 23, 2020

We are relying on a more stable Bundler API right now. Also, RubyGems version support DB was retroactively updated.
This allowed us to drop all Ruby version-specific constraints from the Gemfile in upcoming 4.0 release.
Thanks!

@pirj pirj closed this Dec 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants