Skip to content

Commit

Permalink
Merge pull request #124 from jrmhaig/test_refactor_notes
Browse files Browse the repository at this point in the history
Prepare for refactoring tests
  • Loading branch information
jrmhaig authored Jun 29, 2024
2 parents 63d3ecb + d05c298 commit ca0ab62
Show file tree
Hide file tree
Showing 29 changed files with 206 additions and 87 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/activerecord_head.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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
# Allow tests to run on Active Record head without failing the pipeline
run: bundle exec rspec || true
5 changes: 4 additions & 1 deletion .github/workflows/jruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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.0
bundler-cache: true
- name: Run Rubocop
run: bundle exec rubocop
2 changes: 1 addition & 1 deletion .github/workflows/ruby_30.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ruby_31.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ruby_32.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Ruby 2.7
name: Ruby 3.3

on:
push:
Expand All @@ -12,15 +12,15 @@ 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:
- uses: actions/checkout@v4
- 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
Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/ruby_head.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ on:

jobs:
test:

runs-on: ubuntu-latest
continue-on-error: true
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:
Expand All @@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ coverage
.idea
gemfiles/*.lock
.ruby-version
tmp/**/*
4 changes: 2 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
91 changes: 60 additions & 31 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,64 +1,84 @@
# 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'

# 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:
Expand All @@ -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
Expand All @@ -86,33 +111,37 @@ 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.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, always_true, never
Style/FrozenStringLiteralComment:
# Offense count: 25
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantConstantBase:
Exclude:
- 'spec/lib/amoeba_spec.rb'
- 'spec/spec_helper.rb'
- 'spec/support/data.rb'
- 'spec/support/models.rb'
- 'spec/support/schema.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'
Expand Down
24 changes: 4 additions & 20 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,41 +1,25 @@
# frozen_string_literal: true

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 'activerecord-7.1' do
gem 'activerecord', '~> 7.1.0'
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
Expand Down
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading

0 comments on commit ca0ab62

Please sign in to comment.