From fb018f11a9b838ac78bd8428f41b8fc1edeccfc9 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Tue, 3 Nov 2020 23:40:03 +0100 Subject: [PATCH 1/9] Move MRI build to Github Actions jruby not moved because there is too many issues with it at the moment. Next step fix : - fix ruby 3 - fix flacky test with "mountable_engine?" error - add JRuby --- .github/workflows/ci.yml | 95 ++++++++++++++++++++++++++++++++++++++++ .travis.yml | 53 +++------------------- 2 files changed, 100 insertions(+), 48 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..6c55aa9b59 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,95 @@ +name: RSpec CI +on: + push: + branches: + - 'main' + - '*-maintenance' + - '*-dev' + pull_request: + branches: + - '*' +jobs: + test: + name: 'Ruby: ${{ matrix.ruby }}, Rails: ${{ matrix.env.RAILS_VERSION }}' + runs-on: ubuntu-20.04 + strategy: + fail-fast: false + matrix: + include: + # Rails 6.0 builds >= 2.5.0 + - ruby: 3.0.0-preview1 + allow_failure: true + env: + RAILS_VERSION: '~> 6.0.0' + - ruby: 2.7 + env: + RAILS_VERSION: '~> 6.0.0' + - ruby: 2.6 + env: + RAILS_VERSION: '~> 6.0.0' + - ruby: 2.5 + env: + RAILS_VERSION: '~> 6.0.0' + # Rails 5.2 builds >= 2.2.2 + - ruby: 2.6.6 + env: + RAILS_VERSION: '~> 5.2.0' + - ruby: 2.5.8 + env: + RAILS_VERSION: '~> 5.2.0' + - ruby: 2.4.10 + env: + RAILS_VERSION: '~> 5.2.0' + - ruby: 2.3.8 + env: + RAILS_VERSION: '~> 5.2.0' + - ruby: 2.2.10 + allow_failure: true + env: + RAILS_VERSION: '~> 5.2.0' + - ruby: 2.2.10 + env: + RAILS_VERSION: '5-2-stable' + # Rails 5.1 Builds >= 2.2.2 + - ruby: 2.6.6 + env: + RAILS_VERSION: '~> 5.1.0' + - ruby: 2.5.8 + env: + RAILS_VERSION: '~> 5.1.0' + - ruby: 2.4.10 + env: + RAILS_VERSION: '~> 5.1.0' + - ruby: 2.3.8 + env: + RAILS_VERSION: '~> 5.1.0' + - ruby: 2.2.10 + env: + RAILS_VERSION: '~> 5.1.0' + # Rails 5.0 Builds >= 2.2.2 + - ruby: 2.6.6 + env: + RAILS_VERSION: '~> 5.0.0' + - ruby: 2.5.8 + env: + RAILS_VERSION: '~> 5.0.0' + - ruby: 2.4.10 + env: + RAILS_VERSION: '~> 5.0.0' + - ruby: 2.3.8 + env: + RAILS_VERSION: '~> 5.0.0' + - ruby: 2.2.10 + env: + RAILS_VERSION: '~> 5.0.0' + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: false + - run: script/update_rubygems_and_install_bundler + - run: script/clone_all_rspec_repos + - run: bundle install --binstubs && script/run_build + env: ${{ matrix.env }} + continue-on-error: ${{ matrix.allow_failure || false }} diff --git a/.travis.yml b/.travis.yml index 843352ae6e..00c69032f3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,66 +38,23 @@ script: "script/run_build 2>&1" matrix: include: - # Rails 6.0 builds >= 2.5.0 - rvm: jruby-head jdk: oraclejdk11 env: - RAILS_VERSION='~> 6.0.0' - JRUBY_OPT=--dev - JAVA_OPTS="--add-opens java.base/sun.nio.ch=org.jruby.dist --add-opens java.base/java.io=org.jruby.dist --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.security.cert=ALL-UNNAMED --add-opens=java.base/java.util.zip=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.util.regex=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/javax.crypto=ALL-UNNAMED --add-opens=java.management/sun.management=ALL-UNNAMED" - - rvm: ruby-3.0.0-preview1 - env: RAILS_VERSION='~> 6.0.0' - allow_failure: true - - rvm: 2.7.1 - env: RAILS_VERSION='~> 6.0.0' - - rvm: 2.6.6 - env: RAILS_VERSION='~> 6.0.0' - - rvm: 2.5.8 - env: RAILS_VERSION='~> 6.0.0' - # Rails 5.2 builds >= 2.2.2 - rvm: jruby-head jdk: oraclejdk11 env: - RAILS_VERSION='~> 5.2.0' - JRUBY_OPT=--dev - JAVA_OPTS="--add-opens java.base/sun.nio.ch=org.jruby.dist --add-opens java.base/java.io=org.jruby.dist --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.security.cert=ALL-UNNAMED --add-opens=java.base/java.util.zip=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.util.regex=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/javax.crypto=ALL-UNNAMED --add-opens=java.management/sun.management=ALL-UNNAMED" - - rvm: 2.6.6 - env: RAILS_VERSION='~> 5.2.0' - - rvm: 2.5.8 - env: RAILS_VERSION='~> 5.2.0' - - rvm: 2.4.10 - env: RAILS_VERSION='~> 5.2.0' - - rvm: 2.3.8 - env: RAILS_VERSION='~> 5.2.0' - - rvm: 2.2.10 - env: RAILS_VERSION='~> 5.2.0' - allow_failure: true - - rvm: 2.2.10 - env: RAILS_VERSION='5-2-stable' - - # Rails 5.1 Builds >= 2.2.2 - - rvm: 2.6.6 - env: RAILS_VERSION='~> 5.1.0' - - rvm: 2.5.8 - env: RAILS_VERSION='~> 5.1.0' - - rvm: 2.4.10 - env: RAILS_VERSION='~> 5.1.0' - - rvm: 2.3.8 - env: RAILS_VERSION='~> 5.1.0' - - rvm: 2.2.10 - env: RAILS_VERSION='~> 5.1.0' - - # Rails 5.0 Builds >= 2.2.2 - - rvm: 2.6.6 - env: RAILS_VERSION='~> 5.0.0' - - rvm: 2.5.8 - env: RAILS_VERSION='~> 5.0.0' - - rvm: 2.4.10 - env: RAILS_VERSION='~> 5.0.0' - - rvm: 2.3.8 - env: RAILS_VERSION='~> 5.0.0' - - rvm: 2.2.10 - env: RAILS_VERSION='~> 5.0.0' fast_finish: true + +branches: + only: + - master + - /^\d+-\d+-maintenance$/ From 1d12c96bd37cc3751cb2cdf44f86e5ac51b899e0 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Sat, 21 Nov 2020 00:11:25 +0100 Subject: [PATCH 2/9] Avoid 'mountable_engine?' stub to leak to next specs in the same file --- .../rspec/scaffold/scaffold_generator_spec.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/spec/generators/rspec/scaffold/scaffold_generator_spec.rb b/spec/generators/rspec/scaffold/scaffold_generator_spec.rb index a56b5858ea..d8417519f1 100644 --- a/spec/generators/rspec/scaffold/scaffold_generator_spec.rb +++ b/spec/generators/rspec/scaffold/scaffold_generator_spec.rb @@ -1,8 +1,10 @@ # Generators are not automatically loaded by Rails require 'generators/rspec/scaffold/scaffold_generator' require 'support/generators' +require 'rspec/support/spec/in_sub_process' RSpec.describe Rspec::Generators::ScaffoldGenerator, type: :generator do + include RSpec::Support::InSubProcess setup_default_destination describe 'standard request specs' do @@ -41,12 +43,13 @@ end describe 'in an engine' do - before do - allow_any_instance_of(::Rails::Generators::NamedBase).to receive(:mountable_engine?).and_return(true) - run_generator %w[posts --request_specs] + it 'generates files with Engine url_helpers' do + in_sub_process do + allow_any_instance_of(::Rails::Generators::NamedBase).to receive(:mountable_engine?).and_return(true) + run_generator %w[posts --request_specs] + is_expected.to contain('Engine.routes.url_helpers') + end end - - it { is_expected.to contain('Engine.routes.url_helpers') } end end From 6b7eec040692ce4cf6a6dc9fcfdff7a2aec3a54a Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Sat, 21 Nov 2020 16:04:15 +0100 Subject: [PATCH 3/9] Run the same branch on GA and Travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 00c69032f3..4012daadfd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -58,3 +58,4 @@ branches: only: - master - /^\d+-\d+-maintenance$/ + - /^\d+-\d+-dev$/ From 08bdd11f23ffb5818e2346a1dbca1b4bf19be64c Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Sat, 21 Nov 2020 16:22:39 +0100 Subject: [PATCH 4/9] Share env variables to other steps with RSpec scripts --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6c55aa9b59..5dd9f8fe16 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -89,7 +89,9 @@ jobs: ruby-version: ${{ matrix.ruby }} bundler-cache: false - run: script/update_rubygems_and_install_bundler + env: ${{ matrix.env }} - run: script/clone_all_rspec_repos + env: ${{ matrix.env }} - run: bundle install --binstubs && script/run_build env: ${{ matrix.env }} continue-on-error: ${{ matrix.allow_failure || false }} From 7667604f53d6b8b1386841b4e2e6f5a95f4f7109 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Sat, 21 Nov 2020 17:18:00 +0100 Subject: [PATCH 5/9] Fix argument error on Ruby3.0.preview1 and ActionMailer Error was + 1) InboxMailbox route email to properly mailbox + Failure/Error: + expect(InboxMailbox) + .to receive_inbound_email(to: "replies@example.com") + + ArgumentError: + wrong number of arguments (given 1, expected 0) + # /home/runner/work/rspec-rails/bundle/ruby/3.0.0/gems/actionmailbox-6.0.3.4/lib/action_mailbox/test_helper.rb:16:in `create_inbound_email_from_mail' + # ./spec/mailboxes/inbox_mailbox_spec.rb:6:in `block (2 levels) in ' It should be fixed with Rails 6.1 https://github.com/rails/rails/pull/35904 --- .github/workflows/ci.yml | 1 - lib/rspec/rails/example/mailbox_example_group.rb | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5dd9f8fe16..330249b02c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,6 @@ jobs: include: # Rails 6.0 builds >= 2.5.0 - ruby: 3.0.0-preview1 - allow_failure: true env: RAILS_VERSION: '~> 6.0.0' - ruby: 2.7 diff --git a/lib/rspec/rails/example/mailbox_example_group.rb b/lib/rspec/rails/example/mailbox_example_group.rb index 24cd125b60..de85acdf43 100644 --- a/lib/rspec/rails/example/mailbox_example_group.rb +++ b/lib/rspec/rails/example/mailbox_example_group.rb @@ -13,7 +13,7 @@ module MailboxExampleGroup def self.create_inbound_email(arg) case arg when Hash - create_inbound_email_from_mail(arg) + create_inbound_email_from_mail(**arg) else create_inbound_email_from_source(arg.to_s) end From e265a35eb9b86fa6db1927d4c70d06f4f682370e Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Sat, 21 Nov 2020 18:37:27 +0100 Subject: [PATCH 6/9] Reduce dup by moving env and continue-on-error before steps Co-authored-by: Jon Rowe --- .github/workflows/ci.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 330249b02c..51839a66a4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -81,16 +81,13 @@ jobs: - ruby: 2.2.10 env: RAILS_VERSION: '~> 5.0.0' + env: ${{ matrix.env }} + continue-on-error: ${{ matrix.allow_failure || false }} steps: - uses: actions/checkout@v2 - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} - bundler-cache: false - - run: script/update_rubygems_and_install_bundler - env: ${{ matrix.env }} - run: script/clone_all_rspec_repos - env: ${{ matrix.env }} - - run: bundle install --binstubs && script/run_build - env: ${{ matrix.env }} - continue-on-error: ${{ matrix.allow_failure || false }} + - run: bundle binstubs rspec rspec-core rake cucumber rails + - run: script/run_build From 6394472bc1a2cc7a6d05e6c2f80a0838c8c57340 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Sun, 22 Nov 2020 12:37:56 +0100 Subject: [PATCH 7/9] Revert to previous working commands to install dependencies --- .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 51839a66a4..d027ee5f0a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -89,5 +89,5 @@ jobs: with: ruby-version: ${{ matrix.ruby }} - run: script/clone_all_rspec_repos - - run: bundle binstubs rspec rspec-core rake cucumber rails + - run: bundle install --binstubs - run: script/run_build From 67a9899fda9442949d2d9730b1de7f3205cdaaa1 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Sun, 22 Nov 2020 15:16:37 +0100 Subject: [PATCH 8/9] Set explicit hash as last arg to avoid "wrong number of arguments" error Error was happening on Ruby3.0.0-preview1 --- features/matchers/have_broadcasted_matcher.feature | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/features/matchers/have_broadcasted_matcher.feature b/features/matchers/have_broadcasted_matcher.feature index ecacadafe9..8b639326ac 100644 --- a/features/matchers/have_broadcasted_matcher.feature +++ b/features/matchers/have_broadcasted_matcher.feature @@ -16,7 +16,7 @@ Feature: have_broadcasted matcher it "matches with stream name" do expect { ActionCable.server.broadcast( - "notifications", text: 'Hello!' + "notifications", { text: "Hello!" } ) }.to have_broadcasted_to("notifications") end @@ -34,7 +34,7 @@ Feature: have_broadcasted matcher it "matches with message" do expect { ActionCable.server.broadcast( - "notifications", text: 'Hello!' + "notifications", { text: "Hello!" } ) }.to have_broadcasted_to("notifications").with(text: 'Hello!') end @@ -52,7 +52,7 @@ Feature: have_broadcasted matcher it "matches with message" do expect { ActionCable.server.broadcast( - "notifications", text: 'Hello!', user_id: 12 + "notifications", { text: 'Hello!', user_id: 12 } ) }.to have_broadcasted_to("notifications").with(a_hash_including(text: 'Hello!')) end @@ -70,7 +70,7 @@ Feature: have_broadcasted matcher it "matches with message" do expect { ActionCable.server.broadcast( - "notifications", text: 'Hello!', user_id: 12 + "notifications", { text: 'Hello!', user_id: 12 } ) }.to have_broadcasted_to("notifications").with { |data| expect(data['user_id']).to eq 12 @@ -90,7 +90,7 @@ Feature: have_broadcasted matcher it "matches with stream name" do expect { ActionCable.server.broadcast( - "notifications", text: 'Hello!' + "notifications", { text: 'Hello!' } ) }.to broadcast_to("notifications") end From 029416b37eddecbe4d4f17bb8dd48159a78ea278 Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Sun, 22 Nov 2020 16:02:04 +0100 Subject: [PATCH 9/9] continue-on-error seems to work only when defined in step --- .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 d027ee5f0a..8b51487a2e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -82,7 +82,6 @@ jobs: env: RAILS_VERSION: '~> 5.0.0' env: ${{ matrix.env }} - continue-on-error: ${{ matrix.allow_failure || false }} steps: - uses: actions/checkout@v2 - uses: ruby/setup-ruby@v1 @@ -91,3 +90,4 @@ jobs: - run: script/clone_all_rspec_repos - run: bundle install --binstubs - run: script/run_build + continue-on-error: ${{ matrix.allow_failure || false }}