-
-
Notifications
You must be signed in to change notification settings - Fork 288
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
Fixup 'rubygems: latest' #551
Conversation
Added a second commit which skips |
JFYI... Puma separates MRI & non MRI CI. In MRI CI, we didn't use the rubygems input, as it really didn't work. We added a step to fix RubyGems/Bundler in older Rubies. Note that Puma CI tests Bundler functionality, as it's used when restarting/reloading Puma. I used this PR in Puma CI, and it works as expected. I removed the additional step needed for older Rubies. Head builds are left alone, and Rubies are upgraded with the proper version of RubyGems. We test Ruby 2.4 and later on all platforms. Happy Holidays, Greg |
Note that with the release of RubyGems 3.5.x (restricted to Ruby 3.x), in current master all Ruby versions 2.x fail when the rubygems input is set to latest. See https://github.com/MSP-Greg/setup-ruby/actions/runs/7330308381 |
Any thoughts on TruffleRuby and maybe JRuby? Handle like Ruby head builds? |
Indeed I noticed https://github.com/ruby/setup-ruby/actions/runs/7324250188/job/19947638571 thank you for the fix! |
TruffleRuby ignores |
@@ -28,3 +28,19 @@ export async function rubygemsUpdate(rubygemsVersionInput, rubyPrefix) { | |||
|
|||
return true | |||
} | |||
|
|||
async function rubygemsLatest(gem, platform, engine, version) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a link here to rubygems/rubygems#7329 or another appropriate issue explaining why we need to workaround this bug in RubyGems?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned, this has always been an issue, but since it's only tested here on Ruby 2.6, it failed because of the recently changed minimum Ruby version in RubyGems.
RubyGems 3.4 supported Ruby 2.6 and later, RubyGems 3.5 supports Ruby 3.0 and later.
yarn.lock
Outdated
version "2.1.1" | ||
resolved "https://registry.yarnpkg.com/@actions/http-client/-/http-client-2.1.1.tgz#a8e97699c315bed0ecaeaaeb640948470d4586a0" | ||
integrity sha512-qhrkRMB40bbbLo7gF+0vu+X+UawOvQQqNAA/5Unx774RS8poaOhThDOG6BGmxvAnxhQnDp2BG/ZUm65xZILTpw== | ||
version "2.2.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you undo all changes in yarn.lock?
They can cause failures, etc and updating usually makes it worse more than it helps from past experience.
In any case updating it should be done in its own commit&PR so easy to revert if any issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll split the yarn.lock changes.
rubygems.js
Outdated
|
||
async function rubygemsLatest(gem, platform, engine, version) { | ||
if (engine === 'ruby') { | ||
if (version >= '3.0') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comparing versions as strings feels brittle, could you use common.floatVersion() instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expecting a x.10
version? Regardless, I'll update.
rubygems.js
Outdated
console.log(`Cannot update RubyGems for Ruby version ${version}`) | ||
} | ||
} else { | ||
exec.exec(gem, ['update', '--system']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing await
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, that line is only for non MRI Ruby. Given our/my lack of knowledge of JRuby, remove it and log a message that RubyGems is not updated on non MRI platforms?
Nevermind, I'll fix it as you've listed above. So, same behavior as current with non MRI.
.github/workflows/test.yml
Outdated
fail-fast: false | ||
matrix: | ||
include: | ||
- { ruby: '3.2', rg_vers: '3.5.3' } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rg_vers -> rubygems_version/expected_version/expected_rubygems_version (abbreviations are an overhead on readability if not super well known ones)
.github/workflows/test.yml
Outdated
rubygems: latest | ||
- run: ruby -e "exit(Gem.rubygems_version > Gem::Version.new('3.0.3'))" | ||
- run: ruby -e "puts Gem::VERSION; exit(Gem.rubygems_version >= Gem::Version.new('${{ matrix.rg_vers }}'))" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you swap single and double quotes? It's safer to use single quotes outside for Ruby code (was already an issue before but since you're touching this line let's do it)
action.yml
Outdated
@@ -12,7 +12,7 @@ inputs: | |||
description: | | |||
The version of RubyGems to use. Either 'default' (the default), 'latest', or a version number (e.g., 3.3.5). | |||
For 'default', no action is taken and the version of RubyGems that comes with Ruby by default is used. | |||
For 'latest', `gem update --system` is run to update to the latest RubyGems version. | |||
For 'latest', `gem update --system` is run to update to the proper latest RubyGems version. Ruby head/master builds and Ruby 2.2 and earlier will not be updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep a sentence per line
action.yml
Outdated
@@ -12,7 +12,7 @@ inputs: | |||
description: | | |||
The version of RubyGems to use. Either 'default' (the default), 'latest', or a version number (e.g., 3.3.5). | |||
For 'default', no action is taken and the version of RubyGems that comes with Ruby by default is used. | |||
For 'latest', `gem update --system` is run to update to the latest RubyGems version. | |||
For 'latest', `gem update --system` is run to update to the proper latest RubyGems version. Ruby head/master builds and Ruby 2.2 and earlier will not be updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
proper latest RubyGems
-> latest compatible RubyGems
@MSP-Greg I'm curious, why do you update RubyGems in Puma's CI? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great but needs some polishing (see comments)
Honestly, I can't recall. I wrote the code and included a note with
Not a good phrase to use. Conversely, I guess I shouldn't write code when I'm also doing 'pre Christmas Eve dinner prep'... This issue has come up in the past, a few issues related. In one message you said:
I've advocated using newer Ruby versions, and also using head builds in CI, but I also understand testing against older versions. As you've stated, this is fixing 'old RubyGems bugs'. I believe current RubyGems/Bundler has fixed all the bugs (thanks to some hard work by very few people). Although this code may need the RubyGems versions updated from time to time (so it's a burden here), this fix will benefit others that maybe aren't as familiar with all the issues involved with older RubyGems, cross-platform CI and scripting, etc, etc. For others, it may cleanup their Actions workflow scripts... |
c5d9dd9
to
52bdd5b
Compare
52bdd5b
to
800bff9
Compare
@eregon I think I fixed/updated all items. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
No worries.
What's wrong with it? I didn't mean anything bad. Is "needs some cleanup" better?
Yeah in general I'm unhappy to have to workaround RubyGems/Bundler bugs, specifically I want to ensure such bugs are properly known upstream and fixed there, but I understand in cases such as this one (where we cannot fix RubyGems shipped with some old Ruby) it's warranted.
The fact this action supports Ruby 1.9 means we try to support as much as possible, but still stay reasonable and simple and e.g. not accumulate many fixes for old Rubies (e.g. if it doesn't compile anymore, we don't try to patch that Ruby, it's just not available). |
Here's an example from Sinatra CI, on Ruby 3.0 we use |
Fixes using 'rubygems; latest' for MRI Ruby 2.3 and later. I tried updating Ruby 2.2 and got errors for two different versions.
gem update --system
will not allow a bounded version, only an exact version. So, code is somewhat brittle if new patch releases are done for older RubyGems versions.Code works same as existing for non MRI Rubies.
One thing I wasn't sure about is whether Ruby master/head builds should not have anything done for 'rubygems; latest'. Sometime this year I think the RubyGems version was a pre-release, so latest would install an earlier version? Not.Sure.
Happy Holidays...