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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
53 changes: 33 additions & 20 deletions .github/workflows/actions.yml
Expand Up @@ -8,33 +8,46 @@ on:
- main

jobs:
main:
name: ruby
tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby-version: [3.0.4, 2.7.5, 2.6.10]
ruby-version:
- '2.7'
- '3.0'
- '3.1'
- '3.2'
steps:
- uses: zendesk/checkout@v3
- uses: zendesk/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
- name: Vendor Cache
id: vendor-cache
uses: zendesk/cache@v3
bundler-cache: true
- name: test
run: bundle exec rake

linter:
runs-on: ubuntu-latest
steps:
- uses: zendesk/checkout@v3
- uses: zendesk/setup-ruby@v1
with:
path: vendor/cache
key: ${{ runner.os }}-vendor-ruby-${{ matrix.ruby-version }}-lock-${{ hashFiles('Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-vendor-ruby-${{ matrix.ruby-version }}-
${{ runner.os }}-vendor-
- name: before_script
run: |
bundle config set --local path 'vendor/cache'
bundle install --jobs=3 --retry=3
- name: build
run: |
bundle exec rake
bundler-cache: true
- name: lint
run: |
bundle exec rubocop
run: bundle exec rubocop

tests_successful:
name: Tests passing?
needs: tests
if: always()
runs-on: ubuntu-latest
steps:
- run: |
if ${{ needs.tests.result == 'success' }}
then
echo "All tests pass"
else
echo "Some tests failed"
false
fi
2 changes: 1 addition & 1 deletion .ruby-version
@@ -1 +1 @@
2.6.10
2.7.8
46 changes: 23 additions & 23 deletions Gemfile.lock
@@ -1,9 +1,9 @@
PATH
remote: .
specs:
zendesk_apps_support (4.38.3)
zendesk_apps_support (4.39.0)
erubis
i18n
i18n (>= 1.7.1)
image_size (~> 2.0.2)
ipaddress_2 (~> 0.13.0)
json
Expand All @@ -20,14 +20,14 @@ GEM
ast (2.4.2)
bump (0.5.4)
byebug (9.0.6)
concurrent-ruby (1.1.8)
concurrent-ruby (1.2.2)
crass (1.0.6)
diff-lcs (1.4.4)
diff-lcs (1.5.0)
erubis (2.7.0)
faker (1.6.6)
i18n (~> 0.5)
faker (3.2.0)
i18n (>= 1.8.11, < 2)
ffi (1.15.5)
i18n (0.9.5)
i18n (1.13.0)
concurrent-ruby (~> 1.0)
image_size (2.0.2)
ipaddress_2 (0.13.0)
Expand All @@ -36,8 +36,8 @@ GEM
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
marcel (1.0.2)
mini_portile2 (2.8.1)
nokogiri (1.13.10)
mini_portile2 (2.8.2)
nokogiri (1.14.3)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
parallel (1.12.1)
Expand All @@ -51,19 +51,19 @@ GEM
ffi (>= 0.5.0, < 2)
regexp_parser (2.1.1)
rexml (3.2.5)
rspec (3.4.0)
rspec-core (~> 3.4.0)
rspec-expectations (~> 3.4.0)
rspec-mocks (~> 3.4.0)
rspec-core (3.4.4)
rspec-support (~> 3.4.0)
rspec-expectations (3.4.0)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.12.0)
rspec-core (3.12.2)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.4.0)
rspec-mocks (3.4.1)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.4.0)
rspec-support (3.4.1)
rspec-support (~> 3.12.0)
rspec-support (3.12.0)
rubocop (1.20.0)
parallel (~> 1.10)
parser (>= 3.0.0.0)
Expand Down Expand Up @@ -92,12 +92,12 @@ DEPENDENCIES
bump (~> 0.5.1)
bundler (~> 2.2)
byebug (~> 9.0.6)
faker (~> 1.6.6)
faker
parallel (= 1.12.1)
rake
rspec (~> 3.4.0)
rspec
rubocop
zendesk_apps_support!

BUNDLED WITH
2.3.26
2.4.12
4 changes: 2 additions & 2 deletions lib/zendesk_apps_support/i18n.rb
Expand Up @@ -3,8 +3,8 @@
module ZendeskAppsSupport
module I18n
class << self
def t(key, *args)
i18n.t(key, *args)
def t(key, **args)
i18n.t(key, **args)
end

def set_load_path
Expand Down
2 changes: 1 addition & 1 deletion lib/zendesk_apps_support/manifest/no_override_hash.rb
Expand Up @@ -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.

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.

return translated_error
end
translated_detail_key = 'txt.apps.admin.error.app_build.duplicate_reference_values'
Expand Down
3 changes: 2 additions & 1 deletion lib/zendesk_apps_support/validations/manifest.rb
Expand Up @@ -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.

rescue URI::InvalidURIError
false
end
Expand Down
2 changes: 1 addition & 1 deletion lib/zendesk_apps_support/validations/validation_error.rb
Expand Up @@ -50,7 +50,7 @@ def initialize(key, data = nil)
end

def to_s
ZendeskAppsSupport::I18n.t("#{KEY_PREFIX}#{key}", data)
ZendeskAppsSupport::I18n.t("#{KEY_PREFIX}#{key}", **data)
end

def to_json(*)
Expand Down
4 changes: 2 additions & 2 deletions spec/package_spec.rb
Expand Up @@ -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).

end

it 'merges missing keys with the default locale' do
Expand All @@ -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).

end

it 'merges missing keys with the default locale' do
Expand Down
2 changes: 1 addition & 1 deletion spec/validations/validation_serialization_spec.rb
Expand Up @@ -65,7 +65,7 @@

describe '.from_json' do
it 'decodes a JSON hash and passes it to .from_hash' do
expect(ValidationError).to receive(:from_hash).with('foo' => 'bar')
expect(ValidationError).to receive(:from_hash).with({ 'foo' => 'bar' })
ValidationError.from_json(JSON.generate('foo' => 'bar'))
end

Expand Down
10 changes: 5 additions & 5 deletions zendesk_apps_support.gemspec
Expand Up @@ -2,18 +2,18 @@

Gem::Specification.new do |s|
s.name = 'zendesk_apps_support'
s.version = '4.38.3'
s.version = '4.39.0'
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.

s.required_rubygems_version = '>= 1.3.6'

s.add_runtime_dependency 'i18n'
s.add_runtime_dependency 'i18n', '>= 1.7.1'
s.add_runtime_dependency 'sassc'
s.add_runtime_dependency 'sass' # remove explicit dependency when all compilation uses SassC
s.add_runtime_dependency 'json'
Expand All @@ -24,9 +24,9 @@ Gem::Specification.new do |s|
s.add_runtime_dependency 'rb-inotify', '0.9.10'
s.add_runtime_dependency 'marcel'
s.add_runtime_dependency 'ipaddress_2', '~> 0.13.0'
s.add_development_dependency 'rspec', '~> 3.4.0'
s.add_development_dependency 'rspec'
s.add_development_dependency 'bump', '~> 0.5.1'
s.add_development_dependency 'faker', '~> 1.6.6'
s.add_development_dependency 'faker'
s.add_development_dependency 'rubocop'
s.add_development_dependency 'byebug', '~> 9.0.6'
s.add_development_dependency 'bundler', '~> 2.2'
Expand Down