DEV: Check Zeitwerk eager loading in GitHub CI (#20699)
In production, `eager_load=true`. This sometimes leads to boot errors which are not present in dev/test environments. Running `zeitwerk:check` in CI will help us to pick up on any errors early. This commit also introduces a `DISCOURSE_ZEITWERK_EAGER_LOAD` environment variable to make it easier to toggle the behaviour when developing locally.
This commit is contained in:
parent
9d1423b5aa
commit
150a6601c0
|
@ -159,6 +159,22 @@ jobs:
|
||||||
path: tmp/turbo_rspec_runtime.log
|
path: tmp/turbo_rspec_runtime.log
|
||||||
key: rspec-runtime-backend-core
|
key: rspec-runtime-backend-core
|
||||||
|
|
||||||
|
- name: Run Zeitwerk check
|
||||||
|
if: matrix.build_type == 'backend'
|
||||||
|
env:
|
||||||
|
LOAD_PLUGINS: ${{ (matrix.target == 'plugins') && '1' || '0' }}
|
||||||
|
run: |
|
||||||
|
if ! bin/rails zeitwerk:check --trace; then
|
||||||
|
echo
|
||||||
|
echo "---------------------------------------------"
|
||||||
|
echo
|
||||||
|
echo "::error::'bin/rails zeitwerk:check' failed - the app will fail to boot with 'eager_load=true' (e.g. in production)."
|
||||||
|
echo "To reproduce locally, run 'bin/rails zeitwerk:check'."
|
||||||
|
echo "Alternatively, you can run your local server/tests with the 'DISCOURSE_ZEITWERK_EAGER_LOAD=1' environment variable."
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Core RSpec
|
- name: Core RSpec
|
||||||
if: matrix.build_type == 'backend' && matrix.target == 'core'
|
if: matrix.build_type == 'backend' && matrix.target == 'core'
|
||||||
run: bin/turbo_rspec --verbose
|
run: bin/turbo_rspec --verbose
|
||||||
|
|
|
@ -9,7 +9,7 @@ Discourse::Application.configure do
|
||||||
config.cache_classes = false
|
config.cache_classes = false
|
||||||
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
|
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
|
||||||
|
|
||||||
config.eager_load = false
|
config.eager_load = ENV["DISCOURSE_ZEITWERK_EAGER_LOAD"] == "1"
|
||||||
|
|
||||||
# Use the schema_cache.yml file generated during db:migrate (via db:schema:cache:dump)
|
# Use the schema_cache.yml file generated during db:migrate (via db:schema:cache:dump)
|
||||||
config.active_record.use_schema_cache_dump = true
|
config.active_record.use_schema_cache_dump = true
|
||||||
|
|
|
@ -44,7 +44,7 @@ Discourse::Application.configure do
|
||||||
config.assets.compile = true
|
config.assets.compile = true
|
||||||
config.assets.digest = false
|
config.assets.digest = false
|
||||||
|
|
||||||
config.eager_load = false
|
config.eager_load = ENV["DISCOURSE_ZEITWERK_EAGER_LOAD"] == "1"
|
||||||
|
|
||||||
if ENV["RAILS_ENABLE_TEST_LOG"]
|
if ENV["RAILS_ENABLE_TEST_LOG"]
|
||||||
config.logger = Logger.new(STDOUT)
|
config.logger = Logger.new(STDOUT)
|
||||||
|
|
Loading…
Reference in New Issue