Skip to content

Bump bundler from 2.3.8 to 2.3.9 and automate it#4884

Merged
landongrindheim merged 1 commit intomainfrom
jurre/bunder-2.3.9
Mar 31, 2022
Merged

Bump bundler from 2.3.8 to 2.3.9 and automate it#4884
landongrindheim merged 1 commit intomainfrom
jurre/bunder-2.3.9

Conversation

@jurre
Copy link
Copy Markdown
Member

@jurre jurre commented Mar 21, 2022

This bumps the bundler version to the latest release, and adds a quick
'n dirty script to do it for us going forward.

This solution isn't ideal as places where we reference the version might
change, but I think it's an improvement over manually going through the
files. Also, if we happen to reference the same value as the bundler version
to mean something else in the same file, it'll get updated.

@jurre jurre requested a review from a team as a code owner March 21, 2022 09:42
Copy link
Copy Markdown
Contributor

@deivid-rodriguez deivid-rodriguez left a comment

Choose a reason for hiding this comment

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

Looks good, and unlikely to have false positives I believe. I think it's only missing updates in bundler/script/ci-test.

I left a couple of comments with suggestions on how to reduce the number of places that need updates in the future, just something to consider in future improvements.

module Helpers
V1 = "1.17.3"
V2 = "2.3.8"
V2 = "2.3.9"
Copy link
Copy Markdown
Contributor

@deivid-rodriguez deivid-rodriguez Mar 21, 2022

Choose a reason for hiding this comment

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

The Bundler version selection behavior implemented in this file should be the default as long as there's single v1 and v2 versions installed in the running environment. If that's the case I think it should be possible to completely remove this logic (don't pass BUNDLER_VERSION at all to native helpers) and let RubyGems do the right thing. But it seems something to consider for the future, definitely not for this PR.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Aye, yeah we should definitely try that and see if it doesn't break anything!


let(:v1) { "1.17.3" }
let(:v2) { "2.3.8" }
let(:v2) { "2.3.9" }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this spec could be relaxed to not hardcode exact versions, but instead just check the major version selected.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm not sure, right now I think the exact version is relevant, if we do this then we can maybe relax it?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These specs are unit tests for the Bundler::Helpers.bundler_version method, which selects an exact bundler version according to the lockfile contents, using the following criteria:

  • No lockfile -> The exact v2 version dependabot has available.
  • Lockfile with no BUNDLED WITH section -> The exact v2 version dependabot has available.
  • Lockfile with BUNDLED WITH 1.x section -> The exact v1 version dependabot has available.
  • Lockfie with BUNDLED WITH 2.x section or higher -> The exact v2 version dependabot has available.

Namely, a unit test for this method

def self.bundler_version(lockfile)
return DEFAULT unless lockfile
if (matches = lockfile.content.match(BUNDLER_MAJOR_VERSION_REGEX))
matches[:version].to_i >= 2 ? V2 : V1
else
FAILOVER
end
end

In my opinion, testing that the result is a valid 3 component version number, and that the first segment is correct (1.x or 2.x) is enough. The exact version itself that dependabot is using is "configuration" and should not need a test, because it's not useful for detecting bugs and it means essentially testing the specific value of a constant, which defeats one of the points of using constants (keep things DRY).

Copy link
Copy Markdown
Contributor

@deivid-rodriguez deivid-rodriguez Mar 22, 2022

Choose a reason for hiding this comment

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

That said that just my personal opinion but it's no big deal, and indeed if #4884 (comment) works, all this code will go away, so these tests will go too anways.

@jurre jurre force-pushed the jurre/bunder-2.3.9 branch 2 times, most recently from b43df56 to c2f041a Compare March 21, 2022 20:24
@deivid-rodriguez
Copy link
Copy Markdown
Contributor

Looks good to me!

This bumps the bundler version to the latest release, and adds a quick
'n dirty script to do it for us going forward.

This solution isn't ideal as places where we reference the version might
change, but I think it's an improvement over manually going through the
files.
@jurre jurre force-pushed the jurre/bunder-2.3.9 branch from c2f041a to 575147c Compare March 29, 2022 15:52
Copy link
Copy Markdown
Contributor

@landongrindheim landongrindheim left a comment

Choose a reason for hiding this comment

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

Thanks for checking in the automation! Looks good to me 🚀

Outside the scope of this change: Do you think we could define the Bundler version in one place as a constant and reference it throughout? I'm thinking we could have Dependabot keep it up-to-date 😄

@jurre
Copy link
Copy Markdown
Member Author

jurre commented Mar 30, 2022

Thanks for checking in the automation! Looks good to me 🚀

Outside the scope of this change: Do you think we could define the Bundler version in one place as a constant and reference it throughout? I'm thinking we could have Dependabot keep it up-to-date 😄

I think it would be tricky, because we reference it in the Dockerfile, in Ruby source and bash scripts, the only things I can think of are real hacks 🤔

@landongrindheim
Copy link
Copy Markdown
Contributor

landongrindheim commented Mar 31, 2022

Thanks for checking in the automation! Looks good to me 🚀
Outside the scope of this change: Do you think we could define the Bundler version in one place as a constant and reference it throughout? I'm thinking we could have Dependabot keep it up-to-date 😄

I think it would be tricky, because we reference it in the Dockerfile, in Ruby source and bash scripts, the only things I can think of are real hacks 🤔

Same here. If I think of something I'll raise it with you 😄

@landongrindheim landongrindheim merged commit 0f106ad into main Mar 31, 2022
@landongrindheim landongrindheim deleted the jurre/bunder-2.3.9 branch March 31, 2022 08:57
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.

3 participants