Skip to content

Commit

Permalink
♻️ Refactor dist --fortesting into commons/utils (ampproject#27199)
Browse files Browse the repository at this point in the history
  • Loading branch information
Micajuine Ho authored and twintwox committed Mar 24, 2020
1 parent 6251f68 commit 1e14c11
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
10 changes: 10 additions & 0 deletions build-system/common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ const {isTravisBuild} = require('./travis');

const ROOT_DIR = path.resolve(__dirname, '../../');

/**
* Cleans and builds binaries with --fortesting flag and
* overriden config.
*/
function buildMinifiedRuntime() {
execOrDie('gulp clean');
execOrDie(`gulp dist --fortesting --config ${argv.config}`);
}

/**
* Logs a message on the same line to indicate progress
*
Expand Down Expand Up @@ -137,6 +146,7 @@ function installPackages(dir) {
}

module.exports = {
buildMinifiedRuntime,
getFilesChanged,
getFilesToCheck,
installPackages,
Expand Down
10 changes: 2 additions & 8 deletions build-system/tasks/e2e/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ const glob = require('glob');
const log = require('fancy-log');
const Mocha = require('mocha');
const path = require('path');
const {buildMinifiedRuntime, installPackages} = require('../../common/utils');
const {cyan} = require('ansi-colors');
const {execOrDie} = require('../../common/exec');
const {installPackages} = require('../../common/utils');
const {isTravisBuild} = require('../../common/travis');
const {reportTestStarted} = require('../report-test-status');
const {startServer, stopServer} = require('../serve');
Expand All @@ -36,11 +35,6 @@ const PORT = 8000;
const SLOW_TEST_THRESHOLD_MS = 2500;
const TEST_RETRIES = isTravisBuild() ? 2 : 0;

function buildRuntime_() {
execOrDie('gulp clean');
execOrDie(`gulp dist --fortesting --config ${argv.config}`);
}

async function launchWebServer_() {
await startServer(
{host: HOST, port: PORT},
Expand Down Expand Up @@ -86,7 +80,7 @@ async function e2e() {

// build runtime
if (!argv.nobuild) {
buildRuntime_();
buildMinifiedRuntime();
}

// start up web server
Expand Down
7 changes: 3 additions & 4 deletions build-system/tasks/visual-diff/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ const {
gitTravisMasterBaseline,
shortSha,
} = require('../../common/git');
const {execOrDie, execScriptAsync} = require('../../common/exec');
const {installPackages} = require('../../common/utils');
const {buildMinifiedRuntime, installPackages} = require('../../common/utils');
const {execScriptAsync} = require('../../common/exec');
const {isTravisBuild} = require('../../common/travis');
const {startServer, stopServer} = require('../serve');
const {waitUntilUsed} = require('tcp-port-used');
Expand Down Expand Up @@ -760,8 +760,7 @@ async function ensureOrBuildAmpRuntimeInTestMode_() {
);
}
} else {
execOrDie('gulp clean');
execOrDie(`gulp dist --fortesting --config ${argv.config}`);
buildMinifiedRuntime();
}
}

Expand Down

0 comments on commit 1e14c11

Please sign in to comment.