From 8cf6db58eed23d3589b737c818b8dbafcb58bc91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Lilleb=C3=B8?= Date: Tue, 2 Feb 2021 22:24:16 +0900 Subject: [PATCH 1/5] Use `net-http-persistent` version compatible with Ruby 3 Version 4.0.0 of `net-http-persistent` is incompatible with Ruby 3.0. This was fixed in version 4.0.1. --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index a58a9e250..bb0d18fbb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,7 +45,7 @@ GEM codeclimate-test-reporter (1.0.7) simplecov concurrent-ruby (1.1.7) - connection_pool (2.2.2) + connection_pool (2.2.3) crass (1.0.6) database_cleaner (1.7.0) diff-lcs (1.3) @@ -75,7 +75,7 @@ GEM msgpack (1.3.1) multi_json (1.15.0) mysql2 (0.5.2) - net-http-persistent (4.0.0) + net-http-persistent (4.0.1) connection_pool (~> 2.2) net-http2 (0.18.3) http-2 (~> 0.10.1) @@ -171,4 +171,4 @@ DEPENDENCIES timecop BUNDLED WITH - 2.1.4 + 2.2.3 From bd4c432c0f080f628643ec1dd39de7a6a61c695d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Lilleb=C3=B8?= Date: Tue, 2 Feb 2021 22:30:04 +0900 Subject: [PATCH 2/5] Fix hash being passed as keyword argument In Ruby 2.7, a Hash can automatically be converted to a keyword argument. In Ruby 3.0 however, attempting to do so will raise an ArgumentError. See the following link for more details: https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/ --- lib/generators/templates/add_gcm.rb | 8 ++++---- lib/generators/templates/add_rpush.rb | 8 ++++---- lib/generators/templates/rpush_3_3_1_updates.rb | 4 ++-- spec/unit/daemon/pushy/delivery_spec.rb | 8 +++++--- spec/unit/daemon/webpush/delivery_spec.rb | 8 +++++--- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/lib/generators/templates/add_gcm.rb b/lib/generators/templates/add_gcm.rb index 27c72778a..96e825ab4 100644 --- a/lib/generators/templates/add_gcm.rb +++ b/lib/generators/templates/add_gcm.rb @@ -19,8 +19,8 @@ def self.up change_column :rapns_notifications, :type, :string, null: false change_column :rapns_apps, :type, :string, null: false - change_column :rapns_notifications, :device_token, :string, { null: true, limit: 64 } - change_column :rapns_notifications, :expiry, :integer, { null: true, default: 1.day.to_i } + change_column :rapns_notifications, :device_token, :string, null: true, limit: 64 + change_column :rapns_notifications, :expiry, :integer, null: true, default: 1.day.to_i change_column :rapns_apps, :environment, :string, null: true change_column :rapns_apps, :certificate, :text, null: true, default: nil @@ -73,8 +73,8 @@ def self.down remove_column :rapns_notifications, :type remove_column :rapns_apps, :type - change_column :rapns_notifications, :device_token, :string, { null: false, limit: 64 } - change_column :rapns_notifications, :expiry, :integer, { null: false, default: 1.day.to_i } + change_column :rapns_notifications, :device_token, :string, null: false, limit: 64 + change_column :rapns_notifications, :expiry, :integer, null: false, default: 1.day.to_i change_column :rapns_apps, :environment, :string, null: false change_column :rapns_apps, :certificate, :text, null: false diff --git a/lib/generators/templates/add_rpush.rb b/lib/generators/templates/add_rpush.rb index 5e938ed20..72e5b4d05 100644 --- a/lib/generators/templates/add_rpush.rb +++ b/lib/generators/templates/add_rpush.rb @@ -164,8 +164,8 @@ def self.up change_column :rapns_notifications, :type, :string, null: false change_column :rapns_apps, :type, :string, null: false - change_column :rapns_notifications, :device_token, :string, { null: true, limit: 64 } - change_column :rapns_notifications, :expiry, :integer, { null: true, default: 1.day.to_i } + change_column :rapns_notifications, :device_token, :string, null: true, limit: 64 + change_column :rapns_notifications, :expiry, :integer, null: true, default: 1.day.to_i change_column :rapns_apps, :environment, :string, null: true change_column :rapns_apps, :certificate, :text, null: true, default: nil @@ -218,8 +218,8 @@ def self.down remove_column :rapns_notifications, :type remove_column :rapns_apps, :type - change_column :rapns_notifications, :device_token, :string, { null: false, limit: 64 } - change_column :rapns_notifications, :expiry, :integer, { null: false, default: 1.day.to_i } + change_column :rapns_notifications, :device_token, :string, null: false, limit: 64 + change_column :rapns_notifications, :expiry, :integer, null: false, default: 1.day.to_i change_column :rapns_apps, :environment, :string, null: false change_column :rapns_apps, :certificate, :text, null: false diff --git a/lib/generators/templates/rpush_3_3_1_updates.rb b/lib/generators/templates/rpush_3_3_1_updates.rb index 62fec8b18..c46800fb3 100644 --- a/lib/generators/templates/rpush_3_3_1_updates.rb +++ b/lib/generators/templates/rpush_3_3_1_updates.rb @@ -5,7 +5,7 @@ def self.up end def self.down - change_column :rpush_notifications, :device_token, :string, { null: true, limit: 64 } - change_column :rpush_feedback, :device_token, :string, { null: true, limit: 64 } + change_column :rpush_notifications, :device_token, :string, null: true, limit: 64 + change_column :rpush_feedback, :device_token, :string, null: true, limit: 64 end end diff --git a/spec/unit/daemon/pushy/delivery_spec.rb b/spec/unit/daemon/pushy/delivery_spec.rb index b915b8669..2493ef27a 100644 --- a/spec/unit/daemon/pushy/delivery_spec.rb +++ b/spec/unit/daemon/pushy/delivery_spec.rb @@ -61,10 +61,12 @@ it_behaves_like 'process notification' end - shared_examples 'retry delivery' do |response_code:| - let(:response_code) { response_code } + shared_examples 'retry delivery' do |options| + let(:response_code) { options[:response_code] } + + shared_examples 'logs' do |log_options| + let(:deliver_after) { log_options[:deliver_after] } - shared_examples 'logs' do |deliver_after:| let(:expected_log_message) do "Pushy responded with a #{response_code} error. Notification #{notification.id} " \ "will be retried after #{deliver_after} (retry 1)." diff --git a/spec/unit/daemon/webpush/delivery_spec.rb b/spec/unit/daemon/webpush/delivery_spec.rb index 300eaf284..97c7d40f6 100644 --- a/spec/unit/daemon/webpush/delivery_spec.rb +++ b/spec/unit/daemon/webpush/delivery_spec.rb @@ -50,10 +50,12 @@ it_behaves_like 'process notification' end - shared_examples 'retry delivery' do |response_code:| - let(:response_code) { response_code } + shared_examples 'retry delivery' do |options| + let(:response_code) { options[:response_code] } + + shared_examples 'logs' do |log_options| + let(:deliver_after) { log_options[:deliver_after] } - shared_examples 'logs' do |deliver_after:| let(:expected_log_message) do "[MyApp] Webpush endpoint responded with a #{response_code} error. Notification #{notification.id} will be retried after #{deliver_after} (retry 1)." end From dce1ea9cf6b6af9458cb987adbde4e2e551412a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Lilleb=C3=B8?= Date: Tue, 2 Feb 2021 22:35:23 +0900 Subject: [PATCH 3/5] Test on Ruby 3.0 & Rails 6.1 --- .travis.yml | 2 ++ Appraisals | 8 ++++++++ gemfiles/rails_6.1.gemfile | 11 +++++++++++ 3 files changed, 21 insertions(+) create mode 100644 gemfiles/rails_6.1.gemfile diff --git a/.travis.yml b/.travis.yml index 7a34d81f2..1ae940c1d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ rvm: - 2.5 - 2.6 - 2.7 + - 3.0 # Build only commits on master for the "Build pushed branches" feature. This # prevents building twice on PRs originating from our repo ("Build pushed pull @@ -27,6 +28,7 @@ gemfile: - gemfiles/rails_5.1.gemfile - gemfiles/rails_5.2.gemfile - gemfiles/rails_6.0.gemfile + - gemfiles/rails_6.1.gemfile services: - postgresql diff --git a/Appraisals b/Appraisals index 7f3d75d64..439a10275 100644 --- a/Appraisals +++ b/Appraisals @@ -42,3 +42,11 @@ appraise "rails-6.0" do gem 'rails', '~> 6.0.0' end end + +appraise "rails-6.1" do + gem 'activesupport', '~> 6.1.0' + + group :development do + gem 'rails', '~> 6.1.0' + end +end diff --git a/gemfiles/rails_6.1.gemfile b/gemfiles/rails_6.1.gemfile new file mode 100644 index 000000000..1a2f8c675 --- /dev/null +++ b/gemfiles/rails_6.1.gemfile @@ -0,0 +1,11 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "activesupport", "~> 6.1.0" + +group :development do + gem "rails", "~> 6.1.0" +end + +gemspec path: "../" From e6334fc8f81a67bc685fc2725d425aa96569a573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Lilleb=C3=B8?= Date: Wed, 3 Feb 2021 14:18:08 +0900 Subject: [PATCH 4/5] Exclude incompatible ruby & rails combinations from CI --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 1ae940c1d..8d120f43b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,6 +53,10 @@ matrix: rvm: 2.3 - gemfile: gemfiles/rails_6.0.gemfile rvm: 2.4 + - gemfile: gemfiles/rails_6.1.gemfile + rvm: 2.3 + - gemfile: gemfiles/rails_6.1.gemfile + rvm: 2.4 jobs: include: From d84392692f13e2cbbc61775d03d4738a4027bf7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Lilleb=C3=B8?= Date: Wed, 3 Feb 2021 14:53:15 +0900 Subject: [PATCH 5/5] Ruby 3 is incompatible with Rails 5 --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index 8d120f43b..ee877cc36 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,6 +49,12 @@ env: matrix: fast_finish: true exclude: + - gemfile: gemfiles/rails_5.0.gemfile + rvm: 3.0 + - gemfile: gemfiles/rails_5.1.gemfile + rvm: 3.0 + - gemfile: gemfiles/rails_5.2.gemfile + rvm: 3.0 - gemfile: gemfiles/rails_6.0.gemfile rvm: 2.3 - gemfile: gemfiles/rails_6.0.gemfile