Skip to content

Commit 26aebf9

Browse files
committed
fix CI workflows, add new rubies to test matrix
1 parent 368049d commit 26aebf9

20 files changed

+74
-26
lines changed

.github/workflows/checkstyle.yml

+8-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Rubocop
33
on:
44
push:
55
branches:
6-
- master
6+
- "*"
77

88
pull_request:
99
branches:
@@ -15,18 +15,20 @@ jobs:
1515

1616
steps:
1717
- name: Cancel previous runs
18-
uses: styfle/cancel-workflow-action@0.5.0
18+
uses: styfle/cancel-workflow-action@0.12.1
1919
with:
2020
access_token: ${{ github.token }}
2121

22-
- uses: actions/checkout@v2
22+
- uses: actions/checkout@v4
2323

2424
- name: Set up Ruby ${{ matrix.ruby-version }}
2525
uses: ruby/setup-ruby@v1
2626
with:
27-
ruby-version: 2.7
28-
bundler: 1
27+
ruby-version: 3.2
2928
bundler-cache: true
3029

30+
- name: Install rubocop
31+
run: gem install rubocop -v "~>1.63"
32+
3133
- name: Run rubocop
32-
run: bundle exec rubocop --parallel --fail-level R
34+
run: rubocop --parallel --fail-level R

.github/workflows/test.yml

+8-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Test
33
on:
44
push:
55
branches:
6-
- master
6+
- "*"
77

88
pull_request:
99
branches:
@@ -18,29 +18,30 @@ jobs:
1818
timeout-minutes: 15
1919

2020
strategy:
21+
fail-fast: false
2122
matrix:
22-
ruby-version: [2.3, 2.4, 2.5, 2.6, 2.7, 3.0]
23+
ruby-version: [2.3, 2.4, 2.5, 2.6, 2.7, 3.0, 3.1, 3.2, 3.3]
2324

2425
steps:
2526
- name: Cancel previous runs
26-
uses: styfle/cancel-workflow-action@0.5.0
27+
uses: styfle/cancel-workflow-action@0.12.1
2728
with:
2829
access_token: ${{ github.token }}
2930

30-
- uses: actions/checkout@v2
31+
- uses: actions/checkout@v4
3132

3233
- name: Set up Ruby ${{ matrix.ruby-version }}
3334
uses: ruby/setup-ruby@v1
3435
with:
3536
ruby-version: ${{ matrix.ruby-version }}
3637
bundler: 1
3738

38-
- uses: actions/cache@v2
39+
- uses: actions/cache@v4
3940
with:
4041
path: vendor/bundle
41-
key: ${{ runner.os }}-bundle-${{ matrix.ruby-version }}-v2-${{ hashFiles('rails-data-migrations.gemspec', 'Appraisals') }}
42+
key: ${{ runner.os }}-bundle-${{ matrix.ruby-version }}-v3-${{ hashFiles('rails-data-migrations.gemspec', 'Appraisals') }}
4243
restore-keys: |
43-
${{ runner.os }}-bundle-${{ matrix.ruby-version }}-v2-
44+
${{ runner.os }}-bundle-${{ matrix.ruby-version }}-v3-
4445
4546
- name: Install dependencies
4647
run: |

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@
1010
/.idea/
1111
spec/db/
1212
gemfiles/
13+
vendor/
1314
*.gem

.rubocop.yml

+12-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@ AllCops:
22
Exclude:
33
- 'vendor/**/*'
44
- 'gemfiles/**/*'
5+
TargetRubyVersion: 2.7
56

6-
Layout/TrailingBlankLines:
7+
Gemspec/RequiredRubyVersion:
8+
Enabled: false
9+
10+
Layout/TrailingEmptyLines:
711
Enabled: false
812

913
Metrics/BlockLength:
@@ -12,8 +16,15 @@ Metrics/BlockLength:
1216
Metrics/LineLength:
1317
Max: 120
1418

19+
Naming/FileName:
20+
Exclude:
21+
- lib/rails-data-migrations.rb
22+
1523
Style/Documentation:
1624
Enabled: false
1725

26+
Style/HashSyntax:
27+
Enabled: false
28+
1829
Style/NumericLiterals:
1930
Enabled: false

Appraisals

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
ruby_version = Gem::Version.new(RUBY_VERSION)
24

35
if ruby_version < Gem::Version.new('2.7.0')
@@ -18,19 +20,23 @@ if ruby_version < Gem::Version.new('3.0.0')
1820

1921
appraise 'rails-5.1' do
2022
gem 'rails', '~> 5.1.0'
23+
gem 'sqlite3', '~> 1.3.6'
2124
end
2225

2326
appraise 'rails-5.2' do
2427
gem 'rails', '~> 5.2.0'
28+
gem 'sqlite3', '~> 1.3.6'
2529
end
2630
end
2731

2832
if ruby_version >= Gem::Version.new('2.5.0')
2933
appraise 'rails-6.0' do
3034
gem 'rails', '~> 6.0.0'
35+
gem 'sqlite3', '~> 1.4.0'
3136
end
3237

3338
appraise 'rails-6.1' do
3439
gem 'rails', '~> 6.1.0'
40+
gem 'sqlite3', '~> 1.4.0'
3541
end
3642
end

Gemfile

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
source 'https://rubygems.org'
24

35
# Specify your gem's dependencies in activerecord-data-migrations.gemspec

Rakefile

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'bundler/gem_tasks'
24
require 'rspec/core/rake_task'
35

lib/active_record/data_migration.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'rails/version'
24

35
module ActiveRecord

lib/generators/data_migration_generator.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
# frozen_string_literal: true
2+
13
require 'rails/generators'
24
require 'rails-data-migrations'
35

46
class DataMigrationGenerator < Rails::Generators::NamedBase
5-
source_root File.expand_path('../templates', __FILE__)
7+
source_root File.expand_path('templates', __dir__)
68

79
def create_migration_file
810
migration_file_name =

lib/generators/templates/data_migration_generator.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
class ClassName < ActiveRecord::DataMigration
24
def up
35
# put your code here

lib/rails-data-migrations.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# rubocop:disable Naming/FileName
1+
# frozen_string_literal: true
2+
23
require 'rails'
34
require 'active_record'
45
require 'active_record/data_migration'
56
require 'rails_data_migrations/version'
67
require 'rails_data_migrations/log_entry'
78
require 'rails_data_migrations/migrator'
89
require 'rails_data_migrations/railtie'
9-
# rubocop:enable Naming/FileName

lib/rails_data_migrations/log_entry.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
# frozen_string_literal: true
2+
13
module RailsDataMigrations
24
class LogEntry < ::ActiveRecord::SchemaMigration
35
class << self
46
def table_name
5-
ActiveRecord::Base.table_name_prefix + 'data_migrations' + ActiveRecord::Base.table_name_suffix
7+
"#{ActiveRecord::Base.table_name_prefix}data_migrations#{ActiveRecord::Base.table_name_suffix}"
68
end
79

810
def index_name

lib/rails_data_migrations/migrator.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module RailsDataMigrations
24
class Migrator < ::ActiveRecord::Migrator
35
MIGRATOR_SALT = 2053462855
@@ -61,7 +63,7 @@ def list_pending_migrations
6163
already_migrated = get_all_versions
6264
list_migrations.reject { |m| already_migrated.include?(m.version) }
6365
else
64-
open(migrations_path).pending_migrations
66+
open(migrations_path).pending_migrations # rubocop:disable Security/Open
6567
end
6668
end
6769

lib/rails_data_migrations/railtie.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'rails'
24

35
module RailsDataMigrations

lib/rails_data_migrations/version.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module RailsDataMigrations
2-
VERSION = '1.2.0'.freeze
4+
VERSION = '1.2.0'
35
end

lib/tasks/data_migrations.rake

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
# frozen_string_literal: true
2+
13
require 'rake'
24

35
namespace :data do
46
def apply_single_migration(direction, version)
57
raise 'VERSION is required' unless version
8+
69
RailsDataMigrations::Migrator.run_migration(
710
direction,
811
RailsDataMigrations::Migrator.migrations_path,
@@ -42,7 +45,8 @@ namespace :data do
4245
desc 'Skip single data migration using VERSION'
4346
task skip: :init_migration do
4447
version = ENV['VERSION'].to_i
45-
raise 'VERSION is required' unless version > 0
48+
raise 'VERSION is required' unless version.positive?
49+
4650
if RailsDataMigrations::LogEntry.where(version: version).any?
4751
puts "data migration #{version} was already applied."
4852
else

rails-data-migrations.gemspec

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
lib = File.expand_path('../lib', __FILE__)
1+
# frozen_string_literal: true
2+
3+
lib = File.expand_path('lib', __dir__)
24
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
35
require 'rails_data_migrations/version'
46

@@ -17,12 +19,11 @@ Gem::Specification.new do |spec|
1719
end
1820
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
1921
spec.require_paths = ['lib']
22+
spec.required_ruby_version = '>= 2.3'
2023

2124
spec.add_runtime_dependency 'rails', '>= 4.0.0'
2225

2326
spec.add_development_dependency 'appraisal', '~> 2.1'
2427
spec.add_development_dependency 'rake', '>= 12.3.3'
2528
spec.add_development_dependency 'rspec', '3.5.0'
26-
spec.add_development_dependency 'rubocop', '0.52.1'
27-
spec.add_development_dependency 'sqlite3', '~> 1.3'
2829
end

spec/data_migrations_spec.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'spec_helper'
24

35
describe RailsDataMigrations do
@@ -44,7 +46,7 @@
4446
end
4547

4648
def load_rake_rasks
47-
load File.expand_path('../../lib/tasks/data_migrations.rake', __FILE__)
49+
load File.expand_path('../lib/tasks/data_migrations.rake', __dir__)
4850
Rake::Task.define_task(:environment)
4951
end
5052

spec/generators/data_migration_generator_spec.rb

Whitespace-only changes.

spec/spec_helper.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
# frozen_string_literal: true
2+
13
require 'rails/generators'
24
require 'rake'
35

4-
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
6+
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)
57
require 'rails-data-migrations'
68

79
ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:'

0 commit comments

Comments
 (0)