From 7d3c321d31e9a9d436f3928cf1b6a6bff726c5e2 Mon Sep 17 00:00:00 2001 From: Florian Wininger Date: Tue, 4 Jan 2022 14:29:27 +0100 Subject: [PATCH] Use github action for testing and update test suite --- .github/workflows/main.yml | 60 +++++++++++++++++++ .rubocop.yml | 1 + .travis.yml | 45 ++------------ Appraisals | 2 +- README.md | 6 +- exception_notification.gemspec | 6 +- gemfiles/rails4_2.gemfile | 7 --- gemfiles/rails5_0.gemfile | 7 --- gemfiles/rails5_1.gemfile | 7 --- .../{rails4_0.gemfile => rails6_1.gemfile} | 2 +- .../{rails4_1.gemfile => rails7_0.gemfile} | 2 +- .../modules/error_grouping.rb | 2 +- lib/exception_notifier/modules/formatter.rb | 1 - test/exception_notifier/sns_notifier_test.rb | 7 +-- 14 files changed, 79 insertions(+), 76 deletions(-) create mode 100644 .github/workflows/main.yml delete mode 100644 gemfiles/rails4_2.gemfile delete mode 100644 gemfiles/rails5_0.gemfile delete mode 100644 gemfiles/rails5_1.gemfile rename gemfiles/{rails4_0.gemfile => rails6_1.gemfile} (79%) rename gemfiles/{rails4_1.gemfile => rails7_0.gemfile} (79%) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..709dcd0f --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,60 @@ +name: main +on: + - push + - pull_request +jobs: + rspec: + runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + ruby-version: + - 2.6 + - 2.7 + - 3.0.0 + - 3.1 + gemfile: + - rails5_2.gemfile + - rails6_0.gemfile + - rails6_1.gemfile + - rails7_0.gemfile + exclude: + - ruby-version: 2.6 + gemfile: rails7_0.gemfile + - ruby-version: 3.0.0 + gemfile: rails5_2.gemfile + - ruby-version: 3.1 + gemfile: rails5_2.gemfile + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true + + - name: Install required gems + run: BUNDLE_GEMFILE=gemfiles/${{ matrix.gemfile }} bundle install --jobs=3 --retry=3 + + - name: Run rspec tests + run: BUNDLE_GEMFILE=gemfiles/${{ matrix.gemfile }} bundle exec rake test + + rubocop: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.0.0 + bundler-cache: true + + - name: Install required gems + run: bundle install + + - name: Run rubocop + run: bundle exec rubocop diff --git a/.rubocop.yml b/.rubocop.yml index ed86418e..f977dd9f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -5,6 +5,7 @@ AllCops: DisplayCopNames: true Exclude: - "gemfiles/**/*" + - vendor/bundle/**/* Style/Documentation: Enabled: false diff --git a/.travis.yml b/.travis.yml index cbbb37ea..1aba21ef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,10 @@ language: ruby cache: bundler rvm: - - 2.3.8 - - 2.4.9 - - 2.5.7 - 2.6.5 - 2.7.0 + - 3.0.0 + env: - COVERALLS_SILENT=true before_install: @@ -18,46 +17,14 @@ install: - "mkdir -p test/dummy/tmp/non_default_location" gemfile: - - gemfiles/rails4_0.gemfile - - gemfiles/rails4_1.gemfile - - gemfiles/rails4_2.gemfile - - gemfiles/rails5_0.gemfile - - gemfiles/rails5_1.gemfile - gemfiles/rails5_2.gemfile - gemfiles/rails6_0.gemfile - -matrix: - exclude: - # Rails 6 supports Ruby 2.5 and up - - rvm: 2.3.8 - gemfile: gemfiles/rails6_0.gemfile - - rvm: 2.4.9 - gemfile: gemfiles/rails6_0.gemfile - # rails <=4.1 segfaults with ruby 2.4+ - - rvm: 2.4.9 - gemfile: gemfiles/rails4_0.gemfile - - rvm: 2.4.9 - gemfile: gemfiles/rails4_1.gemfile - - rvm: 2.5.7 - gemfile: gemfiles/rails4_0.gemfile - - rvm: 2.5.7 - gemfile: gemfiles/rails4_1.gemfile - - rvm: 2.6.5 - gemfile: gemfiles/rails4_0.gemfile - - rvm: 2.6.5 - gemfile: gemfiles/rails4_1.gemfile - - rvm: 2.7.0 - gemfile: gemfiles/rails4_0.gemfile - - rvm: 2.7.0 - gemfile: gemfiles/rails4_1.gemfile - # Uninstalling bundler 2 will no longer work since it's a default ruby gem now - - rvm: 2.7.0 - gemfile: gemfiles/rails4_2.gemfile - + - gemfiles/rails6_1.gemfile + - gemfiles/rails7_0.gemfile jobs: include: - stage: Lint - rvm: 2.7.0 - gemfile: gemfiles/rails6_0.gemfile + rvm: 3.0.0 + gemfile: gemfiles/rails7_0.gemfile script: bundle exec rubocop diff --git a/Appraisals b/Appraisals index 713bf000..25c50247 100644 --- a/Appraisals +++ b/Appraisals @@ -1,6 +1,6 @@ # frozen_string_literal: true -rails_versions = ['~> 4.0.5', '~> 4.1.1', '~> 4.2.0', '~> 5.0.0', '~> 5.1.0', '~> 5.2.0', '~> 6.0.0'] +rails_versions = ['~> 5.2.0', '~> 6.0.0', '~> 6.1.0', '~> 7.0.0'] rails_versions.each do |rails_version| appraise "rails#{rails_version.slice(/\d+\.\d+/).tr('.', '_')}" do diff --git a/README.md b/README.md index a071544c..45154d36 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,8 @@ There's a great [Railscast about Exception Notification](http://railscasts.com/e ## Requirements -* Ruby 2.3 or greater -* Rails 4.0 or greater, Sinatra or another Rack-based application. +* Ruby 2.5 or greater +* Rails 5.2 or greater, Sinatra or another Rack-based application. ## Getting Started @@ -35,7 +35,6 @@ ExceptionNotification is used as a rack middleware, or in the environment you wa ```ruby Rails.application.config.middleware.use ExceptionNotification::Rack, email: { - deliver_with: :deliver, # Rails >= 4.2.1 do not need this option since it defaults to :deliver_now email_prefix: '[PREFIX] ', sender_address: %{"notifier" }, exception_recipients: %w{exceptions@example.com} @@ -270,7 +269,6 @@ def server_error(exception) end ``` - ## Extras ### Rails diff --git a/exception_notification.gemspec b/exception_notification.gemspec index 9deaf080..0aac9960 100644 --- a/exception_notification.gemspec +++ b/exception_notification.gemspec @@ -20,8 +20,8 @@ Gem::Specification.new do |s| s.test_files = `git ls-files -- test`.split("\n") s.require_path = 'lib' - s.add_dependency('actionmailer', '>= 4.0', '< 8') - s.add_dependency('activesupport', '>= 4.0', '< 8') + s.add_dependency('actionmailer', '>= 5.2', '< 8') + s.add_dependency('activesupport', '>= 5.2', '< 8') s.add_development_dependency 'appraisal', '~> 2.2.0' s.add_development_dependency 'aws-sdk-sns', '~> 1' @@ -32,7 +32,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'httparty', '~> 0.10.2' s.add_development_dependency 'mocha', '>= 0.13.0' s.add_development_dependency 'mock_redis', '~> 0.19.0' - s.add_development_dependency 'rails', '>= 4.0', '< 8' + s.add_development_dependency 'rails', '>= 5.2', '< 8' s.add_development_dependency 'resque', '~> 1.8.0' s.add_development_dependency 'rubocop', '0.78.0' s.add_development_dependency 'sidekiq', '>= 5.0.4' diff --git a/gemfiles/rails4_2.gemfile b/gemfiles/rails4_2.gemfile deleted file mode 100644 index 6977eb02..00000000 --- a/gemfiles/rails4_2.gemfile +++ /dev/null @@ -1,7 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "rails", "~> 4.2.0" - -gemspec path: "../" diff --git a/gemfiles/rails5_0.gemfile b/gemfiles/rails5_0.gemfile deleted file mode 100644 index 10f52e7a..00000000 --- a/gemfiles/rails5_0.gemfile +++ /dev/null @@ -1,7 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "rails", "~> 5.0.0" - -gemspec path: "../" diff --git a/gemfiles/rails5_1.gemfile b/gemfiles/rails5_1.gemfile deleted file mode 100644 index 6100e830..00000000 --- a/gemfiles/rails5_1.gemfile +++ /dev/null @@ -1,7 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "rails", "~> 5.1.0" - -gemspec path: "../" diff --git a/gemfiles/rails4_0.gemfile b/gemfiles/rails6_1.gemfile similarity index 79% rename from gemfiles/rails4_0.gemfile rename to gemfiles/rails6_1.gemfile index 4f47847a..dd95a476 100644 --- a/gemfiles/rails4_0.gemfile +++ b/gemfiles/rails6_1.gemfile @@ -2,6 +2,6 @@ source "https://rubygems.org" -gem "rails", "~> 4.0.5" +gem "rails", "~> 6.1.0" gemspec path: "../" diff --git a/gemfiles/rails4_1.gemfile b/gemfiles/rails7_0.gemfile similarity index 79% rename from gemfiles/rails4_1.gemfile rename to gemfiles/rails7_0.gemfile index 7e4bd92e..9af0ae34 100644 --- a/gemfiles/rails4_1.gemfile +++ b/gemfiles/rails7_0.gemfile @@ -2,6 +2,6 @@ source "https://rubygems.org" -gem "rails", "~> 4.1.1" +gem "rails", "~> 7.0.0" gemspec path: "../" diff --git a/lib/exception_notifier/modules/error_grouping.rb b/lib/exception_notifier/modules/error_grouping.rb index 743fb02f..9ad0d066 100644 --- a/lib/exception_notifier/modules/error_grouping.rb +++ b/lib/exception_notifier/modules/error_grouping.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "active_support" +require 'active_support' require 'active_support/core_ext/numeric/time' require 'active_support/concern' diff --git a/lib/exception_notifier/modules/formatter.rb b/lib/exception_notifier/modules/formatter.rb index b4070421..e5e3c8db 100644 --- a/lib/exception_notifier/modules/formatter.rb +++ b/lib/exception_notifier/modules/formatter.rb @@ -111,7 +111,6 @@ def controller_and_action def rails_app_name return unless defined?(::Rails) && ::Rails.respond_to?(:application) - if Rails::VERSION::MAJOR >= 6 Rails.application.class.module_parent_name.underscore else diff --git a/test/exception_notifier/sns_notifier_test.rb b/test/exception_notifier/sns_notifier_test.rb index cc7767f0..648c8ecb 100644 --- a/test/exception_notifier/sns_notifier_test.rb +++ b/test/exception_notifier/sns_notifier_test.rb @@ -122,7 +122,7 @@ def setup 'REQUEST_METHOD' => 'GET', 'REQUEST_URI' => '/examples', 'action_controller.instance' => controller, - 'exception_notifier.exception_data' => {current_user: 12} + 'exception_notifier.exception_data' => { current_user: 12 } }) end test 'should put optional data into text' do @@ -146,12 +146,11 @@ def setup env: { 'REQUEST_METHOD' => 'GET', 'REQUEST_URI' => '/examples', - 'action_controller.instance' => controller, + 'action_controller.instance' => controller }, data: { current_user: 12 - } - ) + }) end private