Skip to content

Commit

Permalink
馃彈 Small changes to Travis build matrix utility class (ampproject#20996)
Browse files Browse the repository at this point in the history
  • Loading branch information
estherkim authored and Noran Azmy committed Mar 22, 2019
1 parent 12e35aa commit f12854b
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 34 deletions.
10 changes: 5 additions & 5 deletions build-system/pr-check/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ function main() {
// Make sure package.json and yarn.lock are in sync and up-to-date.
if (!isYarnLockFileInSync(FILENAME) ||
!isYarnLockFileProperlyUpdated(FILENAME)) {
return 1;
process.exitCode = 1;
return;
}

const buildTargets = determineBuildTargets();
if (!areValidBuildTargets(buildTargets, FILENAME)) {
stopTimer(FILENAME, FILENAME, startTime);
return 1;
process.exitCode = 1;
return;
}

if (!isTravisPullRequestBuild()) {
Expand Down Expand Up @@ -79,8 +81,6 @@ function main() {
}

stopTimer(FILENAME, FILENAME, startTime);
return 0;
}

process.exit(main());

main();
3 changes: 1 addition & 2 deletions build-system/pr-check/checks.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ function main() {
}

stopTimer(FILENAME, FILENAME, startTime);
return 0;
}

process.exit(main());
main();
3 changes: 1 addition & 2 deletions build-system/pr-check/dist-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ function main() {
}

stopTimer(FILENAME, FILENAME, startTime);
return 0;
}

process.exit(main());
main();
3 changes: 1 addition & 2 deletions build-system/pr-check/dist.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ function main() {
}

stopTimer(FILENAME, FILENAME, startTime);
return 0;
}

process.exit(main());
main();
5 changes: 2 additions & 3 deletions build-system/pr-check/local-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function main() {
'because this commit not affect the runtime, build system, ' +
'unit test files, integration test files, or the dev dashboard.');
stopTimer(FILENAME, FILENAME, startTime);
return 0;
return;
}
downloadBuildOutput(FILENAME);
timedExecOrDie('gulp update-packages');
Expand Down Expand Up @@ -91,7 +91,6 @@ function main() {
}

stopTimer(FILENAME, FILENAME, startTime);
return 0;
}

process.exit(main());
main();
14 changes: 8 additions & 6 deletions build-system/pr-check/remote-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,18 @@ const FILELOGPREFIX = colors.bold(colors.yellow(`${FILENAME}:`));
const timedExecOrDie =
(cmd, unusedFileName) => timedExecOrDieBase(cmd, FILENAME);

function main() {
async function main() {
const startTime = startTimer(FILENAME, FILENAME);
const buildTargets = determineBuildTargets();

if (!isTravisPullRequestBuild()) {
downloadBuildOutput(FILENAME);
downloadDistOutput(FILENAME);
startSauceConnect(FILENAME);

await startSauceConnect(FILENAME);
timedExecOrDie('gulp test --unit --nobuild --saucelabs_lite');
timedExecOrDie('gulp test --integration --nobuild --compiled --saucelabs');

stopSauceConnect(FILENAME);
} else {
printChangeSummary(FILENAME);
Expand All @@ -61,11 +64,11 @@ function main() {
'because this commit does not affect the runtime, ' +
'build system, or integration test files.');
stopTimer(FILENAME, FILENAME, startTime);
return 0;
return;
}
downloadBuildOutput(FILENAME);
timedExecOrDie('gulp update-packages');
startSauceConnect(FILENAME);
await startSauceConnect(FILENAME);

if (buildTargets.has('RUNTIME') ||
buildTargets.has('BUILD_SYSTEM') ||
Expand All @@ -82,7 +85,6 @@ function main() {
}

stopTimer(FILENAME, FILENAME, startTime);
return 0;
}

process.exit(main());
main();
15 changes: 8 additions & 7 deletions build-system/pr-check/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
'use strict';

const colors = require('ansi-colors');
const requestPromise = require('request-promise');
const {
gitBranchName,
gitDiffCommitLog,
Expand All @@ -24,7 +25,7 @@ const {
gitTravisMasterBaseline,
shortSha,
} = require('../git');
const {execOrDie, exec, getStdout} = require('../exec');
const {execOrDie, exec} = require('../exec');
const {isTravisBuild, travisBuildNumber, travisPullRequestSha} = require('../travis');

const BUILD_OUTPUT_FILE =
Expand Down Expand Up @@ -65,10 +66,10 @@ function printChangeSummary(fileName) {
* Starts connection to Sauce Labs after getting account credentials
* @param {string} functionName
*/
function startSauceConnect(functionName) {
async function startSauceConnect(functionName) {
process.env['SAUCE_USERNAME'] = 'amphtml';
process.env['SAUCE_ACCESS_KEY'] = getStdout('curl --silent ' +
'https://amphtml-sauce-token-dealer.appspot.com/getJwtToken').trim();
const response = await requestPromise('https://amphtml-sauce-token-dealer.appspot.com/getJwtToken');
process.env['SAUCE_ACCESS_KEY'] = response.trim();
const startScCmd = 'build-system/sauce_connect/start_sauce_connect.sh';
const fileLogPrefix = colors.bold(colors.yellow(`${functionName}:`));
console.log('\n' + fileLogPrefix,
Expand Down Expand Up @@ -111,9 +112,9 @@ function startTimer(functionName, fileName) {
*/
function stopTimer(functionName, fileName, startTime) {
const endTime = Date.now();
const executionTime = new Date(endTime - startTime);
const mins = executionTime.getMinutes();
const secs = executionTime.getSeconds();
const executionTime = endTime - startTime;
const mins = Math.floor(executionTime / 60000);
const secs = Math.floor(executionTime % 60000 / 1000);
const fileLogPrefix = colors.bold(colors.yellow(`${fileName}:`));
console.log(
fileLogPrefix, 'Done running', colors.cyan(functionName),
Expand Down
3 changes: 1 addition & 2 deletions build-system/pr-check/validator-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ function main() {
}

stopTimer(FILENAME, FILENAME, startTime);
return 0;
}

process.exit(main());
main();
3 changes: 1 addition & 2 deletions build-system/pr-check/visual-diff-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ function main() {
}

stopTimer(FILENAME, FILENAME, startTime);
return 0;
}

process.exit(main());
main();
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@
"react-with-direction": "1.3.0",
"regexp.escape": "1.0.2",
"request": "2.88.0",
"request-promise": "4.2.4",
"rimraf": "2.6.2",
"rocambole": "0.7.0",
"rollup": "0.68.2",
Expand Down
23 changes: 20 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2748,7 +2748,7 @@ bluebird@3.5.2:
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.2.tgz#1be0908e054a751754549c270489c1505d4ab15a"
integrity sha512-dhHTWMI7kMx5whMQntl7Vr9C6BvV10lFXDAasnqnrMYhXVCzzk6IO9Fo2L75jXHT07WrOngL1WDXOp+yYS91Yg==

bluebird@^3.0.0, bluebird@^3.3.0, bluebird@^3.5.3:
bluebird@^3.0.0, bluebird@^3.3.0, bluebird@^3.5.0, bluebird@^3.5.3:
version "3.5.3"
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.3.tgz#7d01c6f9616c9a51ab0f8c549a79dfe6ec33efa7"
integrity sha512-/qKPUQlaW1OyR51WeCPBvRnAlnZFUJkCSG5HzGnuIqhgyJtF+T94lFnn33eiazjRm2LAHVy2guNnaq48X9SJuw==
Expand Down Expand Up @@ -12533,6 +12533,13 @@ request-promise-core@1.1.1:
dependencies:
lodash "^4.13.1"

request-promise-core@1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/request-promise-core/-/request-promise-core-1.1.2.tgz#339f6aababcafdb31c799ff158700336301d3346"
integrity sha512-UHYyq1MO8GsefGEt7EprS8UrXsm1TxEvFUX1IMTuSLU2Rh7fTIdFtl8xD7JiEYiWU2dl+NYAjCTksTehQUxPag==
dependencies:
lodash "^4.17.11"

request-promise-native@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/request-promise-native/-/request-promise-native-1.0.5.tgz#5281770f68e0c9719e5163fd3fab482215f4fda5"
Expand All @@ -12542,6 +12549,16 @@ request-promise-native@^1.0.5:
stealthy-require "^1.1.0"
tough-cookie ">=2.3.3"

request-promise@4.2.4:
version "4.2.4"
resolved "https://registry.yarnpkg.com/request-promise/-/request-promise-4.2.4.tgz#1c5ed0d71441e38ad58c7ce4ea4ea5b06d54b310"
integrity sha512-8wgMrvE546PzbR5WbYxUQogUnUDfM0S7QIFZMID+J73vdFARkFy+HElj4T+MWYhpXwlLp0EQ8Zoj8xUA0he4Vg==
dependencies:
bluebird "^3.5.0"
request-promise-core "1.1.2"
stealthy-require "^1.1.1"
tough-cookie "^2.3.3"

request@2.88.0, request@^2.87.0, request@^2.88.0:
version "2.88.0"
resolved "https://registry.yarnpkg.com/request/-/request-2.88.0.tgz#9c2fca4f7d35b592efe57c7f0a55e81052124fef"
Expand Down Expand Up @@ -13467,7 +13484,7 @@ statuses@~1.4.0:
resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.4.0.tgz#bb73d446da2796106efcc1b601a253d6c46bd087"
integrity sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==

stealthy-require@^1.1.0:
stealthy-require@^1.1.0, stealthy-require@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/stealthy-require/-/stealthy-require-1.1.1.tgz#35b09875b4ff49f26a777e509b3090a3226bf24b"
integrity sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks=
Expand Down Expand Up @@ -14133,7 +14150,7 @@ touch@3.1.0, touch@^3.1.0:
dependencies:
nopt "~1.0.10"

tough-cookie@>=2.3.3, tough-cookie@^2.3.4, tough-cookie@^2.5.0:
tough-cookie@>=2.3.3, tough-cookie@^2.3.3, tough-cookie@^2.3.4, tough-cookie@^2.5.0:
version "2.5.0"
resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.5.0.tgz#cd9fb2a0aa1d5a12b473bd9fb96fa3dcff65ade2"
integrity sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==
Expand Down

0 comments on commit f12854b

Please sign in to comment.