THRIFT-5906: Remove Fixnum references to support modern Ruby versions
Fixnum type has been deprecated since Ruby 2.4 and removed in Ruby 3.0, which makes BaseProtocol incompatible with modern Ruby versions.
This change removes the Fixnum reference, as well as a monkey-patch that introduces Fixnum#ord() to Ruby versions below 1.8.7.
[!IMPORTANT] This change essentially makes it officially required to use Ruby 2.4 or newer.
Currently, LANGUAGES.md mentions Ruby 2.3.1 as the minimum version, which had an EOL in March 2019. With a series of changes, I am trying to revive the continuous integration pipeline for Ruby, and have currently the test suite pass for up to 3.4.7. I propose to bump the minimum required Ruby version to 2.4.0, and update the "tested up to" version to 3.4.7 once the pipeline is completely green and running on GitHub.
Fixes the following test failures:
1) BaseProtocol Thrift::BaseProtocol should write out the different types (deprecated write_type signature)
Failure/Error: if field_info.is_a? Fixnum
NameError:
uninitialized constant Thrift::BaseProtocol::Fixnum
# ./lib/thrift/protocol/base_protocol.rb:256:in 'Thrift::BaseProtocol#write_type'
# ./spec/base_protocol_spec.rb:65:in 'block (3 levels) in <top (required)>'
2) BaseProtocol Thrift::BaseProtocol should write out the different types
Failure/Error: if field_info.is_a? Fixnum
NameError:
uninitialized constant Thrift::BaseProtocol::Fixnum
# ./lib/thrift/protocol/base_protocol.rb:256:in 'Thrift::BaseProtocol#write_type'
# ./spec/base_protocol_spec.rb:90:in 'block (3 levels) in <top (required)>'
3) BaseProtocol Thrift::BaseProtocol should read the different types (deprecated read_type signature)
Failure/Error: if field_info.is_a? Fixnum
NameError:
uninitialized constant Thrift::BaseProtocol::Fixnum
# ./lib/thrift/protocol/base_protocol.rb:296:in 'Thrift::BaseProtocol#read_type'
# ./spec/base_protocol_spec.rb:113:in 'block (3 levels) in <top (required)>'
4) BaseProtocol Thrift::BaseProtocol should read the different types
Failure/Error: if field_info.is_a? Fixnum
NameError:
uninitialized constant Thrift::BaseProtocol::Fixnum
# ./lib/thrift/protocol/base_protocol.rb:296:in 'Thrift::BaseProtocol#read_type'
# ./spec/base_protocol_spec.rb:136:in 'block (3 levels) in <top (required)>'
- [x] Did you create an Apache Jira ticket? THRIFT-5906
- [x] If a ticket exists: Does your pull request title follow the pattern "THRIFT-NNNN: describe my issue"?
- [x] Did you squash your changes to a single commit? (not required, but preferred)
- [x] Did you do your best to avoid breaking changes? If one was needed, did you label the Jira ticket with "Breaking-Change"?
- [ ] If your change does not involve any code, include
[skip ci]anywhere in the commit message to free up build resources.
@Jens-G I am working through the failing tests to get the Ruby build pipeline up and running on the GitHub workflows. One question is which Ruby versions to support.
In this MR I propose to bump the minimum version from 2.3 to 2.4 (as per LANGUAGES.md), but the number of support versions will affect the size of the test pipeline.
Currently supported versions are 3.2 and above https://endoflife.date/ruby, which might be too aggressive, maybe? I'm thinking about 2.7 and up (https://github.com/kpumuk/thrift/actions/runs/19521001691), but can of course lower it.
I am not quite sure why appveyor tests are failing and how to fix them. Does not seem to be related to the change
I am not quite sure why appveyor tests are failing and how to fix them. Does not seem to be related to the change
The tests are fixed now, and this PR is ready for review.
As per the discussion in the mailing list, we should be good with bumping minimum required version a little bit, as 2.4 it is still well below the currently supported Ruby versions.