Ensure the release CI doesn't break due to the Bundler checksum feature#9436
Open
Edouard-chin wants to merge 4 commits intoruby:masterfrom
Open
Ensure the release CI doesn't break due to the Bundler checksum feature#9436Edouard-chin wants to merge 4 commits intoruby:masterfrom
Edouard-chin wants to merge 4 commits intoruby:masterfrom
Conversation
- ### Problem This change is purely to fix a problem when developing Bundler. When we tried to release Bundler 4.0.9, we bumped the VERSION from `4.1.0.dev` to `4.0.9`, this condition now evaluates to false https://github.com/ruby/rubygems/blob/34d19fa8a3f84c50e2ba65e0f39c80045e7cbfb8/bundler/lib/bundler/lockfile_generator.rb#L106. We then ended up with a CI crash. ``` Errno::ENOENT: No such file or directory @ rb_sysopen - /Users/runner/work/rubygems/rubygems/cache/bundler-4.0.9.gem ``` ### Context Computing a checksum for the `bundler` gem is only possible when the `bundler.gem` binary exists on disk. When a regular user interacts with `bundler`, the spec is loaded from disk and an associated cached `bundler.gem` should exists. However, when developing Bundler, the spec doesn't come from disk but from a fake spec https://github.com/ruby/rubygems/blob/34d19fa8a3f84c50e2ba65e0f39c80045e7cbfb8/bundler/lib/bundler/source/metadata.rb#L22-L28 that with no associated `bundler.gem`. ### Solution To prevent CI from breaking whenever we make a release, we have to skip computing a checksum if no `bundler.gem` exists.
- ### Problem Whenever we bump the bundler `VERSION` to a non development release, like we recently did in [4.0.9](ruby#9426) The test suite will behave differently and will break due to the Bundler checksum feature introduced in ruby#9366 This is because the expectactions of tests that have a lockfile' will sometimes include a checksum line for the bundler gem itself depending on whether this condition evaluates to `true`. https://github.com/ruby/rubygems/blob/34d19fa8a3f84c50e2ba65e0f39c80045e7cbfb8/bundler/lib/bundler/lockfile_generator.rb#L106 ### Solution We can modify the spec helper `checksums_section_when_enabled` to automatically append a checksum entry for bundler whenever necesary.
- ### Problem When we make a new bundler release, CI lint will break due to those two steps. https://github.com/ruby/rubygems/blob/34d19fa8a3f84c50e2ba65e0f39c80045e7cbfb8/.github/workflows/ubuntu-lint.yml#L107-L110 It's a bit tricky to explain without being too verbose, but in summary, one check will tell you to update the lockfile to include bundler checksum, and once you do and repush, the other check will tell you that you have added bundler checksum and you shouldn't have. ### Context When the "Misc check" step runs, it executes `rake version:check`, to ensure that the BUNDLED_WITH section of development lockfile (such as test_gems.rb.lock) gets modified. It does so by literally packaging `bundler.gem` and install it, then run `bundle update --bundler`. In this scenario, due to the self-manager feature, we are not using the "bundler development" binstub but will be using the "real" bundler that we just packaged https://github.com/ruby/rubygems/blob/34d19fa8a3f84c50e2ba65e0f39c80045e7cbfb8/bundler/lib/bundler/self_manager.rb#L33 This has for consequence that the lockfile will include bundler checksum, and tell you to update them and repush. Once you re-push with the lockfile updated, the other CI check `rake dev:frozen_deps` that **uses** bundler development binstub will not include a checksum entry for bundler and will tell you to remove it from the lockfile... ### Solution I want to prevent `rake version:check` from using the packaged bundler and use the binstub so that no checksum get added to development lockfile. We can do so with the `bundle lock` command instead, which won't autoswitch bundler.
- ### Problem This test breaks whenever checksums are computed. It didn't break before because the gemfile in this test doesn't include any gems (only git gems) and therefore checksum is skipped. ### Context This test was added in c19a9f2 to ensure Bundler will not load "digest". I don't think this test really works as it will break as soon as you had a regular gem in the gemfile test. https://github.com/ruby/rubygems/blob/34d19fa8a3f84c50e2ba65e0f39c80045e7cbfb8/spec/runtime/setup_spec.rb#L1354-L1355 I'm being unlucky and it now fails because we compute a checksum for the "bundler" gem itself. Computing a checksum requires "rubygems/package", and down the line requires "digest". ### Solution For the sake of shipping this PR, I'm going to go workaround the problem and skip checksum so that "digest" is not loaded.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was the end-user or developer problem that led to this PR?
Whenever we modify the Bundler VERSION to create a release, CI will break.
This change is purely to fix a problem when developing Bundler. When we tried to release Bundler 4.0.9, we bumped the VERSION from
4.1.0.devto4.0.9, this condition now evaluates to false/rubygems/bundler/lib/bundler/lockfile_generator.rb
Line 106 in 34d19fa
We then ended up with a CI crash.
What is your fix for the problem, implemented in this PR?
I explained changes one by one in the commit message as it's easier to understand with the associated code.
To make sure that this works on a release CI, I pushed a version bump and ran a CI at https://github.com/Shopify/rubygems/actions/runs/23593699080
Make sure the following tasks are checked