From bf977486ed139a57958a8f0a79c3e30020f50983 Mon Sep 17 00:00:00 2001 From: Joe Haig Date: Sun, 1 Oct 2023 17:31:56 +0100 Subject: [PATCH 1/9] Start notes for the test refactor --- docs/test_refactor.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 docs/test_refactor.md diff --git a/docs/test_refactor.md b/docs/test_refactor.md new file mode 100644 index 0000000..c47735e --- /dev/null +++ b/docs/test_refactor.md @@ -0,0 +1,20 @@ +# Test refactor + +## Motivation + +This gem has been unmaintained for some time but is still used. This could +cause problems if it becomes incompatible with new versions of Active Record. +Additionally, there are lots of issues that have been raised and there could be +other features of Active Record that should be supported. However, the tests +not easy to understand as they generally comprise a large setup of data +followed by multiple expectations with no indication of their purpose. A better +structure for the tests would allow for making changes with more confidence. + +## Plan + +All of the tests are currently in `spec/lib/amoeba_spec.rb`. New tests will be +created to mimic the modules so, for example; + +* `spec/lib/amoeba/cloner_spec.rb` to test the `Amoeba::Cloner` class. +* `spec/lib/amoeba/macros/has_many_spec.rb` to test the + `Amoeba::Macros::HasMany` module. From c3bf5625ca4b043f86edf7f242c6151cf79fe134 Mon Sep 17 00:00:00 2001 From: Joe Haig Date: Sun, 1 Oct 2023 17:51:38 +0100 Subject: [PATCH 2/9] Set up Rubocop pipeline --- .github/workflows/rubocop.yml | 21 ++++++++ .rubocop.yml | 4 +- .rubocop_todo.yml | 99 ++++++++++++++++++++++++++--------- amoeba.gemspec | 6 +-- 4 files changed, 99 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/rubocop.yml diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml new file mode 100644 index 0000000..0e09876 --- /dev/null +++ b/.github/workflows/rubocop.yml @@ -0,0 +1,21 @@ +name: Rubocop + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +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 + bundler-cache: true + - name: Run Rubocop + run: bundle exec rubocop \ No newline at end of file diff --git a/.rubocop.yml b/.rubocop.yml index 7d79c5b..fb8e2ab 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -5,10 +5,10 @@ require: inherit_from: .rubocop_todo.yml AllCops: - TargetRubyVersion: 2.5 + TargetRubyVersion: 2.7 NewCops: enable Layout/LineLength: - Max: 99 + Max: 120 Naming/FileName: Enabled: false Style/ModuleFunction: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 173694e..0d5b89f 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,50 +1,70 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2021-07-10 17:38:28 UTC using RuboCop version 1.16.1. +# on 2023-10-02 15:42:47 UTC using RuboCop version 1.56.3. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 10 -# Cop supports --auto-correct. -# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. -# URISchemes: http, https -Layout/LineLength: - Max: 110 +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Severity, Include. +# Include: **/*.gemspec +Gemspec/DeprecatedAttributeAssignment: + Exclude: + - 'amoeba.gemspec' + +# Offense count: 7 +# Configuration parameters: EnforcedStyle, AllowedGems, Include. +# SupportedStyles: Gemfile, gems.rb, gemspec +# Include: **/*.gemspec, **/Gemfile, **/gems.rb +Gemspec/DevelopmentDependencies: + Exclude: + - 'amoeba.gemspec' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Severity, Include. +# Include: **/*.gemspec +Gemspec/RequireMFA: + Exclude: + - 'amoeba.gemspec' + +# Offense count: 1 +# Configuration parameters: Severity, Include. +# Include: **/*.gemspec +Gemspec/RequiredRubyVersion: + Exclude: + - 'amoeba.gemspec' # Offense count: 1 +# Configuration parameters: AllowedParentClasses. Lint/MissingSuper: Exclude: - 'lib/amoeba/macros/base.rb' # Offense count: 17 +# This cop supports unsafe autocorrection (--autocorrect-all). Lint/UselessAssignment: Exclude: - 'spec/support/data.rb' -# Offense count: 8 -# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. -# IgnoredMethods: refine -Metrics/BlockLength: - Max: 339 - # Offense count: 2 # Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: - Max: 141 + Max: 128 # Offense count: 3 # Configuration parameters: ForbiddenDelimiters. -# ForbiddenDelimiters: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$)) +# ForbiddenDelimiters: (?i-mx:(^|\s)(EO[A-Z]{1}|END)(\s|$)) Naming/HeredocDelimiterNaming: Exclude: - 'lib/amoeba/config.rb' # Offense count: 2 -# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers. +# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns. # SupportedStyles: snake_case, normalcase, non_integer -# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339 +# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64 Naming/VariableNumber: Exclude: - 'spec/support/data.rb' @@ -52,13 +72,13 @@ Naming/VariableNumber: # Offense count: 1 RSpec/BeforeAfterAll: Exclude: - - 'spec/spec_helper.rb' - - 'spec/rails_helper.rb' - - 'spec/support/**/*.rb' + - '**/spec/spec_helper.rb' + - '**/spec/rails_helper.rb' + - '**/spec/support/**/*.rb' - 'spec/lib/amoeba_spec.rb' # Offense count: 12 -# Configuration parameters: Prefixes. +# Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without RSpec/ContextWording: Exclude: @@ -68,6 +88,11 @@ RSpec/ContextWording: # Configuration parameters: IgnoredMetadata. RSpec/DescribeClass: Exclude: + - '**/spec/features/**/*' + - '**/spec/requests/**/*' + - '**/spec/routing/**/*' + - '**/spec/system/**/*' + - '**/spec/views/**/*' - 'spec/lib/amoeba_spec.rb' # Offense count: 3 @@ -86,33 +111,55 @@ RSpec/MultipleExpectations: Max: 55 # Offense count: 18 -# Configuration parameters: IgnoreSharedExamples. +# Configuration parameters: EnforcedStyle, IgnoreSharedExamples. +# SupportedStyles: always, named_only RSpec/NamedSubject: Exclude: - 'spec/lib/amoeba_spec.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Strict, EnforcedStyle, AllowedExplicitMatchers. # SupportedStyles: inflected, explicit RSpec/PredicateMatcher: Exclude: - 'spec/lib/amoeba_spec.rb' -# Offense count: 5 -# Cop supports --auto-correct. +# 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: + Exclude: + - 'spec/lib/amoeba_spec.rb' + - 'spec/spec_helper.rb' + - 'spec/support/models.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantRegexpArgument: + Exclude: + - 'spec/lib/amoeba_spec.rb' + # Offense count: 5 -# Cop supports --auto-correct. +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: Mode. Style/StringConcatenation: Exclude: - 'spec/lib/amoeba_spec.rb' diff --git a/amoeba.gemspec b/amoeba.gemspec index 4ccfc18..63fdd35 100644 --- a/amoeba.gemspec +++ b/amoeba.gemspec @@ -26,10 +26,10 @@ Gem::Specification.new do |s| s.require_paths = ['lib'] # specify any dependencies here; for example: - s.add_development_dependency 'rspec', '>= 3.0.0' - s.add_development_dependency 'rubocop', '~> 1.16' + s.add_development_dependency 'rspec', '~> 3.12' + s.add_development_dependency 'rubocop', '~> 1.56' s.add_development_dependency 'rubocop-rake', '~> 0.6' - s.add_development_dependency 'rubocop-rspec', '~> 2.4' + s.add_development_dependency 'rubocop-rspec', '~> 2.24' if RUBY_PLATFORM == 'java' s.add_development_dependency 'activerecord-jdbc-adapter', '~> 70.0' From 7637690f10648448cfecf308130dcb95ae55f21d Mon Sep 17 00:00:00 2001 From: Joe Haig Date: Fri, 17 Nov 2023 11:46:57 +0000 Subject: [PATCH 3/9] Remove sqlite3 from test gemfiles All supported versions of Active Record can now use sqlite3 version 1.6 so there is no need to explicitly set it in each gemfile. --- Appraisals | 16 ---------------- amoeba.gemspec | 2 +- gemfiles/activerecord_6.0.gemfile | 1 - gemfiles/activerecord_6.1.gemfile | 1 - gemfiles/activerecord_7.0.gemfile | 1 - gemfiles/activerecord_head.gemfile | 1 - gemfiles/jruby_activerecord_7.0.gemfile | 2 -- 7 files changed, 1 insertion(+), 23 deletions(-) diff --git a/Appraisals b/Appraisals index daeeb19..5704d6e 100644 --- a/Appraisals +++ b/Appraisals @@ -2,40 +2,24 @@ appraise 'activerecord-6.0' do gem 'activerecord', '~> 6.0.0' - group :development, :test do - gem 'sqlite3', '~> 1.6.0' - end end appraise 'activerecord-6.1' do gem 'activerecord', '~> 6.1.0' - group :development, :test do - gem 'sqlite3', '~> 1.6.0' - end end appraise 'activerecord-7.0' do gem 'activerecord', '~> 7.0.0' - group :development, :test do - gem 'sqlite3', '~> 1.6.0' - end end appraise 'jruby-activerecord-7.0' do gem 'activerecord', '~> 7.0.0' - group :development, :test do - gem 'activerecord-jdbc-adapter', '~> 70.1' - gem 'activerecord-jdbcsqlite3-adapter', '~> 70.1' - end end appraise 'activerecord-head' do git 'https://github.com/rails/rails.git', branch: 'main' do gem 'activerecord' end - group :development, :test do - gem 'sqlite3', '~> 1.6.0' - end end appraise 'jruby-activerecord-head' do diff --git a/amoeba.gemspec b/amoeba.gemspec index 63fdd35..54baecc 100644 --- a/amoeba.gemspec +++ b/amoeba.gemspec @@ -35,7 +35,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'activerecord-jdbc-adapter', '~> 70.0' s.add_development_dependency 'activerecord-jdbcsqlite3-adapter', '~> 70.0' else - s.add_development_dependency 'sqlite3', '~> 1.6' + s.add_development_dependency 'sqlite3', '~> 1.6.0' end s.add_dependency 'activerecord', '>= 6.0.0' diff --git a/gemfiles/activerecord_6.0.gemfile b/gemfiles/activerecord_6.0.gemfile index dc6d5d7..e01f253 100644 --- a/gemfiles/activerecord_6.0.gemfile +++ b/gemfiles/activerecord_6.0.gemfile @@ -8,7 +8,6 @@ group :development, :test do gem 'rake' gem 'simplecov', '~> 0.21.2' gem 'simplecov-lcov', '~> 0.8.0' - gem 'sqlite3', '~> 1.6.0' end group :local_development do diff --git a/gemfiles/activerecord_6.1.gemfile b/gemfiles/activerecord_6.1.gemfile index 53d1bc8..db41a08 100644 --- a/gemfiles/activerecord_6.1.gemfile +++ b/gemfiles/activerecord_6.1.gemfile @@ -8,7 +8,6 @@ group :development, :test do gem 'rake' gem 'simplecov', '~> 0.21.2' gem 'simplecov-lcov', '~> 0.8.0' - gem 'sqlite3', '~> 1.6.0' end group :local_development do diff --git a/gemfiles/activerecord_7.0.gemfile b/gemfiles/activerecord_7.0.gemfile index dcf3dbd..efd7ca8 100644 --- a/gemfiles/activerecord_7.0.gemfile +++ b/gemfiles/activerecord_7.0.gemfile @@ -8,7 +8,6 @@ group :development, :test do gem 'rake' gem 'simplecov', '~> 0.21.2' gem 'simplecov-lcov', '~> 0.8.0' - gem 'sqlite3', '~> 1.6.0' end group :local_development do diff --git a/gemfiles/activerecord_head.gemfile b/gemfiles/activerecord_head.gemfile index 6695831..2d935ca 100644 --- a/gemfiles/activerecord_head.gemfile +++ b/gemfiles/activerecord_head.gemfile @@ -10,7 +10,6 @@ group :development, :test do gem 'rake' gem 'simplecov', '~> 0.21.2' gem 'simplecov-lcov', '~> 0.8.0' - gem 'sqlite3', '~> 1.6.0' end group :local_development do diff --git a/gemfiles/jruby_activerecord_7.0.gemfile b/gemfiles/jruby_activerecord_7.0.gemfile index 7140487..efd7ca8 100644 --- a/gemfiles/jruby_activerecord_7.0.gemfile +++ b/gemfiles/jruby_activerecord_7.0.gemfile @@ -5,8 +5,6 @@ source 'https://rubygems.org' gem 'activerecord', '~> 7.0.0' group :development, :test do - gem 'activerecord-jdbc-adapter', '~> 70.1' - gem 'activerecord-jdbcsqlite3-adapter', '~> 70.1' gem 'rake' gem 'simplecov', '~> 0.21.2' gem 'simplecov-lcov', '~> 0.8.0' From 8c3d3e45cbcfdb44c5995b9662981835e45717cc Mon Sep 17 00:00:00 2001 From: Joe Haig Date: Thu, 28 Mar 2024 15:52:10 +0000 Subject: [PATCH 4/9] Change ordering to defined The 'default' option was changed to defined a long time ago. --- spec/spec_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8e3df44..ac71cfb 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -30,7 +30,7 @@ ActiveRecord::Base.establish_connection(adapter: adapter, database: ':memory:') ::RSpec.configure do |config| - config.order = :default + config.order = :defined end load File.dirname(__FILE__) + '/support/schema.rb' From cf44e2b377731119cfb8874e10d33cf93c4b9eaf Mon Sep 17 00:00:00 2001 From: Joe Haig Date: Thu, 28 Mar 2024 16:13:45 +0000 Subject: [PATCH 5/9] Restrict versions of development dependencies Minor updates of Rubocop and RSpec can cause unexpected failures in the pipeline that are not related to the changes that are being made. To avoid this updates are restricted to patch updates. --- amoeba.gemspec | 8 ++++---- lib/amoeba/cloner.rb | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/amoeba.gemspec b/amoeba.gemspec index 54baecc..cb8224e 100644 --- a/amoeba.gemspec +++ b/amoeba.gemspec @@ -26,10 +26,10 @@ Gem::Specification.new do |s| s.require_paths = ['lib'] # specify any dependencies here; for example: - s.add_development_dependency 'rspec', '~> 3.12' - s.add_development_dependency 'rubocop', '~> 1.56' - s.add_development_dependency 'rubocop-rake', '~> 0.6' - s.add_development_dependency 'rubocop-rspec', '~> 2.24' + s.add_development_dependency 'rspec', '~> 3.13.0' + s.add_development_dependency 'rubocop', '= 1.62.1' + s.add_development_dependency 'rubocop-rake', '~> 0.6.0' + s.add_development_dependency 'rubocop-rspec', '~> 2.27.1' if RUBY_PLATFORM == 'java' s.add_development_dependency 'activerecord-jdbc-adapter', '~> 70.0' diff --git a/lib/amoeba/cloner.rb b/lib/amoeba/cloner.rb index 064192d..35ee71b 100644 --- a/lib/amoeba/cloner.rb +++ b/lib/amoeba/cloner.rb @@ -52,7 +52,7 @@ def inherit_parent_settings return unless _parent_amoeba.inherit return unless %w[strict relaxed submissive].include?(parenting_style.to_s) - __send__("inherit_#{parenting_style}_parent_settings".to_sym) + __send__(:"inherit_#{parenting_style}_parent_settings") end def apply_clones From fcd10194054ca6ee4946ba96857b6445d0d8a94c Mon Sep 17 00:00:00 2001 From: Joe Haig Date: Thu, 28 Mar 2024 16:48:15 +0000 Subject: [PATCH 6/9] 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 | 8 ++--- 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_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 ++ 23 files changed, 74 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%) diff --git a/.github/workflows/activerecord_head.yml b/.github/workflows/activerecord_head.yml new file mode 100644 index 0000000..26f70a8 --- /dev/null +++ b/.github/workflows/activerecord_head.yml @@ -0,0 +1,30 @@ +name: Active Record 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..5f944f6 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 ] 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..6a1d29c 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,6 +8,10 @@ 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 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_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 From f32c545bc5c1c06588bcc1e613312a891418f933 Mon Sep 17 00:00:00 2001 From: Joe Haig Date: Mon, 1 Apr 2024 19:30:07 +0100 Subject: [PATCH 7/9] Add notes on contributing --- README.md | 4 ++++ docs/contributing.md | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 docs/contributing.md diff --git a/README.md b/README.md index c67485a..4a4d34b 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,10 @@ Easy cloning of active_record objects including associations and several operati [![Gem Version](https://badge.fury.io/rb/amoeba.svg)](http://badge.fury.io/rb/amoeba) [![Build Status](https://travis-ci.org/amoeba-rb/amoeba.svg?branch=master)](https://travis-ci.org/amoeba-rb/amoeba) +## Interested in contributing? + +See [here.](docs/contributing.md) + ## What? The goal was to be able to easily and quickly reproduce ActiveRecord objects including their children, for example copying a blog post maintaining its associated tags or categories. diff --git a/docs/contributing.md b/docs/contributing.md new file mode 100644 index 0000000..2a1305b --- /dev/null +++ b/docs/contributing.md @@ -0,0 +1,17 @@ +# Contributing to Amoeba + +Contributations to this project are welcome. The current needs are; + +* More structured documentation +* [Refactoring tests](test_refactor.md) +* Identifying and prioritising features that could be implemented from the long list of issues +* Reviewing of pull requests + +## Some notes regarding pull requests + +When making code changes please include unit tests for any new code and ensure that all tests pass for supported versions of Ruby and Active Record. These tests are run automatically. + +Note that the tests are also run automatically for the current development branches of Ruby and Active Record. It is not necessary for all tests to pass in these cases. However; + +* Please try at least for new tests in the PR to pass unless there is an identifiable issue in the development version of either Ruby or Active Record. +* For any new failures you see please consider raising an issue to have it fixed. \ No newline at end of file From 8a91618964c91652216fccda237855dd88d6d0b9 Mon Sep 17 00:00:00 2001 From: Joe Haig Date: Sat, 6 Apr 2024 09:27:56 +0100 Subject: [PATCH 8/9] Allow failure of tests with dev branches --- .github/workflows/activerecord_head.yml | 8 ++------ .github/workflows/ruby_head.yml | 9 +++------ docs/contributing.md | 6 ++++-- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/.github/workflows/activerecord_head.yml b/.github/workflows/activerecord_head.yml index 26f70a8..5e535d3 100644 --- a/.github/workflows/activerecord_head.yml +++ b/.github/workflows/activerecord_head.yml @@ -8,7 +8,6 @@ on: jobs: test: - runs-on: ubuntu-latest strategy: matrix: @@ -23,8 +22,5 @@ jobs: 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 }} + # Allow tests to run on Active Record head without failing the pipeline + run: bundle exec rspec || true diff --git a/.github/workflows/ruby_head.yml b/.github/workflows/ruby_head.yml index ffdbbc5..246ca8f 100644 --- a/.github/workflows/ruby_head.yml +++ b/.github/workflows/ruby_head.yml @@ -8,8 +8,8 @@ on: jobs: test: - runs-on: ubuntu-latest + continue-on-error: true strategy: matrix: gemfile: [ activerecord_6.1, activerecord_7.0, activerecord_7.1 ] @@ -23,8 +23,5 @@ jobs: ruby-version: head bundler-cache: true - name: Run tests - run: bundle exec rspec - - name: Coveralls - uses: coverallsapp/github-action@master - with: - github-token: ${{ secrets.GITHUB_TOKEN }} + # Allow tests to run on Ruby head without failing the pipeline + run: bundle exec rspec || true diff --git a/docs/contributing.md b/docs/contributing.md index 2a1305b..c87acaf 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -11,7 +11,9 @@ Contributations to this project are welcome. The current needs are; When making code changes please include unit tests for any new code and ensure that all tests pass for supported versions of Ruby and Active Record. These tests are run automatically. -Note that the tests are also run automatically for the current development branches of Ruby and Active Record. It is not necessary for all tests to pass in these cases. However; +Note that the tests are also run automatically for the current development branches of Ruby and Active Record. It is not necessary for all tests to pass in these cases and they are set up to always report as a success to avoid causing the whole pipeline to appear as failed[^1]. However; * Please try at least for new tests in the PR to pass unless there is an identifiable issue in the development version of either Ruby or Active Record. -* For any new failures you see please consider raising an issue to have it fixed. \ No newline at end of file +* For any new failures you see please consider raising an issue to have it fixed. + +[^1]: See [this issue](https://github.com/actions/runner/issues/2347) and [this discussion](https://github.com/orgs/community/discussions/15452) for a long-running discussion on the missing "allow failure" feature in Github Actions. \ No newline at end of file From d05c298e9975605969f2c22aa68a94a73d0d0478 Mon Sep 17 00:00:00 2001 From: Joe Haig Date: Fri, 21 Jun 2024 21:28:55 +0100 Subject: [PATCH 9/9] Update change log --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e037088..a41ca4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ ### Unreleased -* Drop support for Rails 5.2. -* Drop support for Ruby 2.5 and 2.6. +* Drop support for Rails 5.2, Ruby 2.5 and 2.6. [https://github.com/amoeba-rb/amoeba/pull/120] +* Notes on contributing. Github Actions for automate tests. [https://github.com/amoeba-rb/amoeba/pull/124] ### 3.3.0