Skip to content

Commit

Permalink
Enable eager loading by default on CI systems
Browse files Browse the repository at this point in the history
This is a pattern we've been using for ages at Shopify.

When you are running test locally, most of the time you
run only a subset, so it's better to load as little code
as possible to have a faster time to first test result.

But when you are on CI, it's usally much preferable to
eager load the whole application because you will likely
need all the code anyway, and even if the test suite is
split across runners, it's preferable to load
all the code to ensure any codefile that may have side
effects is loaded.

This also ensure that if some autoloaded constants are
not properly tested on CI, at least they'll be loaded
and obvious errors (e.g. SyntaxError) will be caught on
CI rather than during deploy.
  • Loading branch information
byroot committed Oct 22, 2021
1 parent 2451a56 commit db0ee28
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Rails.application.configure do
# Do not eager load code on boot. This avoids loading your whole application
# just for the purpose of running a single test. If you are using a tool that
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false
config.eager_load = ENV["CI"].present?

# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true
Expand Down

0 comments on commit db0ee28

Please sign in to comment.