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

Add test for old lockfile with new ruby version #6317

Conversation

flavorjones
Copy link
Contributor

Summary

We want to be able to bundle install on ruby-head starting from a Gemfile.lock that was generated on the latest stable release. This currently works, but has broken a few times over the past few years. This PR adds a test to prevent regressions to this workflow:

Given an existing application using native gems (e.g., nokogiri)
And a lockfile generated with a stable ruby version
When we run bundle install with ruby-head to test against that ruby version
Then bundler should fall back to the generic ruby platform gem

I couldn't find existing test coverage of this exact scenario. I see a few tests that are close, but use bundle update or bundle lock as the action, not bundle install, so I wanted to add a more explicit test.

Would the Bundler maintainers be willing to formally support this use case?

Note that this test has been passing since 45931ac / 4ff5419 (bundler 2.4.3).

(This PR is co-authored by @byroot.)

What was the end-user or developer problem that led to this PR?

For a couple years now, Shopify has been continuously testing our applications against ruby-head. This brings a lot of value to us as it allows to deal with breaking changes in advance, but more importantly we believe it brings a lot of value to the community. This practice allows us to report bugs quickly after they are introduced, which stabilizes the final release; it also gives us the opportunity to fix compatibility issues upstream in common gems way before the yearly Ruby release in December.

To achieve those goals, we need to test with the same gem versions, so regenerating the Gemfile.lock from scratch or running bundle update aren't quite the right solution.

Over the last few years our testing pipelines have been broken a few times in surprising ways because of improvements and changes to how Bundler handle platforms. We'd like to add a test for this workflow to ensure that it continues working, if the Bundler team is open to supporting it.

Most recently, this workflow was broken in Bundler 2.4.1 (possibly earlier? I didn't bisect), we saw this error message after a bundler install on ruby-head:

Because xxxx >= 0.1.23 (arm64-darwin, x86_64-darwin, x86_64-linux) depends
on Ruby >= 3.1, < 3.3.dev
  and Gemfile depends on xxxx ~> 0.1.23,
  Ruby >= 3.1, < 3.3.dev is required.
So, because current Ruby version is = 3.3.0.dev,

This was quickly fixed in Bundler 2.4.3 (thank you for that!), but the test added doesn't explicitly cover this use case (unless I'm misunderstanding).

Make sure the following tasks are checked

@deivid-rodriguez
Copy link
Member

Absolutely, if this kind of thing broke again, it'd be another regression, so whatever we can do to avoid my overlooks is welcome! 👍

As per the failures, I think you may want to wrap the whole test with a simulate_platform "x86_64-linux" do ... end block so that it passes regardless of CI platform.

@flavorjones
Copy link
Contributor Author

wrap the whole test

Will do!

Given an existing application using native gems (e.g., nokogiri)
And a lockfile generated with a stable ruby version
When we test the application against ruby-head and `bundle install`
Then bundler should fall back to the generic ruby platform gem

Note that this test has been passing since 45931ac
@flavorjones flavorjones force-pushed the flavorjones-add-test-for-ruby-head-scenario branch from 76893af to 0ecc6de Compare January 30, 2023 16:13
@deivid-rodriguez deivid-rodriguez merged commit b9b0210 into rubygems:master Jan 30, 2023
@deivid-rodriguez
Copy link
Member

Thanks @flavorjones and @byroot!

@flavorjones flavorjones deleted the flavorjones-add-test-for-ruby-head-scenario branch January 30, 2023 20:39
deivid-rodriguez added a commit that referenced this pull request Jan 31, 2023
…by-head-scenario

Add test for old lockfile with new ruby version

(cherry picked from commit b9b0210)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants