From 789e8fe1706da9c0e0c04aaa338afa7eb867e007 Mon Sep 17 00:00:00 2001 From: bivanalhar Date: Thu, 27 Jun 2024 15:42:56 +0800 Subject: [PATCH] chore(test): setup test - modify rails and rspec version - support ruby 3.0 --- .github/workflows/ruby.yml | 43 ++++++++++++++++++++++++++++++++++++++ .gitignore | 1 + .travis.yml | 5 ----- Appraisals | 19 +++++++++++++++++ gemfiles/rails_6.0.gemfile | 9 ++++++++ gemfiles/rails_6.1.gemfile | 9 ++++++++ gemfiles/rails_7.0.gemfile | 9 ++++++++ gemfiles/rails_7.1.gemfile | 9 ++++++++ settings_on_rails.gemspec | 4 ++-- spec/spec_helper.rb | 5 +++++ 10 files changed, 106 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/ruby.yml delete mode 100644 .travis.yml create mode 100644 Appraisals create mode 100644 gemfiles/rails_6.0.gemfile create mode 100644 gemfiles/rails_6.1.gemfile create mode 100644 gemfiles/rails_7.0.gemfile create mode 100644 gemfiles/rails_7.1.gemfile diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml new file mode 100644 index 0000000..df7a5a0 --- /dev/null +++ b/.github/workflows/ruby.yml @@ -0,0 +1,43 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake +# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby + +name: Ruby + +on: + push: + branches: + - master + pull_request: + branches: + - master + schedule: + - cron: '0 0 * * 0' + +permissions: + contents: read + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + ruby-version: ['3.0', '3.1', '3.2'] + activerecord: ['6.0', '6.1', '7.0', '7.1'] + env: + BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails_${{ matrix.activerecord }}.gemfile + steps: + - uses: actions/checkout@v3 + - name: Set up Ruby + # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby, + # change this to (see https://github.com/ruby/setup-ruby#versioning): + # uses: ruby/setup-ruby@v1 + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + - name: Run tests + run: bundle exec rake diff --git a/.gitignore b/.gitignore index b1438e1..fc3df16 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ /spec/reports/ /tmp/ /.ruby-version +gemfiles/*.lock diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 06e83f7..0000000 --- a/.travis.yml +++ /dev/null @@ -1,5 +0,0 @@ -language: ruby -rvm: - - 1.9.3 - - 2.1.0 - - 2.2.1 diff --git a/Appraisals b/Appraisals new file mode 100644 index 0000000..61afd00 --- /dev/null +++ b/Appraisals @@ -0,0 +1,19 @@ +appraise "rails-6.0" do + gem 'rails', '6.0.6.1' + gem 'rspec-rails', '~> 5' +end + +appraise "rails-6.1" do + gem 'rails', '~> 6.1' + gem 'rspec-rails', '>= 6' +end + +appraise "rails-7.0" do + gem 'rails', '7.0.8.4' + gem 'rspec-rails', '>= 6' +end + +appraise "rails-7.1" do + gem 'rails', '~> 7.1' + gem 'rspec-rails', '>= 6' +end diff --git a/gemfiles/rails_6.0.gemfile b/gemfiles/rails_6.0.gemfile new file mode 100644 index 0000000..1d0e7f9 --- /dev/null +++ b/gemfiles/rails_6.0.gemfile @@ -0,0 +1,9 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "coveralls_reborn", require: false +gem "rails", "6.0.6.1" +gem "rspec-rails", "~> 5" + +gemspec path: "../" diff --git a/gemfiles/rails_6.1.gemfile b/gemfiles/rails_6.1.gemfile new file mode 100644 index 0000000..6c0ea1e --- /dev/null +++ b/gemfiles/rails_6.1.gemfile @@ -0,0 +1,9 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "coveralls_reborn", require: false +gem "rails", "~> 6.1" +gem "rspec-rails", ">= 6" + +gemspec path: "../" diff --git a/gemfiles/rails_7.0.gemfile b/gemfiles/rails_7.0.gemfile new file mode 100644 index 0000000..72ad08f --- /dev/null +++ b/gemfiles/rails_7.0.gemfile @@ -0,0 +1,9 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "coveralls_reborn", require: false +gem "rails", "7.0.8.4" +gem "rspec-rails", ">= 6" + +gemspec path: "../" diff --git a/gemfiles/rails_7.1.gemfile b/gemfiles/rails_7.1.gemfile new file mode 100644 index 0000000..bdfb589 --- /dev/null +++ b/gemfiles/rails_7.1.gemfile @@ -0,0 +1,9 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "coveralls_reborn", require: false +gem "rails", "~> 7.1" +gem "rspec-rails", ">= 6" + +gemspec path: "../" diff --git a/settings_on_rails.gemspec b/settings_on_rails.gemspec index ad1103a..0dba0c9 100644 --- a/settings_on_rails.gemspec +++ b/settings_on_rails.gemspec @@ -19,11 +19,11 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.required_ruby_version = '>= 3.1.0' + spec.required_ruby_version = '>= 3' spec.add_dependency 'rails', '>= 6' spec.add_development_dependency 'sqlite3', '~> 1.7' spec.add_development_dependency 'bundler', '>= 1.6' - spec.add_development_dependency 'rspec-rails', '~> 3.3' + spec.add_development_dependency "appraisal", "~> 2.1" spec.add_development_dependency 'rake' end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ffa1fc5..cfe17a9 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -8,3 +8,8 @@ config.order = :random end +if ActiveRecord.version > Gem::Version.new('6.2') + ActiveRecord.use_yaml_unsafe_load = true +else + ActiveRecord::Base.use_yaml_unsafe_load = true +end