From b7eb4db87c3f678187053996a1a42f21455c8236 Mon Sep 17 00:00:00 2001 From: Peter Goldstein Date: Fri, 14 Jan 2022 12:08:08 -0800 Subject: [PATCH] Add Ruby 3.1 and Rails 7 to CI (#1526) This PR adds the Ruby 3.1 and Rails 7 elements to the CI matrix. To support those changes a number of other changes were required: - Adding a basic Rails 7 Gemfile and updating `Appraisals` - Quoting 3.0 in the `.github/workflows/build.yml` file so that this entry pulls Ruby 3.0.x and not Ruby 3.1 - Adding the "--disable-error_highlight" value for RUBYOPT in the build environment to disable Ruby 3.1 error highlighting - Bumping the version of `standard` and configuring it to run against our oldest supported version --- .github/workflows/build.yml | 23 +++++++++++++++++++--- .standard.yml | 1 + Appraisals | 6 ++++++ Gemfile.lock | 28 +++++++++++++-------------- gemfiles/7.0.gemfile | 9 +++++++++ lib/factory_bot/decorator.rb | 2 +- lib/factory_bot/definition_proxy.rb | 2 +- lib/factory_bot/evaluator.rb | 2 +- spec/acceptance/build_stubbed_spec.rb | 8 ++++---- spec/factory_bot/definition_spec.rb | 2 +- 10 files changed, 58 insertions(+), 25 deletions(-) create mode 100644 .standard.yml create mode 100644 gemfiles/7.0.gemfile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e1e645ca5..dc4d937e7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,6 +13,7 @@ jobs: ruby: - jruby-9.2.16.0 - truffleruby + - "3.1" - "3.0" - "2.7" - "2.6" @@ -23,25 +24,41 @@ jobs: - "5.2" - "6.0" - "6.1" + - "7.0" - main exclude: + - ruby: 2.5 + rails: "7.0" - ruby: 2.5 rails: main + - ruby: 2.6 + rails: "7.0" - ruby: 2.6 rails: main + - ruby: jruby-9.2.16.0 + rails: "7.0" - ruby: jruby-9.2.16.0 rails: main - - ruby: 3.0 + - ruby: "3.0" + rails: "5.0" + - ruby: "3.0" + rails: "5.1" + - ruby: "3.0" + rails: "5.2" + - ruby: "3.1" rails: "5.0" - - ruby: 3.0 + - ruby: "3.1" rails: "5.1" - - ruby: 3.0 + - ruby: "3.1" rails: "5.2" + - ruby: "3.1" + rails: "6.0" runs-on: 'ubuntu-latest' env: BUNDLE_GEMFILE: gemfiles/${{ matrix.rails }}.gemfile + RUBYOPT: "--disable-error_highlight" steps: - uses: actions/checkout@v2 diff --git a/.standard.yml b/.standard.yml new file mode 100644 index 000000000..724cc8067 --- /dev/null +++ b/.standard.yml @@ -0,0 +1 @@ +ruby_version: "2.5" diff --git a/Appraisals b/Appraisals index 64efee785..eb3121de4 100644 --- a/Appraisals +++ b/Appraisals @@ -28,6 +28,12 @@ appraise "6.1" do gem "sqlite3", platforms: [:ruby] end +appraise "7.0" do + gem "activerecord", "~> 7.0.0" + gem "activerecord-jdbcsqlite3-adapter", "~> 61.0", platforms: [:jruby] + gem "sqlite3", platforms: [:ruby] +end + appraise "main" do gem "activerecord", git: "https://github.com/rails/rails.git", branch: "main" gem "activerecord-jdbcsqlite3-adapter", "~> 61.0", platforms: [:jruby] diff --git a/Gemfile.lock b/Gemfile.lock index e559a95de..a1a949df4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -72,17 +72,17 @@ GEM middleware (0.1.0) minitest (5.14.3) multi_test (0.1.2) - parallel (1.20.1) - parser (3.0.0.0) + parallel (1.21.0) + parser (3.1.0.0) ast (~> 2.4.1) protobuf-cucumber (3.10.8) activesupport (>= 3.2) middleware thor thread_safe - rainbow (3.0.0) + rainbow (3.1.1) rake (13.0.3) - regexp_parser (2.0.3) + regexp_parser (2.2.0) rexml (3.2.5) rspec (3.10.0) rspec-core (~> 3.10.0) @@ -100,19 +100,19 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.10.0) rspec-support (3.10.2) - rubocop (1.10.0) + rubocop (1.24.1) parallel (~> 1.10) parser (>= 3.0.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml - rubocop-ast (>= 1.2.0, < 2.0) + rubocop-ast (>= 1.15.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.4.1) - parser (>= 2.7.1.5) - rubocop-performance (1.9.2) - rubocop (>= 0.90.0, < 2.0) + rubocop-ast (1.15.1) + parser (>= 3.0.1.1) + rubocop-performance (1.13.1) + rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) ruby-progressbar (1.11.0) simplecov (0.21.2) @@ -122,16 +122,16 @@ GEM simplecov-html (0.12.3) simplecov_json_formatter (0.1.2) sqlite3 (1.4.2) - standard (0.13.0) - rubocop (= 1.10.0) - rubocop-performance (= 1.9.2) + standard (1.6.0) + rubocop (= 1.24.1) + rubocop-performance (= 1.13.1) sys-uname (1.2.2) ffi (~> 1.1) thor (1.1.0) thread_safe (0.3.6) tzinfo (2.0.4) concurrent-ruby (~> 1.0) - unicode-display_width (2.0.0) + unicode-display_width (2.1.0) yard (0.9.26) zeitwerk (2.4.2) diff --git a/gemfiles/7.0.gemfile b/gemfiles/7.0.gemfile new file mode 100644 index 000000000..0bbc1585a --- /dev/null +++ b/gemfiles/7.0.gemfile @@ -0,0 +1,9 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "activerecord-jdbcsqlite3-adapter", "~> 61.0", platforms: [:jruby] +gem "sqlite3", platforms: [:ruby] +gem "activerecord", "~> 7.0.0" + +gemspec name: "factory_bot", path: "../" diff --git a/lib/factory_bot/decorator.rb b/lib/factory_bot/decorator.rb index 357f6be3e..3a3a2448e 100644 --- a/lib/factory_bot/decorator.rb +++ b/lib/factory_bot/decorator.rb @@ -17,7 +17,7 @@ def send(...) end RUBY else - def method_missing(name, *args, &block) # rubocop:disable Style/MethodMissingSuper, Style/MissingRespondToMissing + def method_missing(name, *args, &block) # rubocop:disable Style/MissingRespondToMissing @component.send(name, *args, &block) end diff --git a/lib/factory_bot/definition_proxy.rb b/lib/factory_bot/definition_proxy.rb index 20a58ecab..5a6e4c025 100644 --- a/lib/factory_bot/definition_proxy.rb +++ b/lib/factory_bot/definition_proxy.rb @@ -88,7 +88,7 @@ def transient(&block) # end # # are equivalent. - def method_missing(name, *args, &block) # rubocop:disable Style/MissingRespondToMissing, Style/MethodMissingSuper + def method_missing(name, *args, &block) # rubocop:disable Style/MissingRespondToMissing association_options = args.first if association_options.nil? diff --git a/lib/factory_bot/evaluator.rb b/lib/factory_bot/evaluator.rb index 94b99c1aa..e2628a4ff 100644 --- a/lib/factory_bot/evaluator.rb +++ b/lib/factory_bot/evaluator.rb @@ -35,7 +35,7 @@ def association(factory_name, *traits_and_overrides) attr_accessor :instance - def method_missing(method_name, *args, &block) # rubocop:disable Style/MethodMissingSuper, Style/MissingRespondToMissing + def method_missing(method_name, *args, &block) if @instance.respond_to?(method_name) @instance.send(method_name, *args, &block) else diff --git a/spec/acceptance/build_stubbed_spec.rb b/spec/acceptance/build_stubbed_spec.rb index 2c4e3a26d..a8846466f 100644 --- a/spec/acceptance/build_stubbed_spec.rb +++ b/spec/acceptance/build_stubbed_spec.rb @@ -167,7 +167,7 @@ it "allows overriding created_at for objects with created_at" do created_at = 3.days.ago stubbed = build_stubbed(:thing_with_timestamp, created_at: created_at) - expect(stubbed.created_at).to eq created_at + expect(stubbed.created_at).to be_within(1.second).of created_at end it "doesn't allow setting created_at on an object that doesn't define it" do @@ -180,7 +180,7 @@ expect(stub.created_at).to be_about_now past_time = 3.days.ago stub.created_at = past_time - expect(stub.created_at).to eq past_time + expect(stub.created_at).to be_within(1.second).of past_time end it "behaves the same as a non-stubbed created_at" do @@ -231,7 +231,7 @@ def created_at it "allows overriding updated_at for objects with updated_at" do past_time = 3.days.ago stubbed = build_stubbed(:thing_with_timestamp, updated_at: past_time) - expect(stubbed.updated_at).to eq past_time + expect(stubbed.updated_at).to be_within(1.second).of past_time end it "doesn't allow setting updated_at on an object that doesn't define it" do @@ -245,7 +245,7 @@ def created_at expect(stub.updated_at).to be_about_now past_time = 3.days.ago stub.updated_at = past_time - expect(stub.updated_at).to eq past_time + expect(stub.updated_at).to be_within(1.second).of past_time end it "behaves the same as a non-stubbed updated_at" do diff --git a/spec/factory_bot/definition_spec.rb b/spec/factory_bot/definition_spec.rb index 1cd5fb9c5..d16acc3d4 100644 --- a/spec/factory_bot/definition_spec.rb +++ b/spec/factory_bot/definition_spec.rb @@ -67,7 +67,7 @@ it "exposes a non-default create strategy when one is provided by the user" do definition = described_class.new(:name) - block = proc { nil } + block = proc {} definition.to_create(&block) expect(definition.to_create).to eq block