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 and 3.2 support, drop ruby 2.6 #355

Merged
merged 7 commits into from Jun 2, 2023
Merged

Conversation

razumau
Copy link
Contributor

@razumau razumau commented May 10, 2023

Description

Adds Ruby 3.1 and 3.2 to the test matrix, drops Ruby 2.6, updates tests dependencies (to versions with support for recent Ruby versions).
This required a couple of changes:
— keyword arguments in i18n’s translate method (because of that, I’ve added a lower limit for i18n’s version in the gemspec—this release);
— Hash refinements are removed in recents i18n versions (ruby-i18n/i18n#573), so instead we use I18n::Utils.except in tests now;
— In newer URI versions, host for "https://" is an empty string, not nil, so we check for both.

I’ve also cleaned up tests workflow and added a tests_successful wrapper.

Before merging this PR

  • Fill out the Risks section
  • Think about performance and security issues

Risks

  • [RUNTIME] Can this change affect apps rendering for a user? No direct changes to rendering.
  • [HIGH | medium | low] What features does this touch? i18n dependency

@@ -434,7 +434,8 @@ def no_template_format_error(manifest)

def valid_url?(value)
uri = URI.parse(value)
uri.is_a?(URI::HTTP) && !uri.host.nil?
host_empty = uri.host.nil? || uri.host == ''
uri.is_a?(URI::HTTP) && !host_empty
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In newer URI versions, host for "https://" is an empty string, not nil.

@@ -18,7 +18,7 @@ def message

# if the error contains the word `_legacy` in the second sentence, let's
# only use the first one.
if [original, attempted].any? { |val| val =~ /_legacy/ }
if [original, attempted].any? { |val| val.is_a?(String) && val =~ /_legacy/ }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

=~ for non-strings has been removed from recent Ruby versions (and was deprecated—and often meaningless—before), so now we compare only strings to this regex.

@@ -300,7 +300,7 @@ def build_app_source_with_files(files)

it 'includes zh-cn in translations' do
expected_translations = JSON.parse(File.read('spec/translations/zh-cn.json'))
expect(package.send(:translations)['zh-cn'].except('custom1')).to eq(expected_translations)
expect(I18n::Utils.except(package.send(:translations)['zh-cn'], 'custom1')).to eq(expected_translations)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hash refinements are removed in recents i18n versions (ruby-i18n/i18n#573).

@@ -319,7 +319,7 @@ def build_app_source_with_files(files)

it 'removes zendesk-specific keys in translations' do
expected_translations = JSON.parse(File.read('spec/translations/zh-cn.json'))
expect(package.send(:translations)['zh-cn'].except('custom1')).to eq(expected_translations)
expect(I18n::Utils.except(package.send(:translations)['zh-cn'], 'custom1')).to eq(expected_translations)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hash refinements are removed in recents i18n versions (ruby-i18n/i18n#573).

@razumau razumau marked this pull request as ready for review May 16, 2023 11:52
@razumau razumau requested review from a team as code owners May 16, 2023 11:52
@razumau razumau requested a review from a team May 16, 2023 11:52
@@ -18,7 +18,7 @@ def message

# if the error contains the word `_legacy` in the second sentence, let's
# only use the first one.
if [original, attempted].any? { |val| val =~ /_legacy/ }
if [original, attempted].any? { |val| val.is_a?(String) && val =~ /_legacy/ }
Copy link
Member

Choose a reason for hiding this comment

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

Would the following work?

Suggested change
if [original, attempted].any? { |val| val.is_a?(String) && val =~ /_legacy/ }
if [original, attempted].any? { |val| /_legacy/.match?(val) }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No: val is sometimes (at least in tests) a Hash (of all things), so that also fails with TypeError: no implicit conversion of Hash into String.

s.license = 'Apache License Version 2.0'
s.authors = ['James A. Rosen', 'Likun Liu', 'Sean Caffery', 'Daniel Ribeiro']
s.email = ['dev@zendesk.com']
s.homepage = 'http://github.com/zendesk/zendesk_apps_support'
s.summary = 'Support to help you develop Zendesk Apps.'
s.description = s.summary

s.required_ruby_version = Gem::Requirement.new('>= 2.6', '< 3.1')
s.required_ruby_version = Gem::Requirement.new('>= 2.7')
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can drop v2.7 support given it's past EOL now.

@razumau razumau merged commit b936cca into master Jun 2, 2023
7 checks passed
@razumau razumau deleted the jury.razumau/ruby_31_32 branch June 2, 2023 08:46
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.

None yet

4 participants