Skip to content

Upgrade Ruby (3.1.4 -> 3.3.8) & Rails (7.1.3 -> 7.2.2.1) #749

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 29 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
322c9bc
Upgrade to Ruby 3.2.7
fosterfarrell9 Feb 22, 2025
34689b0
Update Gemfile.lock
fosterfarrell9 Feb 22, 2025
a2b9c85
Upgrade to Ruby 3.3.7
fosterfarrell9 Feb 22, 2025
ba786b1
Upgrade thredded in order to prepare for Rails 7.2 upgrade
fosterfarrell9 Feb 22, 2025
15a68eb
Upgrade Rails gem to Rails 7.2.2.1
fosterfarrell9 Feb 22, 2025
855edea
Apply app:upgrade
fosterfarrell9 Feb 22, 2025
8f0ab9e
Flip switches for Rais 7.2 migration
fosterfarrell9 Feb 22, 2025
75a1a56
Enforce Rubocop rules
fosterfarrell9 Feb 22, 2025
7794930
Add mutex_m in order to silence Ruby 3.4 warnings
fosterfarrell9 Feb 22, 2025
811d874
Use Rails 7.2 defaults
fosterfarrell9 Feb 22, 2025
ca1fa1c
Replace keyword argument syntax by positional arguments in order to f…
fosterfarrell9 Feb 22, 2025
90195db
Update schemas to Rails 7.2
fosterfarrell9 Feb 22, 2025
4382a8b
Add csv gem in order to silence deprecation warning
fosterfarrell9 Feb 22, 2025
b7b2433
Remove explicit requiring of csv
fosterfarrell9 Feb 22, 2025
77b68fc
Add config changes from development to docker_development
fosterfarrell9 Feb 22, 2025
7f3437b
Replace remaining old ruby versions
fosterfarrell9 Feb 22, 2025
7e14a3c
Enforce Rubocop rules
fosterfarrell9 Feb 22, 2025
cbf17ff
Add missing require
fosterfarrell9 Feb 22, 2025
b3e1181
Merge branch 'dev' into upgrade/ruby_and_rails
Splines May 2, 2025
e11da52
Use Debian bookworm instead of bullseye & update to ruby 3.3.8 (inste…
Splines May 2, 2025
61997f9
Update to latest thredded version
Splines May 2, 2025
19d726b
Force SSL in production
Splines May 2, 2025
af6665c
Update postgresql in dev to v15
Splines May 2, 2025
7992114
Fix rubocop yml file path
Splines May 2, 2025
3d293ab
Fix failing unit tests (don't set queue_adapter to sidekiq)
Splines May 2, 2025
c4e21e9
Temporarily uninstall new gems csv & mutex_m
Splines May 2, 2025
a12a1ca
Instead of adding mutex_m as dependency, update spring
Splines May 2, 2025
d796bda
Add back in csv dependency for Vignettes::CsvHandler
Splines May 2, 2025
2963988
Specify missing config CLI arg for RuboCop in GitHub Actions
Splines May 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ jobs:
if: ${{ steps.rb-changed.outputs.changed-files != ''}}
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1.4
ruby-version: 3.3.8
bundler-cache: true

- name: Run RuboCop
if: ${{ steps.rb-changed.outputs.changed-files != ''}}
run: |
echo "🚨 Running RuboCop version: $(bundle info rubocop | head -1)"
bundle exec rubocop --format github --fail-level 'convention' --force-exclusion -- $CHANGED_FILES
bundle exec rubocop --config ./.config/.rubocop.yml --format github --fail-level 'convention' --force-exclusion -- $CHANGED_FILES

eslint:
name: ESLint (JS)
Expand Down
9 changes: 5 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source "https://rubygems.org"
# We only pin versions to specific Git commits when they are "problem childs"
# and we want to review each commit before updating to the latest version.

ruby "3.1.4"
ruby "3.3.8"

gem "active_model_serializers", "~> 0.10"
gem "activerecord-import", "~>1.7"
Expand All @@ -20,6 +20,7 @@ gem "clipboard-rails", "~> 1.7"
gem "coffee-rails", "~> 5.0" # CoffeeScript for .coffee assets and views
gem "commontator", "~> 7.0.1"
gem "coveralls", "~> 0.7", require: false
gem "csv", "~> 3.3" # for example used in Vignettes::CsvHandler
gem "dalli", "~> 3.2" # caching to memcached in production
gem "devise", "~> 4.9"
gem "devise-bootstrap-views", "~> 1.1"
Expand Down Expand Up @@ -47,7 +48,7 @@ gem "progress_bar", "~> 1.3"
gem "prometheus_exporter", "~> 2.1"
gem "puma", "~> 6.4" # app server
gem "rack", "~> 2.2"
gem "rails", "~> 7.1.3"
gem "rails", "~> 7.2.2"
gem "rails-i18n", "~> 7.0"
gem "responders", "~> 3.1"
gem "rgl", "~> 0.6"
Expand All @@ -63,7 +64,7 @@ gem "sunspot_rails", "~> 2.7"
gem "sunspot_solr", "~> 2.7"
gem "terser", "~> 1.2" # Ruby wrapper for UglifyJS JavaScript compressor
gem "thredded", git: "https://github.com/thredded/thredded.git",
ref: "1340e913affd1af5fcc060fbccd271184ece9a6a"
ref: "566100f6a020ccc390aa60689d58b007a55506d2"
gem "thredded-markdown_katex",
git: "https://github.com/thredded/thredded-markdown_katex.git",
ref: "e2830bdb40880018a0e59d2b82c94b0a9f237365"
Expand All @@ -79,7 +80,7 @@ group :development, :docker_development do
gem "rubocop", "~> 1.65", require: false
gem "rubocop-performance", "~> 1.21", require: false
gem "rubocop-rails", "~> 2.24", require: false
gem "spring", "~> 2.1" # app preloader, keeps app running in background for development
gem "spring", "~> 4.3" # app preloader, keeps app running in background for development
gem "spring-watcher-listen", "~> 2.0"
gem "web-console", "~> 4.2" # interactive console on exception pages
end
Expand Down
151 changes: 73 additions & 78 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ GIT

GIT
remote: https://github.com/thredded/thredded.git
revision: 1340e913affd1af5fcc060fbccd271184ece9a6a
ref: 1340e913affd1af5fcc060fbccd271184ece9a6a
revision: 566100f6a020ccc390aa60689d58b007a55506d2
ref: 566100f6a020ccc390aa60689d58b007a55506d2
specs:
thredded (1.1.0)
active_record_union (>= 1.3.0)
Expand All @@ -26,11 +26,10 @@ GIT
nokogiri
onebox (>= 1.8.99)
pundit (>= 1.1.0)
rails (> 6.0.0.rc2)
rails (>= 7.0)
rails_gravatar
rinku
sanitize
sassc-rails (>= 2.0.0)
sprockets-es6
timeago_js (>= 3.0.2.2)

Expand All @@ -41,51 +40,46 @@ GEM
RubyInline (3.14.2)
ZenTest (~> 4.3)
ZenTest (4.12.2)
actioncable (7.1.5.1)
actionpack (= 7.1.5.1)
activesupport (= 7.1.5.1)
actioncable (7.2.2.1)
actionpack (= 7.2.2.1)
activesupport (= 7.2.2.1)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
zeitwerk (~> 2.6)
actionmailbox (7.1.5.1)
actionpack (= 7.1.5.1)
activejob (= 7.1.5.1)
activerecord (= 7.1.5.1)
activestorage (= 7.1.5.1)
activesupport (= 7.1.5.1)
mail (>= 2.7.1)
net-imap
net-pop
net-smtp
actionmailer (7.1.5.1)
actionpack (= 7.1.5.1)
actionview (= 7.1.5.1)
activejob (= 7.1.5.1)
activesupport (= 7.1.5.1)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
actionmailbox (7.2.2.1)
actionpack (= 7.2.2.1)
activejob (= 7.2.2.1)
activerecord (= 7.2.2.1)
activestorage (= 7.2.2.1)
activesupport (= 7.2.2.1)
mail (>= 2.8.0)
actionmailer (7.2.2.1)
actionpack (= 7.2.2.1)
actionview (= 7.2.2.1)
activejob (= 7.2.2.1)
activesupport (= 7.2.2.1)
mail (>= 2.8.0)
rails-dom-testing (~> 2.2)
actionpack (7.1.5.1)
actionview (= 7.1.5.1)
activesupport (= 7.1.5.1)
actionpack (7.2.2.1)
actionview (= 7.2.2.1)
activesupport (= 7.2.2.1)
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.5.1)
actionpack (= 7.1.5.1)
activerecord (= 7.1.5.1)
activestorage (= 7.1.5.1)
activesupport (= 7.1.5.1)
useragent (~> 0.16)
actiontext (7.2.2.1)
actionpack (= 7.2.2.1)
activerecord (= 7.2.2.1)
activestorage (= 7.2.2.1)
activesupport (= 7.2.2.1)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.1.5.1)
activesupport (= 7.1.5.1)
actionview (7.2.2.1)
activesupport (= 7.2.2.1)
builder (~> 3.1)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
Expand All @@ -103,38 +97,37 @@ GEM
activestorage (>= 6.1.4)
activesupport (>= 6.1.4)
marcel (>= 1.0.3)
activejob (7.1.5.1)
activesupport (= 7.1.5.1)
activejob (7.2.2.1)
activesupport (= 7.2.2.1)
globalid (>= 0.3.6)
activemodel (7.1.5.1)
activesupport (= 7.1.5.1)
activerecord (7.1.5.1)
activemodel (= 7.1.5.1)
activesupport (= 7.1.5.1)
activemodel (7.2.2.1)
activesupport (= 7.2.2.1)
activerecord (7.2.2.1)
activemodel (= 7.2.2.1)
activesupport (= 7.2.2.1)
timeout (>= 0.4.0)
activerecord-import (1.8.1)
activerecord (>= 4.2)
activerecord-nulldb-adapter (1.1.1)
activerecord (>= 6.0, < 8.1)
activestorage (7.1.5.1)
actionpack (= 7.1.5.1)
activejob (= 7.1.5.1)
activerecord (= 7.1.5.1)
activesupport (= 7.1.5.1)
activestorage (7.2.2.1)
actionpack (= 7.2.2.1)
activejob (= 7.2.2.1)
activerecord (= 7.2.2.1)
activesupport (= 7.2.2.1)
marcel (~> 1.0)
activesupport (7.1.5.1)
activesupport (7.2.2.1)
base64
benchmark (>= 0.3)
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
securerandom (>= 0.3)
tzinfo (~> 2.0)
tzinfo (~> 2.0, >= 2.0.5)
acts_as_list (1.2.4)
activerecord (>= 6.1)
activesupport (>= 6.1)
Expand Down Expand Up @@ -195,6 +188,7 @@ GEM
crass (1.0.6)
css_parser (1.21.1)
addressable
csv (3.3.4)
dalli (3.2.8)
database_cleaner-active_record (2.2.0)
activerecord (>= 5.a)
Expand Down Expand Up @@ -364,7 +358,6 @@ GEM
multi_json (1.15.0)
multipart-post (2.4.1)
mustache (1.1.1)
mutex_m (0.3.0)
net-imap (0.5.6)
date
net-protocol
Expand Down Expand Up @@ -453,20 +446,20 @@ GEM
rackup (1.0.1)
rack (< 3)
webrick
rails (7.1.5.1)
actioncable (= 7.1.5.1)
actionmailbox (= 7.1.5.1)
actionmailer (= 7.1.5.1)
actionpack (= 7.1.5.1)
actiontext (= 7.1.5.1)
actionview (= 7.1.5.1)
activejob (= 7.1.5.1)
activemodel (= 7.1.5.1)
activerecord (= 7.1.5.1)
activestorage (= 7.1.5.1)
activesupport (= 7.1.5.1)
rails (7.2.2.1)
actioncable (= 7.2.2.1)
actionmailbox (= 7.2.2.1)
actionmailer (= 7.2.2.1)
actionpack (= 7.2.2.1)
actiontext (= 7.2.2.1)
actionview (= 7.2.2.1)
activejob (= 7.2.2.1)
activemodel (= 7.2.2.1)
activerecord (= 7.2.2.1)
activestorage (= 7.2.2.1)
activesupport (= 7.2.2.1)
bundler (>= 1.15.0)
railties (= 7.1.5.1)
railties (= 7.2.2.1)
rails-dom-testing (2.2.0)
activesupport (>= 5.0.0)
minitest
Expand All @@ -484,10 +477,10 @@ GEM
railties (>= 6.0.0, < 8)
rails_gravatar (1.0.4)
actionview
railties (7.1.5.1)
actionpack (= 7.1.5.1)
activesupport (= 7.1.5.1)
irb
railties (7.2.2.1)
actionpack (= 7.2.2.1)
activesupport (= 7.2.2.1)
irb (~> 1.13)
rackup (>= 1.0.0)
rake (>= 12.2)
thor (~> 1.0, >= 1.2.2)
Expand Down Expand Up @@ -616,10 +609,10 @@ GEM
simplecov (~> 0.19)
simplecov-html (0.13.1)
simplecov_json_formatter (0.1.4)
spring (2.1.1)
spring-watcher-listen (2.0.1)
spring (4.3.0)
spring-watcher-listen (2.1.0)
listen (>= 2.7, < 4.0)
spring (>= 1.2, < 3.0)
spring (>= 4)
sprockets (4.2.2)
concurrent-ruby (~> 1.0)
logger
Expand Down Expand Up @@ -669,6 +662,7 @@ GEM
unicode-display_width (3.1.4)
unicode-emoji (~> 4.0, >= 4.0.4)
unicode-emoji (4.0.4)
useragent (0.16.11)
warden (1.2.9)
rack (>= 2.0.9)
web-console (4.2.1)
Expand All @@ -687,7 +681,7 @@ GEM
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
will_paginate (4.0.1)
zeitwerk (2.6.18)
zeitwerk (2.7.2)

PLATFORMS
aarch64-linux-gnu
Expand Down Expand Up @@ -718,6 +712,7 @@ DEPENDENCIES
coffee-rails (~> 5.0)
commontator (~> 7.0.1)
coveralls (~> 0.7)
csv (~> 3.3)
dalli (~> 3.2)
database_cleaner-active_record (~> 2.2)
devise (~> 4.9)
Expand Down Expand Up @@ -751,7 +746,7 @@ DEPENDENCIES
prometheus_exporter (~> 2.1)
puma (~> 6.4)
rack (~> 2.2)
rails (~> 7.1.3)
rails (~> 7.2.2)
rails-erd (~> 1.7)
rails-i18n (~> 7.0)
responders (~> 3.1)
Expand All @@ -769,7 +764,7 @@ DEPENDENCIES
sidekiq-cron (~> 1.12)
simplecov (~> 0.22)
simplecov-cobertura (~> 2.1)
spring (~> 2.1)
spring (~> 4.3)
spring-watcher-listen (~> 2.0)
sprockets-rails (~> 3.5)
streamio-ffmpeg (~> 3.0)
Expand All @@ -785,7 +780,7 @@ DEPENDENCIES
webpacker (~> 5.4)

RUBY VERSION
ruby 3.1.4p223
ruby 3.3.8p144

BUNDLED WITH
2.6.8
4 changes: 2 additions & 2 deletions app/helpers/email_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module EmailHelper
def email_image_tag(image, **options)
def email_image_tag(image, **)
attachments.inline[image] = Rails.root.join("public/#{image}").read
image_tag(attachments[image].url, **options)
image_tag(attachments[image].url, **)
end
end
4 changes: 2 additions & 2 deletions app/models/annotation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class Annotation < ApplicationRecord
# the timestamp for the annotation position is serialized as text in the db
serialize :timestamp, coder: TimeStamp

enum category: { note: 0, content: 1, mistake: 2, presentation: 3 }
enum subcategory: { definition: 0, argument: 1, strategy: 2 }
enum :category, { note: 0, content: 1, mistake: 2, presentation: 3 }
enum :subcategory, { definition: 0, argument: 1, strategy: 2 }

# If the annotation has an associated commontator comment, its comment will
# be saved in the commontator comment. While calling annotation.comment returns
Expand Down
1 change: 0 additions & 1 deletion app/models/interaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ class Interaction < InteractionsRecord
scope :created_between, lambda { |start_date, end_date|
where(created_at: start_date.beginning_of_day..end_date.end_of_day)
}
require "csv"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why you removed this line (also in other files)? This is not a RuboCop violation. Without this line, this class will throw an error if CSV is not magically loaded before loading this class and we don't want to risk that, right?

On another point: it'd be better to place this at the top of the file to be better visible since that's the usual place where we put the require statements.

Copy link
Member

@Splines Splines May 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"if CSV is not magically loaded before loading this class"

Turns out that's exactly what is done. But there's no magic: instead it is just the line Bundler.require(*Rails.groups) in config/application.rb which is responsible for this behavior. So indeed, removing these require lines as you did works just fine.

As CSV functionality is not used in many places, we might discuss if we instead want to do a gem "csv", "~> 3.3", require: false instead. Then, only require it at the respective places (at the very top of files that use the CSV class). Of course, one single gem doesn't cut startup times, but in total with many gems it might make a difference.


def self.to_csv
attributes = ["id", "session_id", "created_at", "full_path", "referrer_url",
Expand Down
1 change: 0 additions & 1 deletion app/models/probe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ class Probe < InteractionsRecord
scope :created_between, lambda { |start_date, end_date|
where(created_at: start_date.beginning_of_day..end_date.end_of_day)
}
require "csv"

def self.finished_quizzes(quiz)
Probe.where(quiz_id: quiz.id, progress: -1).count
Expand Down
2 changes: 0 additions & 2 deletions app/models/tutorial.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Tutorial model
class Tutorial < ApplicationRecord
require "csv"

belongs_to :lecture, touch: true

has_many :tutor_tutorial_joins, dependent: :destroy
Expand Down
Loading