From ed2ee41d7f049a6f00709db70f599a28e1479e2c Mon Sep 17 00:00:00 2001 From: Christian Schmidt Date: Wed, 24 Jan 2024 09:37:13 +0100 Subject: [PATCH] CI --- .github/workflows/ci.yml | 50 +++++ Gemfile.lock | 279 +++++++++++++++---------- test/archive_table_test.rb | 2 +- test/dummy/config/application.rb | 4 +- test/dummy/config/database.yml | 2 +- test/dummy/config/environments/test.rb | 5 - 6 files changed, 218 insertions(+), 124 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..ca23406 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,50 @@ +name: Test + +on: + - push + +jobs: + test: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + ruby_version: + #- 2.7 + - 3.0 + #- 3.1 + #- 3.2 + #- 3.3 + gemfile: + #active_record-4.2 + #active_record-5.0 + - active_record-6.0 + + name: "${{ matrix.gemfile }} on Ruby ${{ matrix.ruby_version }}" + + services: + db: + image: mariadb:10 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + ports: + - 3306:3306 + env: + MYSQL_DATABASE: archiving_test + MYSQL_ALLOW_EMPTY_PASSWORD: 1 + + env: + BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile + RAILS_ENV: test + + steps: + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby_version }} + bundler-cache: true + - name: Set up database + working-directory: test/dummy + run: bundle exec rake db:migrate + - name: Run tests + run: bundle exec rake test diff --git a/Gemfile.lock b/Gemfile.lock index 6b26f4e..115d8de 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,144 +1,191 @@ PATH remote: . specs: - archiving (0.4.0) - activerecord (>= 4.2, < 7.0) + archiving (0.4.3) + activerecord (>= 4.2, < 8.0) mysql2 GEM remote: https://rubygems.org/ specs: - actioncable (6.0.0) - actionpack (= 6.0.0) + actioncable (7.1.3) + actionpack (= 7.1.3) + activesupport (= 7.1.3) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.0.0) - actionpack (= 6.0.0) - activejob (= 6.0.0) - activerecord (= 6.0.0) - activestorage (= 6.0.0) - activesupport (= 6.0.0) + zeitwerk (~> 2.6) + actionmailbox (7.1.3) + actionpack (= 7.1.3) + activejob (= 7.1.3) + activerecord (= 7.1.3) + activestorage (= 7.1.3) + activesupport (= 7.1.3) mail (>= 2.7.1) - actionmailer (6.0.0) - actionpack (= 6.0.0) - actionview (= 6.0.0) - activejob (= 6.0.0) + net-imap + net-pop + net-smtp + actionmailer (7.1.3) + actionpack (= 7.1.3) + actionview (= 7.1.3) + activejob (= 7.1.3) + activesupport (= 7.1.3) mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 2.0) - actionpack (6.0.0) - actionview (= 6.0.0) - activesupport (= 6.0.0) - rack (~> 2.0) + net-imap + net-pop + net-smtp + rails-dom-testing (~> 2.2) + actionpack (7.1.3) + actionview (= 7.1.3) + activesupport (= 7.1.3) + nokogiri (>= 1.8.5) + racc + rack (>= 2.2.4) + rack-session (>= 1.0.1) rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.0.0) - actionpack (= 6.0.0) - activerecord (= 6.0.0) - activestorage (= 6.0.0) - activesupport (= 6.0.0) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + actiontext (7.1.3) + actionpack (= 7.1.3) + activerecord (= 7.1.3) + activestorage (= 7.1.3) + activesupport (= 7.1.3) + globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (6.0.0) - activesupport (= 6.0.0) + actionview (7.1.3) + activesupport (= 7.1.3) builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.0.0) - activesupport (= 6.0.0) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activejob (7.1.3) + activesupport (= 7.1.3) globalid (>= 0.3.6) - activemodel (6.0.0) - activesupport (= 6.0.0) - activerecord (6.0.0) - activemodel (= 6.0.0) - activesupport (= 6.0.0) - activestorage (6.0.0) - actionpack (= 6.0.0) - activejob (= 6.0.0) - activerecord (= 6.0.0) - marcel (~> 0.3.1) - activesupport (6.0.0) + activemodel (7.1.3) + activesupport (= 7.1.3) + activerecord (7.1.3) + activemodel (= 7.1.3) + activesupport (= 7.1.3) + timeout (>= 0.4.0) + activestorage (7.1.3) + actionpack (= 7.1.3) + activejob (= 7.1.3) + activerecord (= 7.1.3) + activesupport (= 7.1.3) + marcel (~> 1.0) + activesupport (7.1.3) + base64 + bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - zeitwerk (~> 2.1, >= 2.1.8) - builder (3.2.3) - concurrent-ruby (1.1.10) + connection_pool (>= 2.2.5) + drb + i18n (>= 1.6, < 2) + minitest (>= 5.1) + mutex_m + tzinfo (~> 2.0) + base64 (0.2.0) + bigdecimal (3.1.6) + builder (3.2.4) + concurrent-ruby (1.2.3) + connection_pool (2.4.1) crass (1.0.6) - erubi (1.8.0) - globalid (1.0.1) - activesupport (>= 5.0) - i18n (1.12.0) + date (3.3.4) + drb (2.2.0) + ruby2_keywords + erubi (1.12.0) + globalid (1.2.1) + activesupport (>= 6.1) + i18n (1.14.1) concurrent-ruby (~> 1.0) - loofah (2.19.1) + io-console (0.7.2) + irb (1.11.1) + rdoc + reline (>= 0.4.2) + loofah (2.22.0) crass (~> 1.0.2) - nokogiri (>= 1.5.9) - mail (2.7.1) + nokogiri (>= 1.12.0) + mail (2.8.1) mini_mime (>= 0.1.1) - marcel (0.3.3) - mimemagic (~> 0.3.2) - method_source (0.9.2) - mimemagic (0.3.10) - nokogiri (~> 1) - rake - mini_mime (1.0.2) - mini_portile2 (2.8.1) - minitest (5.17.0) - minitest-focus (1.1.2) + net-imap + net-pop + net-smtp + marcel (1.0.2) + mini_mime (1.1.5) + mini_portile2 (2.8.5) + minitest (5.21.2) + minitest-focus (1.4.0) minitest (>= 4, < 6) - mysql2 (0.5.2) - nio4r (2.5.1) - nokogiri (1.14.3) - mini_portile2 (~> 2.8.0) + mutex_m (0.2.0) + mysql2 (0.5.5) + net-imap (0.4.9.1) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-smtp (0.4.0.1) + net-protocol + nio4r (2.7.0) + nokogiri (1.16.0) + mini_portile2 (~> 2.8.2) racc (~> 1.4) - racc (1.6.2) - rack (2.2.6.4) - rack-test (1.1.0) - rack (>= 1.0, < 3) - rails (6.0.0) - actioncable (= 6.0.0) - actionmailbox (= 6.0.0) - actionmailer (= 6.0.0) - actionpack (= 6.0.0) - actiontext (= 6.0.0) - actionview (= 6.0.0) - activejob (= 6.0.0) - activemodel (= 6.0.0) - activerecord (= 6.0.0) - activestorage (= 6.0.0) - activesupport (= 6.0.0) - bundler (>= 1.3.0) - railties (= 6.0.0) - sprockets-rails (>= 2.0.0) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) + psych (5.1.2) + stringio + racc (1.7.3) + rack (3.0.8) + rack-session (2.0.0) + rack (>= 3.0.0) + rack-test (2.1.0) + rack (>= 1.3) + rackup (2.1.0) + rack (>= 3) + webrick (~> 1.8) + rails (7.1.3) + actioncable (= 7.1.3) + actionmailbox (= 7.1.3) + actionmailer (= 7.1.3) + actionpack (= 7.1.3) + actiontext (= 7.1.3) + actionview (= 7.1.3) + activejob (= 7.1.3) + activemodel (= 7.1.3) + activerecord (= 7.1.3) + activestorage (= 7.1.3) + activesupport (= 7.1.3) + bundler (>= 1.15.0) + railties (= 7.1.3) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.4.4) - loofah (~> 2.19, >= 2.19.1) - railties (6.0.0) - actionpack (= 6.0.0) - activesupport (= 6.0.0) - method_source - rake (>= 0.8.7) - thor (>= 0.20.3, < 2.0) - rake (12.3.3) - rr (1.2.1) - sprockets (3.7.2) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + railties (7.1.3) + actionpack (= 7.1.3) + activesupport (= 7.1.3) + irb + rackup (>= 1.0.0) + rake (>= 12.2) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) + rake (13.1.0) + rdoc (6.6.2) + psych (>= 4.0.0) + reline (0.4.2) + io-console (~> 0.5) + rr (3.1.0) + ruby2_keywords (0.0.5) + stringio (3.1.0) + thor (1.3.0) + timeout (0.4.1) + tzinfo (2.0.6) concurrent-ruby (~> 1.0) - rack (> 1, < 3) - sprockets-rails (3.2.1) - actionpack (>= 4.0) - activesupport (>= 4.0) - sprockets (>= 3.0.0) - thor (0.20.3) - thread_safe (0.3.6) - tzinfo (1.2.10) - thread_safe (~> 0.1) - websocket-driver (0.7.1) + webrick (1.8.1) + websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - zeitwerk (2.6.6) + zeitwerk (2.6.12) PLATFORMS ruby @@ -146,9 +193,9 @@ PLATFORMS DEPENDENCIES archiving! minitest-focus - rails (>= 4.2, < 7.0) + rails (>= 4.2, < 8.0) rake rr BUNDLED WITH - 1.17.3 + 2.4.10 diff --git a/test/archive_table_test.rb b/test/archive_table_test.rb index 00ad31e..5edb846 100644 --- a/test/archive_table_test.rb +++ b/test/archive_table_test.rb @@ -212,7 +212,7 @@ class ArchiveTableTest < ActiveSupport::TestCase end test "overriding database connection for archive" do - assert_not_equal LogOther.connection_config, LogOther.archive.connection_config + assert_not_equal LogOther.connection.execute('SELECT DATABASE').first, LogOther.archive.connection.execute('SELECT DATABASE').first p1 = Post.create!(title: "Post 1", tag: "news") l1 = LogOther.create!(note: "Oh", post: p1) l1.archive! diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index 5fa6486..053dd1c 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -1,6 +1,8 @@ require File.expand_path('../boot', __FILE__) -require 'rails/all' +require 'rails' +require 'active_record/railtie' +require 'rails/test_unit/railtie' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. diff --git a/test/dummy/config/database.yml b/test/dummy/config/database.yml index e196d89..7ead4c4 100644 --- a/test/dummy/config/database.yml +++ b/test/dummy/config/database.yml @@ -22,7 +22,7 @@ other_development: # Do not set this db to the same as development or production. test: adapter: mysql2 - host: localhost + host: 127.0.0.1 database: archiving_test username: root password: diff --git a/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb index bc3341f..43462f6 100644 --- a/test/dummy/config/environments/test.rb +++ b/test/dummy/config/environments/test.rb @@ -31,11 +31,6 @@ # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false - # Tell Action Mailer not to deliver emails to the real world. - # The :test delivery method accumulates sent emails in the - # ActionMailer::Base.deliveries array. - config.action_mailer.delivery_method = :test - # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr