From 89a92bd1da9091ea5a532752a28346b370bab3f7 Mon Sep 17 00:00:00 2001 From: mishina Date: Thu, 3 Mar 2022 23:36:54 +0900 Subject: [PATCH 01/14] Address CI failure in Ruby 3 Since rspec-mocks v3.10.3, `with` now distinguishes between keyword args and hash in Ruby 3. See https://github.com/rspec/rspec-mocks/pull/1394 for details. --- spec/draper/decoratable_spec.rb | 2 +- spec/draper/decorator_spec.rb | 4 ++-- spec/draper/factory_spec.rb | 16 ++++++++-------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/spec/draper/decoratable_spec.rb b/spec/draper/decoratable_spec.rb index 8e673fa6..ccdfa6be 100644 --- a/spec/draper/decoratable_spec.rb +++ b/spec/draper/decoratable_spec.rb @@ -147,7 +147,7 @@ module Draper scoped = [Product.new] allow(Product).to receive(:all).and_return(scoped) - expect(Product.decorator_class).to receive(:decorate_collection).with(scoped, with: nil).and_return(:decorated_collection) + expect(Product.decorator_class).to receive(:decorate_collection).with(scoped, {with: nil}).and_return(:decorated_collection) expect(Product.decorate).to be :decorated_collection end diff --git a/spec/draper/decorator_spec.rb b/spec/draper/decorator_spec.rb index 876a3dd1..a6613fed 100644 --- a/spec/draper/decorator_spec.rb +++ b/spec/draper/decorator_spec.rb @@ -118,7 +118,7 @@ module Draper it "creates a CollectionDecorator using itself for each item" do object = [Model.new] - expect(CollectionDecorator).to receive(:new).with(object, with: Decorator) + expect(CollectionDecorator).to receive(:new).with(object, {with: Decorator}) Decorator.decorate_collection(object) end @@ -134,7 +134,7 @@ module Draper it "creates a custom collection decorator using itself for each item" do object = [Model.new] - expect(ProductsDecorator).to receive(:new).with(object, with: ProductDecorator) + expect(ProductsDecorator).to receive(:new).with(object, {with: ProductDecorator}) ProductDecorator.decorate_collection(object) end diff --git a/spec/draper/factory_spec.rb b/spec/draper/factory_spec.rb index 9a9ce24a..83b479b2 100644 --- a/spec/draper/factory_spec.rb +++ b/spec/draper/factory_spec.rb @@ -73,17 +73,17 @@ module Draper worker = ->(*){} allow(Factory::Worker).to receive_messages new: worker - expect(worker).to receive(:call).with(baz: "qux", context: {foo: "bar"}) + expect(worker).to receive(:call).with({baz: "qux", context: {foo: "bar"}}) factory.decorate(double, {baz: "qux"}) end it "is overridden by explicitly-specified context" do - factory = Factory.new(context: {foo: "bar"}) + factory = Factory.new({context: {foo: "bar"}}) worker = ->(*){} allow(Factory::Worker).to receive_messages new: worker - expect(worker).to receive(:call).with(context: {baz: "qux"}) - factory.decorate(double, context: {baz: "qux"}) + expect(worker).to receive(:call).with({context: {baz: "qux"}}) + factory.decorate(double, {context: {baz: "qux"}}) end end end @@ -109,7 +109,7 @@ module Draper allow(worker).to receive_messages decorator: decorator context = {foo: "bar"} - expect(decorator).to receive(:call).with(anything(), context: context) + expect(decorator).to receive(:call).with(anything(), {context: context}) worker.call(context: ->{ context }) end @@ -140,7 +140,7 @@ module Draper allow(worker).to receive_messages decorator: decorator context = {foo: "bar"} - expect(decorator).to receive(:call).with(anything(), context: context) + expect(decorator).to receive(:call).with(anything(), {context: context}) worker.call(context: context) end end @@ -150,7 +150,7 @@ module Draper decorator = ->(*){} allow(worker).to receive_messages decorator: decorator - expect(decorator).to receive(:call).with(anything(), foo: "bar") + expect(decorator).to receive(:call).with(anything(), {foo: "bar"}) worker.call(foo: "bar", context_args: []) end end @@ -228,7 +228,7 @@ module Draper allow(object).to receive(:decorate){ nil } worker = Factory::Worker.new(nil, object) - expect(decorator_class).to receive(:decorate_collection).with(object, foo: "bar", with: nil).and_return(:decorated) + expect(decorator_class).to receive(:decorate_collection).with(object, {foo: "bar", with: nil}).and_return(:decorated) expect(worker.decorator.call(object, foo: "bar")).to be :decorated end end From b575c6acb0675cd463fe69f85850beb8568be1cf Mon Sep 17 00:00:00 2001 From: mishina Date: Thu, 3 Mar 2022 23:43:23 +0900 Subject: [PATCH 02/14] Enable bundler-cache in ruby/setup-ruby --- .github/workflows/ci.yml | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0b73e450..0b67853b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,20 +32,7 @@ jobs: uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} - - - name: Setup Ruby cache - uses: actions/cache@v2 - with: - path: vendor/bundle - key: ${{ runner.os }}-gems-${{ matrix.ruby }}-${{ hashFiles('**/Gemfile.lock') }} - restore-keys: | - ${{ runner.os }}-gems-${{ matrix.ruby }}- - - - name: Bundle - run: | - gem install bundler - bundle config path vendor/bundle - bundle install --jobs 4 --retry 3 + bundler-cache: true - name: RSpec & publish code coverage uses: paambaati/codeclimate-action@v2.7.5 From 62bfbcc2684cf2a478d32fbfb22e0ba0f83be913 Mon Sep 17 00:00:00 2001 From: mishina Date: Thu, 3 Mar 2022 23:49:40 +0900 Subject: [PATCH 03/14] Add Ruby 3.1 to the CI matrix net-imap, net-pop and net-smtp are bundled gems in Ruby 3.1. So they need to be listed in Gemfile. See https://www.ruby-lang.org/en/news/2021/12/25/ruby-3-1-0-released/ for details. --- .github/workflows/ci.yml | 1 + Gemfile | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0b67853b..ed9d6c19 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,6 +12,7 @@ jobs: fail-fast: false matrix: ruby: + - '3.1' - '3.0' - '2.7' - '2.6' diff --git a/Gemfile b/Gemfile index f1a10c3c..f7ed415f 100644 --- a/Gemfile +++ b/Gemfile @@ -27,3 +27,9 @@ if RUBY_VERSION >= "2.5.0" else gem "mongoid", "~> 7.2" end + +if RUBY_VERSION >= "3.1.0" + gem "net-imap" + gem "net-pop" + gem "net-smtp" +end From 0472887ce452af6962d96e72b7fe72f9bd281955 Mon Sep 17 00:00:00 2001 From: mishina Date: Sat, 11 Jun 2022 15:33:52 +0900 Subject: [PATCH 04/14] Add GitHub token permissions for workflow GitHub asks developers to define workflow permissions, see below for securing GitHub workflows against supply-chain attacks. - https://github.blog/changelog/2021-04-20-github-actions-control-permissions-for-github_token/ - https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed9d6c19..9680c7f7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,9 @@ on: - push - pull_request +permissions: + contents: read + jobs: rspec: runs-on: ubuntu-20.04 From d3d7f5d44ef8e30b7246e6696a5f07a7ad2fbf07 Mon Sep 17 00:00:00 2001 From: mishina Date: Sat, 11 Jun 2022 15:35:30 +0900 Subject: [PATCH 05/14] Bump actions/checkout from v2 to v3 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9680c7f7..c299f46e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup Ruby uses: ruby/setup-ruby@v1 From 86d8e5e60c8def41130505b6f1050812f8c34b4d Mon Sep 17 00:00:00 2001 From: mishina <32959831+mishina2228@users.noreply.github.com> Date: Thu, 29 Dec 2022 22:33:50 +0900 Subject: [PATCH 06/14] Add Ruby 3.2 to the CI matrix --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c299f46e..fc9593f3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,7 @@ jobs: fail-fast: false matrix: ruby: + - '3.2' - '3.1' - '3.0' - '2.7' From 3152987a85eabc3ffe917990bbb53ac080c274be Mon Sep 17 00:00:00 2001 From: mishina Date: Thu, 29 Dec 2022 22:49:15 +0900 Subject: [PATCH 07/14] Use mongoid 7.x with earlier than Ruby 2.6 --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index f7ed415f..d32a399f 100644 --- a/Gemfile +++ b/Gemfile @@ -22,7 +22,7 @@ else gem "rails", "~> 5.0" end -if RUBY_VERSION >= "2.5.0" +if RUBY_VERSION >= "2.6.0" gem "mongoid", github: "mongodb/mongoid" else gem "mongoid", "~> 7.2" From 48c46baeffc1b789578d316d7d0ebe21eed120a4 Mon Sep 17 00:00:00 2001 From: mishina <32959831+mishina2228@users.noreply.github.com> Date: Fri, 30 Dec 2022 16:04:43 +0900 Subject: [PATCH 08/14] Bump paambaati/codeclimate-action to v3.2.0 This suppresses the following warning: ``` Node.js 12 actions are deprecated. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/. Please update the following actions to use Node.js 16: paambaati/codeclimate-action@v2.7.5 ``` --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fc9593f3..e95895a9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,7 +40,7 @@ jobs: bundler-cache: true - name: RSpec & publish code coverage - uses: paambaati/codeclimate-action@v2.7.5 + uses: paambaati/codeclimate-action@v3.2.0 env: CC_TEST_REPORTER_ID: b7ba588af2a540fa96c267b3655a2afe31ea29976dc25905a668dd28d5e88915 with: From 971eec3cc52df39d167d1315804f099bff6f1ae3 Mon Sep 17 00:00:00 2001 From: mishina Date: Wed, 21 Aug 2024 18:10:20 +0900 Subject: [PATCH 09/14] Add Ruby 3.3 to the CI matrix --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e95895a9..366899f7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,7 @@ jobs: fail-fast: false matrix: ruby: + - '3.3' - '3.2' - '3.1' - '3.0' From acc587d71c41a1c6938d78030d23517ac085fca9 Mon Sep 17 00:00:00 2001 From: mishina Date: Wed, 21 Aug 2024 18:16:03 +0900 Subject: [PATCH 10/14] Restrict to sqlite3 v1 --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index d32a399f..593d10f4 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ gemspec platforms :ruby do if RUBY_VERSION >= "2.5.0" - gem 'sqlite3' + gem 'sqlite3', '~> 1.4' else gem 'sqlite3', '~> 1.3.6' end From e3bcc365233b926dde5fe6d1d88202cb5c06a9d1 Mon Sep 17 00:00:00 2001 From: mishina Date: Wed, 21 Aug 2024 18:26:26 +0900 Subject: [PATCH 11/14] Workaround for Ruby 2.4 --- Gemfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Gemfile b/Gemfile index 593d10f4..8c222ef4 100644 --- a/Gemfile +++ b/Gemfile @@ -33,3 +33,7 @@ if RUBY_VERSION >= "3.1.0" gem "net-pop" gem "net-smtp" end + +if RUBY_VERSION < "2.5.0" + gem "loofah", "< 2.21.0" # Workaround for `uninitialized constant Nokogiri::HTML4` +end From 2905bef537cb03b1c8b82af1e124362cd8ad60c1 Mon Sep 17 00:00:00 2001 From: mishina Date: Wed, 21 Aug 2024 18:31:41 +0900 Subject: [PATCH 12/14] Adjust mongoid version requirements --- Gemfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 8c222ef4..1ec9bada 100644 --- a/Gemfile +++ b/Gemfile @@ -22,8 +22,10 @@ else gem "rails", "~> 5.0" end -if RUBY_VERSION >= "2.6.0" +if RUBY_VERSION >= "2.7.0" gem "mongoid", github: "mongodb/mongoid" +elsif RUBY_VERSION >= "2.6.0" + gem "mongoid", "~> 8.1" else gem "mongoid", "~> 7.2" end From 402d262fc06fae9b3f05ea0c20e040a4fd85be0d Mon Sep 17 00:00:00 2001 From: mishina Date: Wed, 21 Aug 2024 18:35:49 +0900 Subject: [PATCH 13/14] Bump actions/checkout from v3 to v4 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 366899f7..ecdd3c3f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Ruby uses: ruby/setup-ruby@v1 From a74f591e887311d3d31391c23c678433a6e3cf0f Mon Sep 17 00:00:00 2001 From: mishina Date: Wed, 21 Aug 2024 18:41:44 +0900 Subject: [PATCH 14/14] Bump paambaati/codeclimate from v3.2.0 to v8 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ecdd3c3f..101416c0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: bundler-cache: true - name: RSpec & publish code coverage - uses: paambaati/codeclimate-action@v3.2.0 + uses: paambaati/codeclimate-action@v8 env: CC_TEST_REPORTER_ID: b7ba588af2a540fa96c267b3655a2afe31ea29976dc25905a668dd28d5e88915 with: