Skip to content

Commit

Permalink
Update to latest source version 6.0 (#9)
Browse files Browse the repository at this point in the history
* bumping to 5.0.0

This includes support for Rails 5 and a better gem deployment mechanism

* Pushing tags on release

* testing automatic version tagging

* Fixing EOL issue

* Check If Record Has DeletedAt Column

## Context
Previously, when model with has_many association without `deleted_at` column will
raise "undefined method deleted_at=" error.

With this change, it will revert to original destroy behavior when the record
does not have `deleted_at` column.

* Update version support: Rails >= 5.2, Ruby >= 2.7.8

Also introduce appraisal for multi-version testing

* Fix rubocop offenses

* Restrict to Rails < 7, minimize active record patch

... by delegating to super so we don't have to copy more of active
record than necessary.

* Add rubocop-rake and rubocop-rspec, fix more warnings

Keep some warnings in rubocop todos for now, also disabled some
cops in rubocop config that would definitely mean lots of rewriting
... to be examinated later.

* Relax rails version constraint to include 7, add appraisals

* Bump version to 6.0.0

* Try to fix gempush GH workflow

Got error: "fatal: ambiguous argument 'HEAD..HEAD^': unknown revision
or path not in the working tree."

Also, make gempush-if-failed script fail on error.

* Bump version to 6.0.1

---------

Co-authored-by: Jack Danger <[email protected]>
Co-authored-by: Taufek Johar <[email protected]>
Co-authored-by: Luciano Maiwald <[email protected]>
Co-authored-by: Maximilian Herold <[email protected]>
  • Loading branch information
5 people authored Apr 12, 2024
1 parent 39583fe commit 49f124d
Show file tree
Hide file tree
Showing 46 changed files with 468 additions and 170 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/gempush.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,17 @@ jobs:

steps:
- uses: actions/checkout@master
- name: Set up Ruby 2.6
uses: actions/setup-ruby@v1
with:
ruby-version: 2.6.x
fetch-depth: 2
- name: Set up Ruby 2.7
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7.8

- name: Install bundle
run: bundle
- name: Run rubocop
run: bundle exec rubocop

- name: Publish to RubyGems
run: |
Expand All @@ -26,3 +33,4 @@ jobs:
bin/gempush-if-changed
env:
GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32 changes: 0 additions & 32 deletions .github/workflows/test.yml

This file was deleted.

57 changes: 57 additions & 0 deletions .github/workflows/test_and_lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Lint & Test

on: push

jobs:
test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
ruby:
- 2.7.8
- 3.0.6
- 3.1.4
- 3.2.3
appraisal:
- rails-5.2
- rails-6.0
- rails-6.1
- rails-7.0
- rails-7.1
exclude:
- ruby: 3.0.6
appraisal: rails-5.2
- ruby: 3.1.4
appraisal: rails-5.2
- ruby: 3.2.3
appraisal: rails-5.2
steps:
- name: Install system dependencies
run: sudo apt-get install -y libsqlite3-dev
- uses: actions/checkout@master
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- name: Install bundle
run: bundle
- name: Install appraisal
run: bundle exec appraisal install
- name: Run tests
run: bundle exec appraisal ${{ matrix.appraisal }} rspec
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Install system dependencies
run: sudo apt-get install -y libsqlite3-dev
- uses: actions/checkout@master
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7.8
- name: Install bundle
run: bundle
- name: Run rubocop
run: bundle exec rubocop
28 changes: 25 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,39 @@
require: rubocop-performance
require:
- rubocop-performance
- rubocop-rake
- rubocop-rspec

inherit_from: .rubocop_todo.yml

AllCops:
Exclude:
- bin/*
TargetRubyVersion: 2.2
- gemfiles/*
- vendor/bundle/**/*
NewCops: enable
TargetRubyVersion: 2.7

Gemspec/RequireMFA:
Exclude:
- 'permanent_records.gemspec'

Metrics/BlockLength:
Enabled: false

Metrics/LineLength:
Layout/LineLength:
Max: 120

RSpec/ContextWording:
Enabled: false

RSpec/MultipleExpectations:
Enabled: false

RSpec/MultipleMemoizedHelpers:
Enabled: false

RSpec/NestedGroups:
Enabled: false

Style/BlockDelimiters:
Enabled: false
60 changes: 59 additions & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,65 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2019-10-15 13:32:11 +0200 using RuboCop version 0.68.1.
# on 2024-03-26 14:12:23 UTC using RuboCop version 1.62.1.
# 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: 11
RSpec/AnyInstance:
Exclude:
- 'spec/permanent_records_spec.rb'

# Offense count: 3
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 22

# Offense count: 5
# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
# Include: **/*_spec*rb*, **/spec/**/*
RSpec/FilePath:
Exclude:
- 'spec/permanent_records/circular_sti_dependency_spec.rb'
- 'spec/permanent_records/counter_cache_spec.rb'
- 'spec/permanent_records/propagate_validation_flag_spec.rb'
- 'spec/permanent_records/revive_parent_first_spec.rb'
- 'spec/permanent_records/validate_presence_spec.rb'

# Offense count: 5
RSpec/LetSetup:
Exclude:
- 'spec/permanent_records/revive_parent_first_spec.rb'
- 'spec/permanent_records_spec.rb'

# Offense count: 1
# Configuration parameters: .
# SupportedStyles: have_received, receive
RSpec/MessageSpies:
EnforcedStyle: receive

# Offense count: 60
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
# SupportedStyles: always, named_only
RSpec/NamedSubject:
Exclude:
- 'spec/permanent_records_spec.rb'

# Offense count: 5
# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata.
# Include: **/*_spec.rb
RSpec/SpecFilePathFormat:
Exclude:
- '**/spec/routing/**/*'
- 'spec/permanent_records/circular_sti_dependency_spec.rb'
- 'spec/permanent_records/counter_cache_spec.rb'
- 'spec/permanent_records/propagate_validation_flag_spec.rb'
- 'spec/permanent_records/revive_parent_first_spec.rb'
- 'spec/permanent_records/validate_presence_spec.rb'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
Rake/Desc:
Exclude:
- 'Rakefile'
11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

21 changes: 21 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

appraise 'rails-5.2' do
gem 'rails', '5.2.8.1'
end

appraise 'rails-6.0' do
gem 'rails', '6.0.6.1'
end

appraise 'rails-6.1' do
gem 'rails', '6.1.7.7'
end

appraise 'rails-7.0' do
gem 'rails', '7.0.8.1'
end

appraise 'rails-7.1' do
gem 'rails', '7.1.3.2'
end
13 changes: 13 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gemspec

gem 'appraisal'
gem 'database_cleaner', '>= 1.5.1'
gem 'pry-byebug'
gem 'rake'
gem 'rspec', '>= 3.5.0'
gem 'rubocop'
gem 'rubocop-performance'
gem 'rubocop-rake'
gem 'rubocop-rspec'
gem 'sqlite3'
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# PermanentRecords (Rails 5)
# PermanentRecords

[http://github.com/JackDanger/permanent_records/](http://github.com/JackDanger/permanent_records/)

Expand Down
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'bundler'
require 'yaml'
require 'English'
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.2.8
6.0.1
8 changes: 8 additions & 0 deletions bin/gempush-if-changed
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
#!/bin/bash

set -x
set -euo pipefail
if git diff --name-only HEAD..HEAD^ | egrep -q '^VERSION$'; then
# The VERSION file changed in the last commit, build the gem and push
gem build *.gemspec
gem push *.gem

# We set the GITHUB_TOKEN variable from the repo's 'Secrets' admin panel.
git remote set-url --push origin https://JackDanger:${GITHUB_TOKEN}@github.com/JackDanger/permanent_records.git

version=$(cat VERSION)
git tag ${version}
git push origin ${version}
fi
7 changes: 0 additions & 7 deletions ci

This file was deleted.

1 change: 1 addition & 0 deletions gemfiles/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.gemfile.lock
17 changes: 17 additions & 0 deletions gemfiles/rails_5.2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "appraisal"
gem "database_cleaner", ">= 1.5.1"
gem "pry-byebug"
gem "rake"
gem "rspec", ">= 3.5.0"
gem "rubocop"
gem "rubocop-performance"
gem "rubocop-rake"
gem "rubocop-rspec"
gem "sqlite3"
gem "rails", "5.2.8.1"

gemspec path: "../"
17 changes: 17 additions & 0 deletions gemfiles/rails_6.0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "appraisal"
gem "database_cleaner", ">= 1.5.1"
gem "pry-byebug"
gem "rake"
gem "rspec", ">= 3.5.0"
gem "rubocop"
gem "rubocop-performance"
gem "rubocop-rake"
gem "rubocop-rspec"
gem "sqlite3"
gem "rails", "6.0.6.1"

gemspec path: "../"
17 changes: 17 additions & 0 deletions gemfiles/rails_6.1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "appraisal"
gem "database_cleaner", ">= 1.5.1"
gem "pry-byebug"
gem "rake"
gem "rspec", ">= 3.5.0"
gem "rubocop"
gem "rubocop-performance"
gem "rubocop-rake"
gem "rubocop-rspec"
gem "sqlite3"
gem "rails", "6.1.7.7"

gemspec path: "../"
17 changes: 17 additions & 0 deletions gemfiles/rails_7.0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "appraisal"
gem "database_cleaner", ">= 1.5.1"
gem "pry-byebug"
gem "rake"
gem "rspec", ">= 3.5.0"
gem "rubocop"
gem "rubocop-performance"
gem "rubocop-rake"
gem "rubocop-rspec"
gem "sqlite3"
gem "rails", "7.0.8.1"

gemspec path: "../"
Loading

0 comments on commit 49f124d

Please sign in to comment.