Skip to content

Commit 988cab0

Browse files
ClearlyClaireroot
authored andcommitted
Fix building assets in test environment (mastodon#8691)
Webpacker (Ruby wrapper to webpack) uses RAILS_ENV-based environments while the javascript configuration for webpack re-reads this configuration file using the NODE_ENV environment variable. This means that when RAILS_ENV=test, running “assets:precompile” compiled the production packs in “public/packs” while webpacker expects them in “public/packs-test”. This causes Ruby to recompile them on-the-fly, possibly leading to race conditions in parallel_tests. This changes: - Disables on-the-fly compilation in test environment - Changes the javascript part to read the correct environment
1 parent aa504fa commit 988cab0

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

config/webpack/configuration.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const { readFileSync } = require('fs');
77

88
const configPath = resolve('config', 'webpacker.yml');
99
const loadersDir = join(__dirname, 'loaders');
10-
const settings = safeLoad(readFileSync(configPath), 'utf8')[env.NODE_ENV];
10+
const settings = safeLoad(readFileSync(configPath), 'utf8')[env.RAILS_ENV || env.NODE_ENV];
1111

1212
const themePath = resolve('config', 'themes.yml');
1313
const themes = safeLoad(readFileSync(themePath), 'utf8');

config/webpacker.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ test:
4040
# Compile test packs to a separate directory
4141
public_output_path: packs-test
4242

43+
# CircleCI precompiles packs prior to running the tests.
44+
# Also avoids race conditions in parallel_tests.
45+
compile: false
46+
4347
production:
4448
<<: *default
4549

0 commit comments

Comments
 (0)