diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index d734442d..8a55ca9d 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -19,15 +19,13 @@ jobs: fail-fast: false matrix: os: [ubuntu-22.04] - ruby: ['3.0.3'] runs-on: ${{ matrix.os }} - continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }} steps: - uses: actions/checkout@v5 - uses: ruby/setup-ruby@v1 with: - ruby-version: ${{ matrix.ruby }} + ruby-version: .ruby-version # reads the Ruby version from the .ruby-version file bundler-cache: true # runs 'bundle install' and caches installed gems automatically - name: config bundler run: | diff --git a/Dockerfile b/Dockerfile index 9c46182a..1f86b445 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,16 @@ -FROM internetee/ruby:3.0-buster +FROM ruby:3.4.9-bookworm + +# System dependencies (the official ruby image ships build tools but not these) +RUN apt-get update -qq && \ + apt-get install --no-install-recommends -y \ + libpq-dev \ + nodejs \ + netcat-openbsd \ + curl \ + imagemagick \ + shared-mime-info \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* RUN mkdir -p /opt/webapps/app/tmp/pids WORKDIR /opt/webapps/app diff --git a/Dockerfile.production b/Dockerfile.production index 8af4af7c..ce92613d 100644 --- a/Dockerfile.production +++ b/Dockerfile.production @@ -1,5 +1,5 @@ -# Base image with platform specification -FROM internetee/ruby:3.0-buster +# Base image +FROM ruby:3.4.9-bookworm # Set working directory WORKDIR /opt/webapps/app @@ -13,20 +13,18 @@ ENV RAILS_ENV="production" \ LANGUAGE=et_EE:et \ LC_ALL=et_EE.UTF-8 -# Fix repository issues and install packages -RUN apt-get update -qq || true && \ - apt-get install -y --no-install-recommends gnupg2 && \ - # Remove problematic repositories - rm -f /etc/apt/sources.list.d/google-chrome.list && \ - rm -f /etc/apt/sources.list.d/pgdg.list && \ - # Update sources and install packages - apt-get update -qq && \ +# Install system packages and generate the Estonian locale +RUN apt-get update -qq && \ apt-get install --no-install-recommends -y \ - netcat \ + netcat-openbsd \ curl \ libpq-dev \ + nodejs \ imagemagick \ shared-mime-info \ + locales \ + && echo "et_EE.UTF-8 UTF-8" > /etc/locale.gen \ + && locale-gen \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* diff --git a/Dockerfile.staging b/Dockerfile.staging index 4a375bb9..ce92613d 100644 --- a/Dockerfile.staging +++ b/Dockerfile.staging @@ -1,5 +1,5 @@ -# Base image with platform specification -FROM internetee/ruby:3.0-buster +# Base image +FROM ruby:3.4.9-bookworm # Set working directory WORKDIR /opt/webapps/app @@ -13,20 +13,18 @@ ENV RAILS_ENV="production" \ LANGUAGE=et_EE:et \ LC_ALL=et_EE.UTF-8 -# Fix repository issues and install packages -RUN echo "deb http://archive.debian.org/debian buster main" > /etc/apt/sources.list && \ - echo "deb http://archive.debian.org/debian-security buster/updates main" >> /etc/apt/sources.list && \ - echo 'Acquire::Check-Valid-Until "false";' > /etc/apt/apt.conf.d/99no-check-valid-until && \ - rm -f /etc/apt/sources.list.d/google-chrome.list && \ - rm -f /etc/apt/sources.list.d/pgdg.list && \ - apt-get update -qq && \ +# Install system packages and generate the Estonian locale +RUN apt-get update -qq && \ apt-get install --no-install-recommends -y \ - gnupg2 \ - netcat \ + netcat-openbsd \ curl \ libpq-dev \ + nodejs \ imagemagick \ shared-mime-info \ + locales \ + && echo "et_EE.UTF-8 UTF-8" > /etc/locale.gen \ + && locale-gen \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* diff --git a/Dockerfile.test b/Dockerfile.test index fd85ef7e..ce92613d 100644 --- a/Dockerfile.test +++ b/Dockerfile.test @@ -1,5 +1,5 @@ -# Base image with platform specification -FROM internetee/ruby:3.0-buster +# Base image +FROM ruby:3.4.9-bookworm # Set working directory WORKDIR /opt/webapps/app @@ -13,21 +13,18 @@ ENV RAILS_ENV="production" \ LANGUAGE=et_EE:et \ LC_ALL=et_EE.UTF-8 -# Fix repository issues and install packages -RUN echo "deb [trusted=yes] http://archive.debian.org/debian buster main" > /etc/apt/sources.list && \ - echo "deb [trusted=yes] http://archive.debian.org/debian-security buster/updates main" >> /etc/apt/sources.list && \ - echo 'Acquire::Check-Valid-Until "false";' > /etc/apt/apt.conf.d/99no-check-valid-until && \ - rm -f /etc/apt/sources.list.d/google-chrome.list && \ - rm -f /etc/apt/sources.list.d/pgdg.list && \ - rm -f /etc/apt/sources.list.d/nodesource.list && \ - apt-get update && \ +# Install system packages and generate the Estonian locale +RUN apt-get update -qq && \ apt-get install --no-install-recommends -y \ - gnupg2 \ - netcat \ + netcat-openbsd \ curl \ libpq-dev \ + nodejs \ imagemagick \ shared-mime-info \ + locales \ + && echo "et_EE.UTF-8 UTF-8" > /etc/locale.gen \ + && locale-gen \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* diff --git a/Gemfile b/Gemfile index fcd1f44f..3810e900 100644 --- a/Gemfile +++ b/Gemfile @@ -1,13 +1,25 @@ source 'https://rubygems.org' +# Ruby 3.4 moved these out of the default gems; Rails 6.1 does not declare +# them, so they must be required explicitly to boot on Ruby 3.4. +gem 'base64' +gem 'benchmark' +gem 'bigdecimal' +gem 'drb' +gem 'logger' +gem 'mutex_m' +gem 'net-smtp', require: false +gem 'ostruct' +gem 'syslog' # Used by production logging (syslog/logger); bundled gem in Ruby 3.4 + gem 'aws-sdk-ses', '~> 1.40' gem 'bootsnap', '~> 1.18.0', require: false gem 'figaro', '~> 1.3.0' gem 'jbuilder' gem 'mimemagic', '~> 0.4.3' gem 'passenger', '>= 5.3.2', require: 'phusion_passenger/rack_handler' -gem 'pg', '~> 1.6.3' -gem 'rails', '>= 6.0.3.1' +gem 'pg', '~> 1.6.3', force_ruby_platform: true +gem 'rails', '~> 6.1.7', '>= 6.1.7.10' gem 'recaptcha', '~> 5.21', require: 'recaptcha/rails' gem 'sassc', '~> 2.4' gem 'sassc-rails' @@ -21,6 +33,7 @@ end group :development, :test do gem 'apparition', github: 'twalpole/apparition', ref: 'ca86be4d54af835d531dbcd2b86e7b2c77f85f34' gem 'capybara' + gem 'matrix' # Removed from Ruby 3.4 default gems; required by capybara gem 'mina', '~> 1.2.4' gem 'pry' gem 'puma' @@ -29,6 +42,7 @@ group :development, :test do end group :test do + gem 'minitest', '~> 5.25' # Rails 6.1 is built against minitest 5.x; 6.x breaks minitest/mock gem 'selenium-webdriver' gem 'simplecov', '0.17.1', require: false # CC last supported v0.17 end diff --git a/Gemfile.lock b/Gemfile.lock index 92f870e3..46edbe51 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,60 +10,60 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (6.1.4.1) - actionpack (= 6.1.4.1) - activesupport (= 6.1.4.1) + actioncable (6.1.7.10) + actionpack (= 6.1.7.10) + activesupport (= 6.1.7.10) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.4.1) - actionpack (= 6.1.4.1) - activejob (= 6.1.4.1) - activerecord (= 6.1.4.1) - activestorage (= 6.1.4.1) - activesupport (= 6.1.4.1) + actionmailbox (6.1.7.10) + actionpack (= 6.1.7.10) + activejob (= 6.1.7.10) + activerecord (= 6.1.7.10) + activestorage (= 6.1.7.10) + activesupport (= 6.1.7.10) mail (>= 2.7.1) - actionmailer (6.1.4.1) - actionpack (= 6.1.4.1) - actionview (= 6.1.4.1) - activejob (= 6.1.4.1) - activesupport (= 6.1.4.1) + actionmailer (6.1.7.10) + actionpack (= 6.1.7.10) + actionview (= 6.1.7.10) + activejob (= 6.1.7.10) + activesupport (= 6.1.7.10) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.1.4.1) - actionview (= 6.1.4.1) - activesupport (= 6.1.4.1) + actionpack (6.1.7.10) + actionview (= 6.1.7.10) + activesupport (= 6.1.7.10) rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.4.1) - actionpack (= 6.1.4.1) - activerecord (= 6.1.4.1) - activestorage (= 6.1.4.1) - activesupport (= 6.1.4.1) + actiontext (6.1.7.10) + actionpack (= 6.1.7.10) + activerecord (= 6.1.7.10) + activestorage (= 6.1.7.10) + activesupport (= 6.1.7.10) nokogiri (>= 1.8.5) - actionview (6.1.4.1) - activesupport (= 6.1.4.1) + actionview (6.1.7.10) + activesupport (= 6.1.7.10) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.1.4.1) - activesupport (= 6.1.4.1) + activejob (6.1.7.10) + activesupport (= 6.1.7.10) globalid (>= 0.3.6) - activemodel (6.1.4.1) - activesupport (= 6.1.4.1) - activerecord (6.1.4.1) - activemodel (= 6.1.4.1) - activesupport (= 6.1.4.1) - activestorage (6.1.4.1) - actionpack (= 6.1.4.1) - activejob (= 6.1.4.1) - activerecord (= 6.1.4.1) - activesupport (= 6.1.4.1) - marcel (~> 1.0.0) + activemodel (6.1.7.10) + activesupport (= 6.1.7.10) + activerecord (6.1.7.10) + activemodel (= 6.1.7.10) + activesupport (= 6.1.7.10) + activestorage (6.1.7.10) + actionpack (= 6.1.7.10) + activejob (= 6.1.7.10) + activerecord (= 6.1.7.10) + activesupport (= 6.1.7.10) + marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (6.1.4.1) + activesupport (6.1.7.10) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -83,9 +83,12 @@ GEM aws-sigv4 (~> 1.1) aws-sigv4 (1.2.4) aws-eventstream (~> 1, >= 1.0.2) + base64 (0.3.0) + benchmark (0.5.0) + bigdecimal (4.1.2) bootsnap (1.18.3) msgpack (~> 1.2) - builder (3.2.4) + builder (3.3.0) capybara (3.35.3) addressable mini_mime (>= 0.1.3) @@ -96,20 +99,22 @@ GEM xpath (~> 3.2) childprocess (3.0.0) coderay (1.1.3) - concurrent-ruby (1.1.9) + concurrent-ruby (1.3.7) crack (0.4.5) rexml crass (1.0.6) + date (3.5.1) docile (1.3.2) - erubi (1.10.0) + drb (2.2.3) + erubi (1.13.1) execjs (2.10.1) ffi (1.17.4) figaro (1.3.0) thor (>= 0.14.0, < 2) - globalid (0.5.2) - activesupport (>= 5.0) + globalid (1.3.0) + activesupport (>= 6.1) hashdiff (1.0.1) - i18n (1.8.10) + i18n (1.15.0) concurrent-ruby (~> 1.0) jbuilder (2.11.2) activesupport (>= 5.0.0) @@ -121,28 +126,44 @@ GEM rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) logger (1.7.0) - loofah (2.19.1) + loofah (2.25.1) crass (~> 1.0.2) - nokogiri (>= 1.5.9) - mail (2.7.1) + nokogiri (>= 1.12.0) + mail (2.9.0) + logger mini_mime (>= 0.1.1) - marcel (1.0.1) - method_source (1.0.0) + net-imap + net-pop + net-smtp + marcel (1.2.1) + matrix (0.4.3) + method_source (1.1.0) mimemagic (0.4.3) nokogiri (~> 1) rake mina (1.2.4) open4 (~> 1.3.4) rake - mini_mime (1.1.1) - mini_portile2 (2.8.0) - minitest (5.14.4) + mini_mime (1.1.5) + mini_portile2 (2.8.9) + minitest (5.27.0) msgpack (1.7.2) - nio4r (2.5.9) - nokogiri (1.13.10) - mini_portile2 (~> 2.8.0) + mutex_m (0.3.0) + net-imap (0.6.4.1) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-smtp (0.5.1) + net-protocol + nio4r (2.7.5) + nokogiri (1.19.3) + mini_portile2 (~> 2.8.2) racc (~> 1.4) open4 (1.3.4) + ostruct (0.6.3) passenger (6.1.2) logger (>= 1.7.0) rack (>= 1.6.13) @@ -155,38 +176,40 @@ GEM public_suffix (4.0.6) puma (5.6.8) nio4r (~> 2.0) - racc (1.6.1) + racc (1.8.1) rack (2.2.23) - rack-test (1.1.0) - rack (>= 1.0, < 3) + rack-test (2.2.0) + rack (>= 1.3) rackup (1.0.1) rack (< 3) webrick - rails (6.1.4.1) - actioncable (= 6.1.4.1) - actionmailbox (= 6.1.4.1) - actionmailer (= 6.1.4.1) - actionpack (= 6.1.4.1) - actiontext (= 6.1.4.1) - actionview (= 6.1.4.1) - activejob (= 6.1.4.1) - activemodel (= 6.1.4.1) - activerecord (= 6.1.4.1) - activestorage (= 6.1.4.1) - activesupport (= 6.1.4.1) + rails (6.1.7.10) + actioncable (= 6.1.7.10) + actionmailbox (= 6.1.7.10) + actionmailer (= 6.1.7.10) + actionpack (= 6.1.7.10) + actiontext (= 6.1.7.10) + actionview (= 6.1.7.10) + activejob (= 6.1.7.10) + activemodel (= 6.1.7.10) + activerecord (= 6.1.7.10) + activestorage (= 6.1.7.10) + activesupport (= 6.1.7.10) bundler (>= 1.15.0) - railties (= 6.1.4.1) + railties (= 6.1.7.10) sprockets-rails (>= 2.0.0) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) + rails-dom-testing (2.3.0) + activesupport (>= 5.0.0) + minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.4.4) - loofah (~> 2.19, >= 2.19.1) - railties (6.1.4.1) - actionpack (= 6.1.4.1) - activesupport (= 6.1.4.1) + rails-html-sanitizer (1.7.0) + loofah (~> 2.25) + nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) + railties (6.1.7.10) + actionpack (= 6.1.7.10) + activesupport (= 6.1.7.10) method_source - rake (>= 0.13) + rake (>= 12.2) thor (~> 1.0) raindrops (0.19.2) rake (13.4.2) @@ -215,16 +238,20 @@ GEM simplecov-html (0.10.2) simpleidn (0.2.1) unf (~> 0.1.4) - sprockets (4.0.2) + sprockets (4.2.2) concurrent-ruby (~> 1.0) - rack (> 1, < 3) - sprockets-rails (3.2.2) - actionpack (>= 4.0) - activesupport (>= 4.0) + logger + rack (>= 2.2.4, < 4) + sprockets-rails (3.5.2) + actionpack (>= 6.1) + activesupport (>= 6.1) sprockets (>= 3.0.0) + syslog (0.4.0) + logger thor (1.5.0) tilt (2.0.10) - tzinfo (2.0.4) + timeout (0.6.1) + tzinfo (2.0.6) concurrent-ruby (~> 1.0) uglifier (4.2.1) execjs (>= 0.3.0, < 3) @@ -239,12 +266,13 @@ GEM crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) webrick (1.9.2) - websocket-driver (0.7.5) + websocket-driver (0.8.1) + base64 websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.4.2) + zeitwerk (2.8.2) PLATFORMS ruby @@ -252,27 +280,38 @@ PLATFORMS DEPENDENCIES apparition! aws-sdk-ses (~> 1.40) + base64 + benchmark + bigdecimal bootsnap (~> 1.18.0) capybara + drb figaro (~> 1.3.0) jbuilder listen (>= 3.0.5, < 3.10.1) + logger + matrix mimemagic (~> 0.4.3) mina (~> 1.2.4) + minitest (~> 5.25) + mutex_m + net-smtp + ostruct passenger (>= 5.3.2) pg (~> 1.6.3) pry puma - rails (>= 6.0.3.1) + rails (~> 6.1.7, >= 6.1.7.10) recaptcha (~> 5.21) sassc (~> 2.4) sassc-rails selenium-webdriver simplecov (= 0.17.1) simpleidn (= 0.2.1) + syslog uglifier unicorn webmock BUNDLED WITH - 2.5.7 + 2.5.23 diff --git a/app/mailers/contact_request_mailer.rb b/app/mailers/contact_request_mailer.rb index f5ec0949..530a9b30 100644 --- a/app/mailers/contact_request_mailer.rb +++ b/app/mailers/contact_request_mailer.rb @@ -13,8 +13,20 @@ def confirmation_email(contact_request) mail(to: recipients, subject: t('contact_request_mailer.confirmation_email.subject')) end - def contact_email(contact_request:, recipients:, mail_body:, raise_error: false) - raise ::Net::SMTPFatalError if Rails.env.test? && raise_error + # NOTE: takes a positional Hash rather than keyword arguments on purpose. + # ActionMailer 6.1 does not preserve the ruby2_keywords flag through its lazy + # delivery proxy (Mailer.action(...).deliver_*), so keyword arguments arrive + # as a single positional Hash on Ruby 3.x and raise ArgumentError. Accepting a + # Hash here sidesteps that. Fixed upstream in Rails 7; can revert on upgrade. + def contact_email(args) + contact_request = args.fetch(:contact_request) + recipients = args.fetch(:recipients) + mail_body = args.fetch(:mail_body) + raise_error = args.fetch(:raise_error, false) + + # Net::SMTPFatalError#initialize requires a response argument in the + # net-smtp gem (unlike the old Ruby 3.0 stdlib version). + raise ::Net::SMTPFatalError, 'Simulated SMTP failure' if Rails.env.test? && raise_error if ApplicationMailer.ses_configured? ses_contact_email( diff --git a/config/boot.rb b/config/boot.rb index b9e460ce..add5c826 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,4 +1,8 @@ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +# concurrent-ruby >= 1.3.5 dropped its implicit `require "logger"`, which +# ActiveSupport 6.1 relies on. Load it early so Rails boots on Ruby 3.4. +require 'logger' + require 'bundler/setup' # Set up gems listed in the Gemfile. require 'bootsnap/setup' # Speed up boot time by caching expensive operations. diff --git a/test/test_helper.rb b/test/test_helper.rb index 2ddc2ce0..06c186b3 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -19,6 +19,13 @@ class ActiveSupport::TestCase # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. fixtures :all + # ActionMailer::Base.deliveries is a global array shared across all test + # classes. Clear it after every test so mails sent by one test never leak + # into another (the failure is order/seed dependent otherwise). + teardown do + ActionMailer::Base.deliveries.clear + end + # Add more helper methods to be used by all tests here... end