diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 41f9fb2..04db846 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,12 +11,15 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby-version: ["3.0", "3.1", "3.2"] + ruby-version: ["3.1", "3.2"] gemfile: - Gemfile - - test/ci/rails61.gemfile - - test/ci/rails70.gemfile - test/ci/rails71.gemfile + exclude: + # Exclude Ruby 3.0 since it isn't supported with rails 7.2 + - ruby-version: "3.1" + gemfile: Gemfile + env: ROOT_BUNDLE_PATH: ${{ github.workspace }}/vendor/bundle BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gemfile }} diff --git a/.gitignore b/.gitignore index a1c29be..d38e291 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ test/ci/*.gemfile.lock .rvmrc .ruby-version .byebug_history +.idea diff --git a/Gemfile.lock b/Gemfile.lock index 5f986e2..146d7a7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,103 +3,101 @@ PATH specs: wagons (0.8.0) bundler (>= 2.0) + concurrent-ruby (< 1.3.5) rails (>= 6.1) seed-fu-ndo (>= 0.0.3) GEM remote: https://rubygems.org/ specs: - actioncable (7.1.3.4) - actionpack (= 7.1.3.4) - activesupport (= 7.1.3.4) + actioncable (7.2.0) + actionpack (= 7.2.0) + activesupport (= 7.2.0) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.1.3.4) - actionpack (= 7.1.3.4) - activejob (= 7.1.3.4) - activerecord (= 7.1.3.4) - activestorage (= 7.1.3.4) - activesupport (= 7.1.3.4) - mail (>= 2.7.1) - net-imap - net-pop - net-smtp - actionmailer (7.1.3.4) - actionpack (= 7.1.3.4) - actionview (= 7.1.3.4) - activejob (= 7.1.3.4) - activesupport (= 7.1.3.4) - mail (~> 2.5, >= 2.5.4) - net-imap - net-pop - net-smtp + actionmailbox (7.2.0) + actionpack (= 7.2.0) + activejob (= 7.2.0) + activerecord (= 7.2.0) + activestorage (= 7.2.0) + activesupport (= 7.2.0) + mail (>= 2.8.0) + actionmailer (7.2.0) + actionpack (= 7.2.0) + actionview (= 7.2.0) + activejob (= 7.2.0) + activesupport (= 7.2.0) + mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (7.1.3.4) - actionview (= 7.1.3.4) - activesupport (= 7.1.3.4) + actionpack (7.2.0) + actionview (= 7.2.0) + activesupport (= 7.2.0) nokogiri (>= 1.8.5) racc - rack (>= 2.2.4) + rack (>= 2.2.4, < 3.2) rack-session (>= 1.0.1) rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - actiontext (7.1.3.4) - actionpack (= 7.1.3.4) - activerecord (= 7.1.3.4) - activestorage (= 7.1.3.4) - activesupport (= 7.1.3.4) + useragent (~> 0.16) + actiontext (7.2.0) + actionpack (= 7.2.0) + activerecord (= 7.2.0) + activestorage (= 7.2.0) + activesupport (= 7.2.0) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.1.3.4) - activesupport (= 7.1.3.4) + actionview (7.2.0) + activesupport (= 7.2.0) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (7.1.3.4) - activesupport (= 7.1.3.4) + activejob (7.2.0) + activesupport (= 7.2.0) globalid (>= 0.3.6) - activemodel (7.1.3.4) - activesupport (= 7.1.3.4) - activerecord (7.1.3.4) - activemodel (= 7.1.3.4) - activesupport (= 7.1.3.4) + activemodel (7.2.0) + activesupport (= 7.2.0) + activerecord (7.2.0) + activemodel (= 7.2.0) + activesupport (= 7.2.0) timeout (>= 0.4.0) - activestorage (7.1.3.4) - actionpack (= 7.1.3.4) - activejob (= 7.1.3.4) - activerecord (= 7.1.3.4) - activesupport (= 7.1.3.4) + activestorage (7.2.0) + actionpack (= 7.2.0) + activejob (= 7.2.0) + activerecord (= 7.2.0) + activesupport (= 7.2.0) marcel (~> 1.0) - activesupport (7.1.3.4) + activesupport (7.2.0) base64 bigdecimal - concurrent-ruby (~> 1.0, >= 1.0.2) + concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) + logger (>= 1.4.2) minitest (>= 5.1) - mutex_m - tzinfo (~> 2.0) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) base64 (0.2.0) bigdecimal (3.1.8) builder (3.3.0) - concurrent-ruby (1.3.3) + concurrent-ruby (1.3.4) connection_pool (2.4.1) crass (1.0.6) - date (3.3.4) + date (3.4.1) drb (2.2.1) erubi (1.13.0) globalid (1.2.1) activesupport (>= 6.1) i18n (1.14.5) concurrent-ruby (~> 1.0) - io-console (0.7.2) - irb (1.14.0) + io-console (0.8.0) + irb (1.14.3) rdoc (>= 4.0.0) reline (>= 0.4.2) + logger (1.6.5) loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) @@ -114,8 +112,7 @@ GEM minitest (5.24.1) mocha (2.4.0) ruby2_keywords (>= 0.0.5) - mutex_m (0.2.0) - net-imap (0.4.14) + net-imap (0.5.5) date net-protocol net-pop (0.1.2) @@ -124,12 +121,13 @@ GEM timeout net-smtp (0.5.0) net-protocol - nio4r (2.7.3) + nio4r (2.7.4) nokogiri (1.16.6) mini_portile2 (~> 2.8.2) racc (~> 1.4) open4 (1.3.4) - psych (5.1.2) + psych (5.2.2) + date stringio racc (1.8.0) rack (3.1.6) @@ -137,23 +135,22 @@ GEM rack (>= 3.0.0) rack-test (2.1.0) rack (>= 1.3) - rackup (2.1.0) + rackup (2.2.1) rack (>= 3) - webrick (~> 1.8) - rails (7.1.3.4) - actioncable (= 7.1.3.4) - actionmailbox (= 7.1.3.4) - actionmailer (= 7.1.3.4) - actionpack (= 7.1.3.4) - actiontext (= 7.1.3.4) - actionview (= 7.1.3.4) - activejob (= 7.1.3.4) - activemodel (= 7.1.3.4) - activerecord (= 7.1.3.4) - activestorage (= 7.1.3.4) - activesupport (= 7.1.3.4) + rails (7.2.0) + actioncable (= 7.2.0) + actionmailbox (= 7.2.0) + actionmailer (= 7.2.0) + actionpack (= 7.2.0) + actiontext (= 7.2.0) + actionview (= 7.2.0) + activejob (= 7.2.0) + activemodel (= 7.2.0) + activerecord (= 7.2.0) + activestorage (= 7.2.0) + activesupport (= 7.2.0) bundler (>= 1.15.0) - railties (= 7.1.3.4) + railties (= 7.2.0) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -165,37 +162,39 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.1.3.4) - actionpack (= 7.1.3.4) - activesupport (= 7.1.3.4) - irb + railties (7.2.0) + actionpack (= 7.2.0) + activesupport (= 7.2.0) + irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) thor (~> 1.0, >= 1.2.2) zeitwerk (~> 2.6) rake (13.2.1) - rdoc (6.7.0) + rdoc (6.10.0) psych (>= 4.0.0) - reline (0.5.9) + reline (0.6.0) io-console (~> 0.5) ruby2_keywords (0.0.5) + securerandom (0.4.1) seed-fu (2.3.9) activerecord (>= 3.1) activesupport (>= 3.1) seed-fu-ndo (0.0.3) seed-fu (>= 2.2.0) - sqlite3 (1.7.3) + sqlite3 (2.1.0) mini_portile2 (~> 2.8.0) - stringio (3.1.1) - thor (1.3.1) + stringio (3.1.2) + thor (1.3.2) timeout (0.4.1) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - webrick (1.8.2) - websocket-driver (0.7.6) + useragent (0.16.11) + websocket-driver (0.7.7) + base64 websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - zeitwerk (2.6.16) + zeitwerk (2.7.1) PLATFORMS ruby @@ -205,7 +204,7 @@ DEPENDENCIES net-smtp open4 rails-controller-testing - sqlite3 (~> 1.4) + sqlite3 (<= 2.1) wagons! BUNDLED WITH diff --git a/lib/tasks/wagons.rake b/lib/tasks/wagons.rake index 8c84d4c..855584e 100644 --- a/lib/tasks/wagons.rake +++ b/lib/tasks/wagons.rake @@ -147,7 +147,8 @@ eval(File.read(wagonfile)) if File.exist?(wagonfile)" pending_migrations = ActiveRecord::Migrator.new( :up, context.migrations, - ActiveRecord::SchemaMigration + ActiveRecord::SchemaMigration, + InternalMetadata.new(ActiveRecord::Tasks::DatabaseTasks.migration_connection_pool) ).pending_migrations if pending_migrations.any? @@ -186,7 +187,7 @@ namespace :db do Rake::Task[:'db:_dump'].clear_actions task :_dump do - context = ActiveRecord::MigrationContext.new(ActiveRecord::Migrator.migrations_paths, ActiveRecord::SchemaMigration) + context = ActiveRecord::MigrationContext.new(ActiveRecord::Migrator.migrations_paths) migrated = Set.new(context.get_all_versions) if migrated.size > context.migrations.size puts "The database schema will not be dumped when there are loaded wagon migrations." diff --git a/lib/wagons/extensions/migration.rb b/lib/wagons/extensions/migration.rb index 19cfc22..588ab6f 100644 --- a/lib/wagons/extensions/migration.rb +++ b/lib/wagons/extensions/migration.rb @@ -13,18 +13,14 @@ def maintain_test_schema_with_wagons! suppress_messages { load_wagon_schema! } end end + alias maintain_test_schema_without_wagons! maintain_test_schema! alias maintain_test_schema! maintain_test_schema_with_wagons! private def load_wagon_schema! - if rails_version_smaller_than('7.1.0') - Base.clear_all_connections! - else - Base.connection_handler.clear_all_connections! - end - + Base.connection_handler.clear_all_connections! # Contrary to the original rails approach (#load_schema_if_pending!), # purge the database first to get rid of all wagon tables. config = Base.configurations.configs_for(env_name: 'test').first @@ -38,11 +34,7 @@ def load_wagon_schema! def load_app_schema(config) Tasks::DatabaseTasks.load_schema(config) - if rails_version_smaller_than('7.1.0') - check_pending! - else - check_all_pending! - end + check_all_pending! end def app_needs_migration? @@ -63,27 +55,15 @@ def migration_versions_in_db end def schema_migration_table_exists? - if rails_version_smaller_than('7.1.0') - Base.connection.table_exists?(SchemaMigration.table_name) - else - SchemaMigration.new(Base.connection).table_exists? - end + ActiveRecord::Base.connection.data_source_exists?(ActiveRecord::Base.schema_migrations_table_name) end def migration_context - if rails_version_smaller_than('7.1.0') - MigrationContext.new(Migrator.migrations_paths, SchemaMigration) - else - MigrationContext.new(Migrator.migrations_paths) - end + MigrationContext.new(Migrator.migrations_paths) end def maintain_test_schema? - if rails_version_smaller_than('7.0.0') - ActiveRecord::Base.maintain_test_schema - else - ActiveRecord.maintain_test_schema - end + ActiveRecord.maintain_test_schema end def rails_version_smaller_than(version) diff --git a/test/ci/rails61.gemfile b/test/ci/rails61.gemfile deleted file mode 100644 index 837a8c1..0000000 --- a/test/ci/rails61.gemfile +++ /dev/null @@ -1,11 +0,0 @@ -source 'https://rubygems.org' - -gemspec :path => '../..' - -gem 'rails', '~> 6.1.0' - -group :test do - gem 'mocha', :require => false - gem 'net-smtp' - gem 'rails-controller-testing' -end diff --git a/test/ci/rails70.gemfile b/test/ci/rails70.gemfile deleted file mode 100644 index 5cb7c3a..0000000 --- a/test/ci/rails70.gemfile +++ /dev/null @@ -1,11 +0,0 @@ -source 'https://rubygems.org' - -gemspec :path => '../..' - -gem 'rails', '~> 7.0.0' - -group :test do - gem 'mocha', :require => false - gem 'net-smtp' - gem 'rails-controller-testing' -end diff --git a/test/dummy/Gemfile b/test/dummy/Gemfile index cc0e05b..4f5b82f 100644 --- a/test/dummy/Gemfile +++ b/test/dummy/Gemfile @@ -6,12 +6,12 @@ gem 'wagons', :path => File.expand_path(__FILE__).split("test#{File::SEPARATOR}d group :development, :test do gem 'net-smtp' - gem 'sqlite3', '~> 1.4' end group :test do gem 'mocha', :require => false gem 'rails-controller-testing' + gem 'sqlite3', '~> 2.1' end # Include the wagons you want attached in Wagonfile. diff --git a/test/dummy/db/schema.rb b/test/dummy/db/schema.rb index 5a1df9a..5a6495c 100644 --- a/test/dummy/db/schema.rb +++ b/test/dummy/db/schema.rb @@ -17,5 +17,4 @@ t.datetime "created_at", precision: nil, null: false t.datetime "updated_at", precision: nil, null: false end - end diff --git a/wagons.gemspec b/wagons.gemspec index a782d64..3c54edd 100644 --- a/wagons.gemspec +++ b/wagons.gemspec @@ -22,6 +22,8 @@ Gem::Specification.new do |s| s.add_dependency 'seed-fu-ndo', '>= 0.0.3' + s.add_dependency 'concurrent-ruby', '< 1.3.5' + s.add_development_dependency 'open4' - s.add_development_dependency 'sqlite3', '~> 1.4' + s.add_development_dependency 'sqlite3', '<= 2.1' end