From 618e76bf2fc271ce205a7aa441ba3806018dc072 Mon Sep 17 00:00:00 2001 From: Tuan Nguyen Date: Sun, 31 Mar 2024 11:07:42 -0400 Subject: [PATCH] update gems and CI workflow --- .github/workflows/rubyonrails.yml | 55 ++++-- Gemfile | 2 +- Gemfile.lock | 273 +++++++++++++++--------------- config/initializers/rack.rb | 2 +- docker-compose.yml | 1 + test/database_cleaner.rb | 2 +- 6 files changed, 185 insertions(+), 150 deletions(-) diff --git a/.github/workflows/rubyonrails.yml b/.github/workflows/rubyonrails.yml index 41dd554..38ae53e 100644 --- a/.github/workflows/rubyonrails.yml +++ b/.github/workflows/rubyonrails.yml @@ -1,18 +1,30 @@ -# This workflow will install a prebuilt Ruby version, install dependencies, and -# run tests and linters. name: "Ruby on Rails CI" on: push: - branches: [ "master" ] + branches: [ "*" ] pull_request: - branches: [ "master" ] + branches: [ "*" ] jobs: - test: + build_and_run_tests: + name: Build and run tests runs-on: ubuntu-latest - env: - RAILS_ENV: test - DB_ADAPTER: sqlite3 - DATABASE_URL: db/test.sqlite3 + services: + mysql: + image: mysql + ports: + - 3306:3306 + env: + MYSQL_ROOT_PASSWORD: mysql + MYSQL_DATABASE: test + MYSQL_USER: test + MYSQL_PASSWORD: test + # Set health checks to wait until mysql has started + options: >- + --health-cmd "mysqladmin ping -h 127.0.0.1 -u root -p$$MYSQL_ROOT_PASSWORD" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + steps: - name: Checkout code uses: actions/checkout@v3 @@ -20,9 +32,26 @@ jobs: uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0 with: bundler-cache: true - - name: Run tests - run: | + - name: Install libmariadb-dev + run: + sudo apt install -y libmariadb-dev-compat libmariadb-dev + - name: bundle install + env: + RAILS_ENV: test + run: bundle install - bundle exec rails db:create - bundle exec rails test + - name: Run tests with mysql + env: + RAILS_ENV: test + DATABASE_URL: mysql2://test:test@127.0.0.1:3306/test + run: | + bundle exec rake db:reset + bundle exec rake test + - name: Run tests with sqlite3 + env: + RAILS_ENV: test + DATABASE_URL: sqlite3:db/test.sqlite3 + run: | + bundle exec rake db:reset + bundle exec rake test diff --git a/Gemfile b/Gemfile index 65012a0..040bd0f 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ gem 'puma', '~> 6.4', '>= 6.4.2' gem 'rails', '~> 7.0', '>= 7.0.3.1' ## DATABASES ## -gem 'mysql2', '0.5.3' +gem 'mysql2' ## CSS AND JAVASCRIPT ## gem 'actiontext', '~> 7.0', '>= 7.0.3.1' diff --git a/Gemfile.lock b/Gemfile.lock index 5689a88..0512deb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -15,56 +15,56 @@ GIT GIT remote: https://github.com/yorkulcs/sword2ruby.git - revision: 2a8e3f27aa4dff72a0af15adb2b9263d492468cd + revision: 1a12fe35a6665cafcc7368dc77b9633e7e49e254 specs: - sword2ruby (1.0.0) + sword2ruby (1.0.2) atom-tools (~> 2.0.5) hpricot (~> 0.8.3) GEM remote: http://rubygems.org/ specs: - actioncable (7.0.3.1) - actionpack (= 7.0.3.1) - activesupport (= 7.0.3.1) + actioncable (7.0.8.1) + actionpack (= 7.0.8.1) + activesupport (= 7.0.8.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.3.1) - actionpack (= 7.0.3.1) - activejob (= 7.0.3.1) - activerecord (= 7.0.3.1) - activestorage (= 7.0.3.1) - activesupport (= 7.0.3.1) + actionmailbox (7.0.8.1) + actionpack (= 7.0.8.1) + activejob (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.3.1) - actionpack (= 7.0.3.1) - actionview (= 7.0.3.1) - activejob (= 7.0.3.1) - activesupport (= 7.0.3.1) + actionmailer (7.0.8.1) + actionpack (= 7.0.8.1) + actionview (= 7.0.8.1) + activejob (= 7.0.8.1) + activesupport (= 7.0.8.1) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.0) - actionpack (7.0.3.1) - actionview (= 7.0.3.1) - activesupport (= 7.0.3.1) - rack (~> 2.0, >= 2.2.0) + actionpack (7.0.8.1) + actionview (= 7.0.8.1) + activesupport (= 7.0.8.1) + rack (~> 2.0, >= 2.2.4) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.3.1) - actionpack (= 7.0.3.1) - activerecord (= 7.0.3.1) - activestorage (= 7.0.3.1) - activesupport (= 7.0.3.1) + actiontext (7.0.8.1) + actionpack (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.3.1) - activesupport (= 7.0.3.1) + actionview (7.0.8.1) + activesupport (= 7.0.8.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) @@ -72,51 +72,53 @@ GEM active_link_to (1.0.5) actionpack addressable - activejob (7.0.3.1) - activesupport (= 7.0.3.1) + activejob (7.0.8.1) + activesupport (= 7.0.8.1) globalid (>= 0.3.6) - activemodel (7.0.3.1) - activesupport (= 7.0.3.1) - activerecord (7.0.3.1) - activemodel (= 7.0.3.1) - activesupport (= 7.0.3.1) - activestorage (7.0.3.1) - actionpack (= 7.0.3.1) - activejob (= 7.0.3.1) - activerecord (= 7.0.3.1) - activesupport (= 7.0.3.1) + activemodel (7.0.8.1) + activesupport (= 7.0.8.1) + activerecord (7.0.8.1) + activemodel (= 7.0.8.1) + activesupport (= 7.0.8.1) + activestorage (7.0.8.1) + actionpack (= 7.0.8.1) + activejob (= 7.0.8.1) + activerecord (= 7.0.8.1) + activesupport (= 7.0.8.1) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (7.0.3.1) + activesupport (7.0.8.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - addressable (2.8.1) + addressable (2.8.6) public_suffix (>= 2.0.2, < 6.0) atom-tools (2.0.5) - audited (5.0.2) - activerecord (>= 5.0, < 7.1) + audited (5.4.3) + activerecord (>= 5.0, < 7.2) + request_store (~> 1.2) autoprefixer-rails (10.4.16.0) execjs (~> 2) - bcrypt (3.1.18) + base64 (0.2.0) + bcrypt (3.1.20) bindex (0.8.1) bootstrap (5.3.2) autoprefixer-rails (>= 9.1.0) popper_js (>= 2.11.8, < 3) builder (3.2.4) byebug (11.1.3) - cancancan (3.4.0) - capybara (3.39.2) + cancancan (3.5.0) + capybara (3.40.0) addressable matrix mini_mime (>= 0.1.3) - nokogiri (~> 1.8) + nokogiri (~> 1.11) rack (>= 1.6.0) rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) - carrierwave (2.2.2) + carrierwave (2.2.6) activemodel (>= 5.0.0) activesupport (>= 5.0.0) addressable (~> 2.6) @@ -144,42 +146,42 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.1.10) + concurrent-ruby (1.2.3) crass (1.0.6) database_cleaner-active_record (2.1.0) activerecord (>= 5.a) database_cleaner-core (~> 2.0.0) database_cleaner-core (2.0.1) - devise (4.8.1) + date (3.3.4) + devise (4.9.3) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 4.1.0) responders warden (~> 1.2.3) - digest (3.1.0) em-websocket (0.5.3) eventmachine (>= 0.12.9) http_parser.rb (~> 0) - erubi (1.11.0) + erubi (1.12.0) eventmachine (1.2.7) exception_notification (4.5.0) actionmailer (>= 5.2, < 8) activesupport (>= 5.2, < 8) - execjs (2.8.1) + execjs (2.9.1) factory_girl (4.8.1) activesupport (>= 3.0.0) factory_girl_rails (4.8.0) factory_girl (~> 4.8.0) railties (>= 3.0.0) - faker (2.22.0) + faker (2.23.0) i18n (>= 1.8.11, < 2) - ffi (1.15.5) + ffi (1.16.3) font-awesome-rails (4.7.0.8) railties (>= 3.2, < 8.0) formatador (1.1.0) - globalid (1.0.0) - activesupport (>= 5.0) - guard (2.18.0) + globalid (1.2.1) + activesupport (>= 6.1) + guard (2.18.1) formatador (>= 0.2.4) listen (>= 2.7, < 4.0) lumberjack (>= 1.0.12, < 2.0) @@ -188,7 +190,7 @@ GEM pry (>= 0.13.0) shellany (~> 0.0) thor (>= 0.18.1) - guard-bundler (3.0.0) + guard-bundler (3.0.1) bundler (>= 2.1, < 3) guard (~> 2.2) guard-compat (~> 1.1) @@ -204,7 +206,7 @@ GEM hpricot (0.8.6) htmlentities (4.3.4) http_parser.rb (0.8.0) - i18n (1.12.0) + i18n (1.14.4) concurrent-ruby (~> 1.0) image_processing (1.12.2) mini_magick (>= 4.9.5, < 5) @@ -229,104 +231,107 @@ GEM activerecord kaminari-core (= 1.2.2) kaminari-core (1.2.2) - liquid (5.4.0) - listen (3.7.1) + liquid (5.5.0) + listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.18.0) + loofah (2.22.0) crass (~> 1.0.2) - nokogiri (>= 1.5.9) - lumberjack (1.2.8) - mail (2.7.1) + nokogiri (>= 1.12.0) + lumberjack (1.2.10) + mail (2.8.1) mini_mime (>= 0.1.1) - marcel (1.0.2) + net-imap + net-pop + net-smtp + marcel (1.0.4) matrix (0.4.2) method_source (1.0.0) - mini_magick (4.11.0) - mini_mime (1.1.2) - minitest (5.20.0) + mini_magick (4.12.0) + mini_mime (1.1.5) + minitest (5.22.3) mocha (2.1.0) ruby2_keywords (>= 0.0.5) multi_json (1.15.0) - mysql2 (0.5.3) + mysql2 (0.5.6) nenv (0.3.0) - net-imap (0.2.3) - digest + net-imap (0.4.10) + date net-protocol - strscan - net-pop (0.1.1) - digest + net-pop (0.1.2) net-protocol + net-protocol (0.2.2) timeout - net-protocol (0.1.3) - timeout - net-smtp (0.3.1) - digest + net-smtp (0.5.0) net-protocol - timeout - nio4r (2.5.8) - nokogiri (1.13.8-x86_64-linux) + nio4r (2.7.1) + nokogiri (1.16.3-x86_64-linux) racc (~> 1.4) notiffany (0.1.3) nenv (~> 0.1) shellany (~> 0.0) orm_adapter (0.5.0) popper_js (2.11.8) - pry (0.14.1) + pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) - public_suffix (5.0.0) + public_suffix (5.0.4) puma (6.4.2) nio4r (~> 2.0) - racc (1.6.0) - rack (2.2.4) - rack-test (2.0.2) + racc (1.7.3) + rack (2.2.9) + rack-test (2.1.0) rack (>= 1.3) - rails (7.0.3.1) - actioncable (= 7.0.3.1) - actionmailbox (= 7.0.3.1) - actionmailer (= 7.0.3.1) - actionpack (= 7.0.3.1) - actiontext (= 7.0.3.1) - actionview (= 7.0.3.1) - activejob (= 7.0.3.1) - activemodel (= 7.0.3.1) - activerecord (= 7.0.3.1) - activestorage (= 7.0.3.1) - activesupport (= 7.0.3.1) + rails (7.0.8.1) + actioncable (= 7.0.8.1) + actionmailbox (= 7.0.8.1) + actionmailer (= 7.0.8.1) + actionpack (= 7.0.8.1) + actiontext (= 7.0.8.1) + actionview (= 7.0.8.1) + activejob (= 7.0.8.1) + activemodel (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) bundler (>= 1.15.0) - railties (= 7.0.3.1) + railties (= 7.0.8.1) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) activesupport (>= 5.0.1.rc1) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.4.3) - loofah (~> 2.3) - rails-settings-cached (2.8.2) - rails (>= 5.0.0) - railties (7.0.3.1) - actionpack (= 7.0.3.1) - activesupport (= 7.0.3.1) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + rails-settings-cached (2.9.4) + activerecord (>= 5.0.0) + railties (>= 5.0.0) + railties (7.0.8.1) + actionpack (= 7.0.8.1) + activesupport (= 7.0.8.1) method_source rake (>= 12.2) thor (~> 1.0) zeitwerk (~> 2.5) - rake (13.0.6) - rb-fsevent (0.11.1) + rake (13.1.0) + rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) regexp_parser (2.9.0) - responders (3.0.1) - actionpack (>= 5.0) - railties (>= 5.0) - rexml (3.2.5) - roo (2.9.0) + request_store (1.6.0) + rack (>= 1.4) + responders (3.1.1) + actionpack (>= 5.2) + railties (>= 5.2) + rexml (3.2.6) + roo (2.10.1) nokogiri (~> 1) rubyzip (>= 1.3.0, < 3.0.0) - ruby-vips (2.1.4) + ruby-vips (2.2.1) ffi (~> 1.12) ruby2_keywords (0.0.5) rubyzip (1.3.0) @@ -340,37 +345,37 @@ GEM sprockets (> 3.0) sprockets-rails tilt - selenium-webdriver (4.16.0) + selenium-webdriver (4.19.0) + base64 (~> 0.2) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) shellany (0.0.1) shoulda-context (2.0.0) - shoulda-matchers (5.1.0) + shoulda-matchers (5.3.0) activesupport (>= 5.2.0) simple_form (5.3.0) actionpack (>= 5.2) activemodel (>= 5.2) - spring (4.0.0) - sprockets (4.1.1) + spring (4.1.3) + sprockets (4.2.1) concurrent-ruby (~> 1.0) - rack (> 1, < 3) + rack (>= 2.2.4, < 4) sprockets-rails (3.4.2) actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) sqlite3 (1.7.3-x86_64-linux) - ssrf_filter (1.0.8) - strscan (3.0.4) - terser (1.1.20) + ssrf_filter (1.1.2) + terser (1.2.1) execjs (>= 0.3.0, < 3) - thor (1.2.1) - tilt (2.0.11) - timeliness (0.4.4) - timeout (0.3.0) + thor (1.3.1) + tilt (2.3.0) + timeliness (0.4.5) + timeout (0.4.1) trix-rails (2.4.0) rails (> 4.1) - tzinfo (2.0.5) + tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode (0.4.4.4) warden (1.2.9) @@ -381,12 +386,12 @@ GEM bindex (>= 0.4.0) railties (>= 6.0.0) websocket (1.2.10) - websocket-driver (0.7.5) + websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.0) + zeitwerk (2.6.13) zip-zip (0.3) rubyzip (>= 1.0.0) @@ -427,7 +432,7 @@ DEPENDENCIES liquid (~> 5.4) minitest (~> 5.20) mocha (~> 2.1) - mysql2 (= 0.5.3) + mysql2 nokogiri (~> 1.13, >= 1.13.8) populator! puma (~> 6.4, >= 6.4.2) diff --git a/config/initializers/rack.rb b/config/initializers/rack.rb index d6d2ac7..7f5247c 100644 --- a/config/initializers/rack.rb +++ b/config/initializers/rack.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -Rack::Multipart::Parser.const_set('BUFSIZE', 10_000_000) unless Rails.env.test? +#Rack::Multipart::Parser.const_set('BUFSIZE', 10_000_000) unless Rails.env.test? diff --git a/docker-compose.yml b/docker-compose.yml index 1726e55..a41a023 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,6 +19,7 @@ services: - RAILS_ENV=${RAILS_ENV:-development} - SECRET_KEY_BASE=${SECRET_KEY_BASE} - DATABASE_URL=mysql2://root:mypasswd@db/${COMPOSE_PROJECT_NAME}_${RAILS_ENV:-development} + - TEST_DATABASE_URL=mysql2://root:mypasswd@db/test - RAILS_SERVE_STATIC_FILES=true - NODE_OPTIONS=--openssl-legacy-provider env_file: diff --git a/test/database_cleaner.rb b/test/database_cleaner.rb index 405f5ca..ce6dda7 100644 --- a/test/database_cleaner.rb +++ b/test/database_cleaner.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -DatabaseCleaner.strategy = :transaction +DatabaseCleaner.strategy = :truncation module Minitest class Spec