summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Greiling <mike@pixelcog.com>2019-09-11 16:36:18 +0000
committerClement Ho <408677-ClemMakesApps@users.noreply.gitlab.com>2019-09-11 16:36:18 +0000
commit1c621da36250b18a4e3b9f76c748d69df9255f33 (patch)
tree168d6258d177037905d6be7026f7b96f6726f501
parent70302281d70b65bd0653f9f3732e5dbbbbc98753 (diff)
downloadgitlab-ce-1c621da36250b18a4e3b9f76c748d69df9255f33.tar.gz
Add webpack memory test to CI
-rw-r--r--.gitlab/ci/frontend.gitlab-ci.yml14
-rw-r--r--config/webpack.config.js25
2 files changed, 39 insertions, 0 deletions
diff --git a/.gitlab/ci/frontend.gitlab-ci.yml b/.gitlab/ci/frontend.gitlab-ci.yml
index a20215694c0..b2058506ea1 100644
--- a/.gitlab/ci/frontend.gitlab-ci.yml
+++ b/.gitlab/ci/frontend.gitlab-ci.yml
@@ -232,3 +232,17 @@ qa-frontend-node:latest:
extends: .qa-frontend-node
image: node:latest
allow_failure: true
+
+webpack-dev-server:
+ extends:
+ - .default-tags
+ - .default-retry
+ - .default-cache
+ - .except-docs-qa
+ dependencies: ["compile-assets", "compile-assets pull-cache", "setup-test-env"]
+ variables:
+ SETUP_DB: "false"
+ WEBPACK_MEMORY_TEST: "true"
+ script:
+ - node --version
+ - node --expose-gc node_modules/.bin/webpack-dev-server --config config/webpack.config.js
diff --git a/config/webpack.config.js b/config/webpack.config.js
index 969a84e85dd..f3f0a5f8934 100644
--- a/config/webpack.config.js
+++ b/config/webpack.config.js
@@ -17,6 +17,7 @@ const DEV_SERVER_HOST = process.env.DEV_SERVER_HOST || 'localhost';
const DEV_SERVER_PORT = parseInt(process.env.DEV_SERVER_PORT, 10) || 3808;
const DEV_SERVER_LIVERELOAD = IS_DEV_SERVER && process.env.DEV_SERVER_LIVERELOAD !== 'false';
const WEBPACK_REPORT = process.env.WEBPACK_REPORT;
+const WEBPACK_MEMORY_TEST = process.env.WEBPACK_MEMORY_TEST;
const NO_COMPRESSION = process.env.NO_COMPRESSION;
const NO_SOURCEMAPS = process.env.NO_SOURCEMAPS;
@@ -337,6 +338,30 @@ module.exports = {
},
},
+ // output the in-memory heap size upon compilation and exit
+ WEBPACK_MEMORY_TEST && {
+ apply(compiler) {
+ compiler.hooks.emit.tapAsync('ReportMemoryConsumptionPlugin', (compilation, callback) => {
+ console.log('Assets compiled...');
+ if (global.gc) {
+ console.log('Running garbage collection...');
+ global.gc();
+ } else {
+ console.error(
+ "WARNING: you must use the --expose-gc node option to accurately measure webpack's heap size",
+ );
+ }
+ const memoryUsage = process.memoryUsage().heapUsed;
+ const toMB = bytes => Math.floor(bytes / 1024 / 1024);
+
+ console.log(`Webpack heap size: ${toMB(memoryUsage)} MB`);
+
+ // exit in case we're running webpack-dev-server
+ IS_DEV_SERVER && process.exit();
+ });
+ },
+ },
+
// enable HMR only in webpack-dev-server
DEV_SERVER_LIVERELOAD && new webpack.HotModuleReplacementPlugin(),