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 Ruby 3.1 support #1736

Merged
merged 4 commits into from
May 13, 2022
Merged

Add Ruby 3.1 support #1736

merged 4 commits into from
May 13, 2022

Conversation

ekohl
Copy link
Member

@ekohl ekohl commented May 3, 2022

In Ruby 3.1 using trim_mode must be passed as a keyword argument or a deprecation warning is shown. However, that is only possible on Ruby 2.7 or newer.

@codecov
Copy link

codecov bot commented May 3, 2022

Codecov Report

Merging #1736 (e23cbc8) into master (a17ac7d) will increase coverage by 0.01%.
The diff coverage is 87.50%.

❗ Current head e23cbc8 differs from pull request most recent head 35baf5f. Consider uploading reports for the commit 35baf5f to get more accurate results

@@            Coverage Diff             @@
##           master    #1736      +/-   ##
==========================================
+ Coverage   74.77%   74.78%   +0.01%     
==========================================
  Files          82       82              
  Lines        4853     4859       +6     
==========================================
+ Hits         3629     3634       +5     
- Misses       1224     1225       +1     
Impacted Files Coverage Δ
lib/beaker/options/hosts_file_parser.rb 97.61% <87.50%> (-2.39%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a17ac7d...35baf5f. Read the comment docs.

ekohl added 2 commits May 12, 2022 20:21
Ruby 2.7 changed behavior around passing in an options hash at the end.
This is a more explicit specification of what happens.
In Ruby 3.1 using trim_mode must be passed as a keyword argument or a
deprecation warning is shown. However, that is only possible on Ruby 2.7
or newer.
@@ -28,3 +28,5 @@ group :coverage, optional: ENV['COVERAGE']!='yes' do
gem 'simplecov-console', :require => false
gem 'codecov', :require => false
end

gem 'rdoc' if RUBY_VERSION >= '3.1'
Copy link
Member Author

Choose a reason for hiding this comment

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

#1737 will make this obsolete, but I first want to release a minor version that adds Ruby 3.1 support, then do a major one.

@ekohl ekohl changed the title Handle Ruby 3.1 ERB trim_mode deprecation Add Ruby 3.1 support May 12, 2022
@@ -1,5 +1,15 @@
require 'spec_helper'

def load_yaml_file(path)
permitted = [Beaker::Options::OptionsHash, Symbol, RSpec::Mocks::Double, Time]
Copy link
Member Author

Choose a reason for hiding this comment

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

The double is because the logger is being serialized for some reason. Looks like a bug to me, but I consider that out of scope.

@ekohl
Copy link
Member Author

ekohl commented May 12, 2022

Psych 4 is being a pain and I don't have Ruby 2.7 installed right now. Hence the multiple pushes.

ekohl added 2 commits May 12, 2022 21:19
Ruby 3.1 contains Psych 4 which defaults to safe loading. A small helper
is introduced to avoid repetition.
@ekohl
Copy link
Member Author

ekohl commented May 12, 2022

This now passes CI

else
ERB.new(template, nil, '-')
end
if RUBY_VERSION >= '2.6'
Copy link
Member Author

Choose a reason for hiding this comment

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

Ruby 2.4 and 2.5 (or rather, their Psych version) do not accept permitted_classes as an argument to safe_load

@bastelfreak bastelfreak merged commit d4cc3be into voxpupuli:master May 13, 2022
@ekohl ekohl deleted the ruby-3.1 branch March 2, 2023 13:01
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.

2 participants