Skip to content

Commit

Permalink
Upgrade to Rails 8.0 and apply new framework defaults
Browse files Browse the repository at this point in the history
* Disable cache_store during tests and re-enable it only explicitly
  • Loading branch information
MrSerth committed Dec 8, 2024
1 parent 87c4003 commit b643bd0
Show file tree
Hide file tree
Showing 26 changed files with 784 additions and 471 deletions.
4 changes: 1 addition & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ gem 'proformaxml', '~> 1.5.1'
gem 'prometheus_exporter'
gem 'puma'
gem 'pundit'
gem 'rails', '~> 7.2.2'
gem 'rails', '~> 8.0.0'
gem 'rails_admin'
gem 'rails-i18n'
gem 'rails-timeago'
Expand Down Expand Up @@ -75,8 +75,6 @@ group :development, :staging do
gem 'i18n-tasks'
gem 'letter_opener'
gem 'listen'
gem 'pry-byebug'
gem 'pry-rails'
gem 'rack-mini-profiler'
gem 'rubocop'
gem 'rubocop-capybara'
Expand Down
131 changes: 59 additions & 72 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,70 +9,69 @@ GIT
GEM
remote: https://rubygems.org/
specs:
actioncable (7.2.2)
actionpack (= 7.2.2)
activesupport (= 7.2.2)
actioncable (8.0.0)
actionpack (= 8.0.0)
activesupport (= 8.0.0)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
zeitwerk (~> 2.6)
actionmailbox (7.2.2)
actionpack (= 7.2.2)
activejob (= 7.2.2)
activerecord (= 7.2.2)
activestorage (= 7.2.2)
activesupport (= 7.2.2)
actionmailbox (8.0.0)
actionpack (= 8.0.0)
activejob (= 8.0.0)
activerecord (= 8.0.0)
activestorage (= 8.0.0)
activesupport (= 8.0.0)
mail (>= 2.8.0)
actionmailer (7.2.2)
actionpack (= 7.2.2)
actionview (= 7.2.2)
activejob (= 7.2.2)
activesupport (= 7.2.2)
actionmailer (8.0.0)
actionpack (= 8.0.0)
actionview (= 8.0.0)
activejob (= 8.0.0)
activesupport (= 8.0.0)
mail (>= 2.8.0)
rails-dom-testing (~> 2.2)
actionpack (7.2.2)
actionview (= 7.2.2)
activesupport (= 7.2.2)
actionpack (8.0.0)
actionview (= 8.0.0)
activesupport (= 8.0.0)
nokogiri (>= 1.8.5)
racc
rack (>= 2.2.4, < 3.2)
rack (>= 2.2.4)
rack-session (>= 1.0.1)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
useragent (~> 0.16)
actiontext (7.2.2)
actionpack (= 7.2.2)
activerecord (= 7.2.2)
activestorage (= 7.2.2)
activesupport (= 7.2.2)
actiontext (8.0.0)
actionpack (= 8.0.0)
activerecord (= 8.0.0)
activestorage (= 8.0.0)
activesupport (= 8.0.0)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.2.2)
activesupport (= 7.2.2)
actionview (8.0.0)
activesupport (= 8.0.0)
builder (~> 3.1)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
activejob (7.2.2)
activesupport (= 7.2.2)
activejob (8.0.0)
activesupport (= 8.0.0)
globalid (>= 0.3.6)
activemodel (7.2.2)
activesupport (= 7.2.2)
activemodel (8.0.0)
activesupport (= 8.0.0)
activemodel-serializers-xml (1.0.3)
activemodel (>= 5.0.0.a)
activesupport (>= 5.0.0.a)
builder (~> 3.1)
activerecord (7.2.2)
activemodel (= 7.2.2)
activesupport (= 7.2.2)
activerecord (8.0.0)
activemodel (= 8.0.0)
activesupport (= 8.0.0)
timeout (>= 0.4.0)
activestorage (7.2.2)
actionpack (= 7.2.2)
activejob (= 7.2.2)
activerecord (= 7.2.2)
activesupport (= 7.2.2)
activestorage (8.0.0)
actionpack (= 8.0.0)
activejob (= 8.0.0)
activerecord (= 8.0.0)
activesupport (= 8.0.0)
marcel (~> 1.0)
activesupport (7.2.2)
activesupport (8.0.0)
base64
benchmark (>= 0.3)
bigdecimal
Expand All @@ -84,6 +83,7 @@ GEM
minitest (>= 5.1)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
uri (>= 0.13.1)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
amq-protocol (2.3.2)
Expand Down Expand Up @@ -111,7 +111,6 @@ GEM
bunny (2.23.0)
amq-protocol (~> 2.3, >= 2.3.1)
sorted_set (~> 1, >= 1.0.2)
byebug (11.1.3)
capybara (3.40.0)
addressable
matrix
Expand All @@ -133,7 +132,6 @@ GEM
childprocess (5.1.0)
logger (~> 1.5)
chronic (0.10.2)
coderay (1.1.3)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
cose (1.3.1)
Expand Down Expand Up @@ -267,7 +265,6 @@ GEM
net-smtp
marcel (1.0.4)
matrix (0.4.2)
method_source (1.1.0)
mimemagic (0.4.3)
nokogiri (~> 1)
rake
Expand Down Expand Up @@ -330,14 +327,6 @@ GEM
rubyzip (>= 1.2.2, < 3.0.0)
prometheus_exporter (2.2.0)
webrick
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
pry-byebug (3.10.1)
byebug (~> 11.0)
pry (>= 0.13, < 0.15)
pry-rails (0.3.11)
pry (>= 0.13.0)
psych (5.2.1)
date
stringio
Expand All @@ -359,20 +348,20 @@ GEM
rack (>= 1.3)
rackup (2.2.1)
rack (>= 3)
rails (7.2.2)
actioncable (= 7.2.2)
actionmailbox (= 7.2.2)
actionmailer (= 7.2.2)
actionpack (= 7.2.2)
actiontext (= 7.2.2)
actionview (= 7.2.2)
activejob (= 7.2.2)
activemodel (= 7.2.2)
activerecord (= 7.2.2)
activestorage (= 7.2.2)
activesupport (= 7.2.2)
rails (8.0.0)
actioncable (= 8.0.0)
actionmailbox (= 8.0.0)
actionmailer (= 8.0.0)
actionpack (= 8.0.0)
actiontext (= 8.0.0)
actionview (= 8.0.0)
activejob (= 8.0.0)
activemodel (= 8.0.0)
activerecord (= 8.0.0)
activestorage (= 8.0.0)
activesupport (= 8.0.0)
bundler (>= 1.15.0)
railties (= 7.2.2)
railties (= 8.0.0)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
actionview (>= 5.0.1.rc1)
Expand All @@ -384,9 +373,9 @@ GEM
rails-html-sanitizer (1.6.1)
loofah (~> 2.21)
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)
rails-i18n (7.0.10)
rails-i18n (8.0.1)
i18n (>= 0.7, < 2)
railties (>= 6.0.0, < 8)
railties (>= 8.0.0, < 9)
rails-timeago (2.20.0)
actionpack (>= 5.2)
activesupport (>= 5.2)
Expand All @@ -397,9 +386,9 @@ GEM
nested_form (~> 0.3)
rails (>= 6.0, < 9)
turbo-rails (>= 1.0, < 3)
railties (7.2.2)
actionpack (= 7.2.2)
activesupport (= 7.2.2)
railties (8.0.0)
actionpack (= 8.0.0)
activesupport (= 8.0.0)
irb (~> 1.13)
rackup (>= 1.0.0)
rake (>= 12.2)
Expand Down Expand Up @@ -545,7 +534,7 @@ GEM
fugit (~> 1.11.0)
railties (>= 7.1)
thor (~> 1.3.1)
sorbet-runtime (0.5.11685)
sorbet-runtime (0.5.11690)
sorcery (0.17.0)
bcrypt (~> 3.1)
oauth (>= 0.6)
Expand Down Expand Up @@ -662,12 +651,10 @@ DEPENDENCIES
pg
proformaxml (~> 1.5.1)
prometheus_exporter
pry-byebug
pry-rails
puma
pundit
rack-mini-profiler
rails (~> 7.2.2)
rails (~> 8.0.0)
rails-controller-testing
rails-i18n
rails-timeago
Expand Down
2 changes: 2 additions & 0 deletions bin/dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env ruby
exec "./bin/rails", "server", *ARGV
14 changes: 5 additions & 9 deletions bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

require 'fileutils'

# path to your application root.
APP_ROOT = File.expand_path('..', __dir__)
APP_NAME = 'codeocean'

def system!(*)
system(*, exception: true)
Expand All @@ -17,7 +15,6 @@ FileUtils.chdir APP_ROOT do
# Add necessary setup steps to this file.

puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')

# Install JavaScript dependencies
Expand All @@ -36,10 +33,9 @@ FileUtils.chdir APP_ROOT do
puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'

puts "\n== Restarting application server =="
system! 'bin/rails restart'

# puts "\n== Configuring puma-dev =="
# system "ln -nfs #{APP_ROOT} ~/.puma-dev/#{APP_NAME}"
# system "curl -Is https://#{APP_NAME}.test/up | head -n 1"
unless ARGV.include?('--skip-server')
puts "\n== Starting development server =="
$stdout.flush # flush the output before exec(2) so that it displays
exec 'bin/dev'
end
end
5 changes: 5 additions & 0 deletions bin/thrust
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env ruby
require "rubygems"
require "bundler/setup"

load Gem.bin_path("thruster", "thrust")
2 changes: 1 addition & 1 deletion config/action_mailer.yml.ci
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ test:
default_options:
from: 'CodeOcean <[email protected]>'
default_url_options:
host: localhost
host: example.com
delivery_method: :test
2 changes: 1 addition & 1 deletion config/action_mailer.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ production:
test:
<<: *default
default_url_options:
host: localhost
host: example.com
delivery_method: :test
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
module CodeOcean
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.2
config.load_defaults 8.0

# Please, add to the `ignore` list any other `lib` subdirectories that do
# not contain `.rb` files, or that should not be reloaded or eager loaded.
Expand Down
26 changes: 13 additions & 13 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@
private_ips.each {|ip| BetterErrors::Middleware.allow_ip! ip }
end

# In the development environment your application's code is reloaded any time
# it changes. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
# Make code changes take effect immediately without server restart.
config.enable_reloading = true

# Eager load code for prometheus exporter
# Eager load code for prometheus exporter.
config.eager_load = true

# Show full error reports.
Expand All @@ -29,22 +27,21 @@
# Enable server timing.
config.server_timing = true

# Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching.
# Enable/disable Action Controller caching. By default Action Controller caching is disabled.
# Run rails dev:cache to toggle Action Controller caching.
if Rails.root.join('tmp/caching-dev.txt').exist?
config.action_controller.perform_caching = true
config.action_controller.enable_fragment_cache_logging = true

config.cache_store = :memory_store
config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{2.days.to_i}",
'cache-control' => "public, max-age=#{2.days.to_i}",
}
else
config.action_controller.perform_caching = false

config.cache_store = :null_store
end

# Change to :null_store to avoid any caching.
config.cache_store = :memory_store

# Store uploaded files on the local file system (see config/storage.yml for options).
config.active_storage.service = :local

Expand All @@ -56,10 +53,10 @@
config.solid_queue.connects_to = {database: {writing: :queue}}
config.active_job.queue_name_prefix = 'codeocean_development'

# Disable caching for Action Mailer templates even if Action Controller
# caching is enabled.
# Make template changes take effect immediately.
config.action_mailer.perform_caching = false

# Set localhost to be used by links generated in mailer templates.
config.action_mailer.default_url_options = {host: 'localhost', port: 7000}

# Print deprecation notices to the Rails logger.
Expand All @@ -77,6 +74,9 @@
# Highlight code that triggered database queries in logs.
config.active_record.verbose_query_logs = true

# Append comments with runtime information tags to SQL queries in logs.
config.active_record.query_log_tags_enabled = true

# Highlight code that enqueued background job in logs.
config.active_job.verbose_enqueue_logs = true

Expand Down
Loading

0 comments on commit b643bd0

Please sign in to comment.