From f1777abb2a0ab07aaec16df0e9aa19804b19ee68 Mon Sep 17 00:00:00 2001 From: Joe Haig Date: Thu, 28 Mar 2024 16:48:15 +0000 Subject: [PATCH] Update activerecord and ruby versions to test Tests for the unreleased version of Active Record are now in a separate file so that a failure does not cancell other tests. Really, Github Actions should have an 'allow failure' option. --- .github/workflows/activerecord_head.yml | 30 +++++++++++++++++++ .github/workflows/jruby.yml | 5 +++- .github/workflows/rubocop.yml | 3 +- .github/workflows/ruby_30.yml | 2 +- .github/workflows/ruby_31.yml | 2 +- .github/workflows/ruby_32.yml | 2 +- .../workflows/{ruby_27.yml => ruby_33.yml} | 6 ++-- .github/workflows/ruby_head.yml | 2 +- .gitignore | 1 + .rubocop_todo.yml | 18 ----------- Appraisals | 12 +++++--- amoeba.gemspec | 6 ++-- gemfiles/activerecord_6.1.gemfile | 2 ++ gemfiles/activerecord_7.0.gemfile | 2 ++ ...d_6.0.gemfile => activerecord_7.1.gemfile} | 4 ++- gemfiles/activerecord_head.gemfile | 2 ++ gemfiles/jruby_activerecord_7.0.gemfile | 2 ++ gemfiles/jruby_activerecord_7.1.gemfile | 20 +++++++++++++ gemfiles/jruby_activerecord_head.gemfile | 2 ++ spec/lib/amoeba_spec.rb | 2 ++ spec/spec_helper.rb | 2 ++ spec/support/data.rb | 2 ++ spec/support/models.rb | 4 ++- spec/support/schema.rb | 2 ++ 24 files changed, 98 insertions(+), 37 deletions(-) create mode 100644 .github/workflows/activerecord_head.yml rename .github/workflows/{ruby_27.yml => ruby_33.yml} (80%) rename gemfiles/{activerecord_6.0.gemfile => activerecord_7.1.gemfile} (81%) create mode 100644 gemfiles/jruby_activerecord_7.1.gemfile diff --git a/.github/workflows/activerecord_head.yml b/.github/workflows/activerecord_head.yml new file mode 100644 index 0000000..d6538cf --- /dev/null +++ b/.github/workflows/activerecord_head.yml @@ -0,0 +1,30 @@ +name: Ruby head + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + test: + + runs-on: ubuntu-latest + strategy: + matrix: + ruby_version: [ 3.0, 3.1, 3.2, 3.3, head ] + env: + BUNDLE_GEMFILE: gemfiles/activerecord_head.gemfile + steps: + - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby_version }} + bundler-cache: true + - name: Run tests + run: bundle exec rspec + - name: Coveralls + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/jruby.yml b/.github/workflows/jruby.yml index b6dfe60..11288ad 100644 --- a/.github/workflows/jruby.yml +++ b/.github/workflows/jruby.yml @@ -9,8 +9,11 @@ on: jobs: test: runs-on: ubuntu-latest + strategy: + matrix: + gemfile: [ jruby_activerecord_7.0, jruby_activerecord_7.1 ] env: - BUNDLE_GEMFILE: gemfiles/jruby_activerecord_7.0.gemfile + BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile JRUBY_OPTS: --debug steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml index 0e09876..c25715f 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/rubocop.yml @@ -8,14 +8,13 @@ on: jobs: test: - runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: 3.2 + ruby-version: 3.0 bundler-cache: true - name: Run Rubocop run: bundle exec rubocop \ No newline at end of file diff --git a/.github/workflows/ruby_30.yml b/.github/workflows/ruby_30.yml index 4c04a1f..d275efd 100644 --- a/.github/workflows/ruby_30.yml +++ b/.github/workflows/ruby_30.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - gemfile: [ activerecord_6.0, activerecord_6.1, activerecord_7.0, activerecord_head ] + gemfile: [ activerecord_6.1, activerecord_7.0, activerecord_7.1 ] env: BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile steps: diff --git a/.github/workflows/ruby_31.yml b/.github/workflows/ruby_31.yml index 8414ac0..f1051ea 100644 --- a/.github/workflows/ruby_31.yml +++ b/.github/workflows/ruby_31.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - gemfile: [ activerecord_6.0, activerecord_6.1, activerecord_7.0, activerecord_head ] + gemfile: [ activerecord_6.1, activerecord_7.0, activerecord_7.1 ] env: BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile steps: diff --git a/.github/workflows/ruby_32.yml b/.github/workflows/ruby_32.yml index 5e2ebb7..90492ac 100644 --- a/.github/workflows/ruby_32.yml +++ b/.github/workflows/ruby_32.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - gemfile: [ activerecord_6.0, activerecord_6.1, activerecord_7.0, activerecord_head ] + gemfile: [ activerecord_6.1, activerecord_7.0, activerecord_7.1 ] env: BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile steps: diff --git a/.github/workflows/ruby_27.yml b/.github/workflows/ruby_33.yml similarity index 80% rename from .github/workflows/ruby_27.yml rename to .github/workflows/ruby_33.yml index f7ab526..24ec0b3 100644 --- a/.github/workflows/ruby_27.yml +++ b/.github/workflows/ruby_33.yml @@ -1,4 +1,4 @@ -name: Ruby 2.7 +name: Ruby 3.3 on: push: @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - gemfile: [ activerecord_6.0, activerecord_6.1, activerecord_7.0, activerecord_head ] + gemfile: [ activerecord_6.1, activerecord_7.0, activerecord_7.1 ] env: BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile steps: @@ -20,7 +20,7 @@ jobs: - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: 2.7 + ruby-version: 3.3 bundler-cache: true - name: Run tests run: bundle exec rspec diff --git a/.github/workflows/ruby_head.yml b/.github/workflows/ruby_head.yml index 8e86586..ffdbbc5 100644 --- a/.github/workflows/ruby_head.yml +++ b/.github/workflows/ruby_head.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - gemfile: [ activerecord_6.0, activerecord_6.1, activerecord_7.0, activerecord_head ] + gemfile: [ activerecord_6.1, activerecord_7.0, activerecord_7.1 ] env: BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile steps: diff --git a/.gitignore b/.gitignore index ca0f13a..09fd559 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ coverage .idea gemfiles/*.lock .ruby-version +tmp/**/* diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0d5b89f..d2d1027 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -125,24 +125,6 @@ RSpec/PredicateMatcher: Exclude: - 'spec/lib/amoeba_spec.rb' -# Offense count: 11 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: always, always_true, never -Style/FrozenStringLiteralComment: - Exclude: - - 'gemfiles/activerecord_6.0.gemfile' - - 'gemfiles/activerecord_6.1.gemfile' - - 'gemfiles/activerecord_7.0.gemfile' - - 'gemfiles/activerecord_head.gemfile' - - 'gemfiles/jruby_activerecord_7.0.gemfile' - - 'gemfiles/jruby_activerecord_head.gemfile' - - 'spec/lib/amoeba_spec.rb' - - 'spec/spec_helper.rb' - - 'spec/support/data.rb' - - 'spec/support/models.rb' - - 'spec/support/schema.rb' - # Offense count: 25 # This cop supports safe autocorrection (--autocorrect). Style/RedundantConstantBase: diff --git a/Appraisals b/Appraisals index 5704d6e..32a114a 100644 --- a/Appraisals +++ b/Appraisals @@ -1,9 +1,5 @@ # frozen_string_literal: true -appraise 'activerecord-6.0' do - gem 'activerecord', '~> 6.0.0' -end - appraise 'activerecord-6.1' do gem 'activerecord', '~> 6.1.0' end @@ -12,10 +8,18 @@ appraise 'activerecord-7.0' do gem 'activerecord', '~> 7.0.0' end +appraise 'activerecord-7.1' do + gem 'activerecord', '~> 7.1.0' +end + appraise 'jruby-activerecord-7.0' do gem 'activerecord', '~> 7.0.0' end +appraise 'jruby-activerecord-7.1' do + gem 'activerecord', '~> 7.1.0' +end + appraise 'activerecord-head' do git 'https://github.com/rails/rails.git', branch: 'main' do gem 'activerecord' diff --git a/amoeba.gemspec b/amoeba.gemspec index cb8224e..569d145 100644 --- a/amoeba.gemspec +++ b/amoeba.gemspec @@ -32,11 +32,11 @@ Gem::Specification.new do |s| s.add_development_dependency 'rubocop-rspec', '~> 2.27.1' if RUBY_PLATFORM == 'java' - s.add_development_dependency 'activerecord-jdbc-adapter', '~> 70.0' - s.add_development_dependency 'activerecord-jdbcsqlite3-adapter', '~> 70.0' + s.add_development_dependency 'activerecord-jdbc-adapter', '= 70.1' + s.add_development_dependency 'activerecord-jdbcsqlite3-adapter', '= 70.1' else s.add_development_dependency 'sqlite3', '~> 1.6.0' end - s.add_dependency 'activerecord', '>= 6.0.0' + s.add_dependency 'activerecord', '>= 6.1.0' end diff --git a/gemfiles/activerecord_6.1.gemfile b/gemfiles/activerecord_6.1.gemfile index db41a08..ba9c07b 100644 --- a/gemfiles/activerecord_6.1.gemfile +++ b/gemfiles/activerecord_6.1.gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file was generated by Appraisal source 'https://rubygems.org' diff --git a/gemfiles/activerecord_7.0.gemfile b/gemfiles/activerecord_7.0.gemfile index efd7ca8..3fd7f6b 100644 --- a/gemfiles/activerecord_7.0.gemfile +++ b/gemfiles/activerecord_7.0.gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file was generated by Appraisal source 'https://rubygems.org' diff --git a/gemfiles/activerecord_6.0.gemfile b/gemfiles/activerecord_7.1.gemfile similarity index 81% rename from gemfiles/activerecord_6.0.gemfile rename to gemfiles/activerecord_7.1.gemfile index e01f253..2f3f359 100644 --- a/gemfiles/activerecord_6.0.gemfile +++ b/gemfiles/activerecord_7.1.gemfile @@ -1,8 +1,10 @@ +# frozen_string_literal: true + # This file was generated by Appraisal source 'https://rubygems.org' -gem 'activerecord', '~> 6.0.0' +gem 'activerecord', '~> 7.1.0' group :development, :test do gem 'rake' diff --git a/gemfiles/activerecord_head.gemfile b/gemfiles/activerecord_head.gemfile index 2d935ca..eeb6dd0 100644 --- a/gemfiles/activerecord_head.gemfile +++ b/gemfiles/activerecord_head.gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file was generated by Appraisal source 'https://rubygems.org' diff --git a/gemfiles/jruby_activerecord_7.0.gemfile b/gemfiles/jruby_activerecord_7.0.gemfile index efd7ca8..3fd7f6b 100644 --- a/gemfiles/jruby_activerecord_7.0.gemfile +++ b/gemfiles/jruby_activerecord_7.0.gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file was generated by Appraisal source 'https://rubygems.org' diff --git a/gemfiles/jruby_activerecord_7.1.gemfile b/gemfiles/jruby_activerecord_7.1.gemfile new file mode 100644 index 0000000..2f3f359 --- /dev/null +++ b/gemfiles/jruby_activerecord_7.1.gemfile @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +# This file was generated by Appraisal + +source 'https://rubygems.org' + +gem 'activerecord', '~> 7.1.0' + +group :development, :test do + gem 'rake' + gem 'simplecov', '~> 0.21.2' + gem 'simplecov-lcov', '~> 0.8.0' +end + +group :local_development do + gem 'appraisal' + gem 'pry' +end + +gemspec path: '../' diff --git a/gemfiles/jruby_activerecord_head.gemfile b/gemfiles/jruby_activerecord_head.gemfile index 5c72a6f..e15da7a 100644 --- a/gemfiles/jruby_activerecord_head.gemfile +++ b/gemfiles/jruby_activerecord_head.gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file was generated by Appraisal source 'https://rubygems.org' diff --git a/spec/lib/amoeba_spec.rb b/spec/lib/amoeba_spec.rb index 97c71c3..0a9141c 100644 --- a/spec/lib/amoeba_spec.rb +++ b/spec/lib/amoeba_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'amoeba' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ac71cfb..a476ea0 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'simplecov' SimpleCov.start do diff --git a/spec/support/data.rb b/spec/support/data.rb index 73ae6ce..e1a9bd2 100644 --- a/spec/support/data.rb +++ b/spec/support/data.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + u1 = User.create(name: 'Robert Johnson', email: 'bob@crossroads.com') u2 = User.create(name: 'Miles Davis', email: 'miles@kindofblue.com') diff --git a/spec/support/models.rb b/spec/support/models.rb index fa1fcc9..b624c6d 100644 --- a/spec/support/models.rb +++ b/spec/support/models.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Topic < ActiveRecord::Base has_many :posts end @@ -202,7 +204,7 @@ class Product < ActiveRecord::Base has_many :images has_and_belongs_to_many :sections - SECTION_COUNT_QUERY = 'SELECT COUNT(*) AS section_count FROM products_sections WHERE product_id = ?'.freeze + SECTION_COUNT_QUERY = 'SELECT COUNT(*) AS section_count FROM products_sections WHERE product_id = ?' amoeba do enable diff --git a/spec/support/schema.rb b/spec/support/schema.rb index 4c07d9d..3a1d402 100644 --- a/spec/support/schema.rb +++ b/spec/support/schema.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + ActiveRecord::Schema.define do self.verbose = false