]> cat aescling's git repositories - mastodon.git/commitdiff
Fix building assets in test environment (#8691)
authorThibG <thib@sitedethib.com>
Thu, 13 Sep 2018 13:18:47 +0000 (15:18 +0200)
committerEugen Rochko <eugen@zeonfederated.com>
Thu, 13 Sep 2018 13:18:47 +0000 (15:18 +0200)
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

config/webpack/configuration.js
config/webpacker.yml

index cf8c0c7e1d33bd4a9a1c6c16107901b0958ca163..4d325a82877197bc37aa1e61606866f7c7766c48 100644 (file)
@@ -7,7 +7,7 @@ const { readFileSync } = require('fs');
 
 const configPath = resolve('config', 'webpacker.yml');
 const loadersDir = join(__dirname, 'loaders');
-const settings = safeLoad(readFileSync(configPath), 'utf8')[env.NODE_ENV];
+const settings = safeLoad(readFileSync(configPath), 'utf8')[env.RAILS_ENV || env.NODE_ENV];
 
 const themePath = resolve('config', 'themes.yml');
 const themes = safeLoad(readFileSync(themePath), 'utf8');
index 8d8470651ac41cc583317e49cecd0b0502b763f0..ea814a0e65f6156c250551d3174205b2a5243689 100644 (file)
@@ -40,6 +40,10 @@ test:
   # Compile test packs to a separate directory
   public_output_path: packs-test
 
+  # CircleCI precompiles packs prior to running the tests.
+  # Also avoids race conditions in parallel_tests.
+  compile: false
+
 production:
   <<: *default