Skip to content

Commit 6adbfd1

Browse files
committed
build: cancel screenshot diff if there is no activity
* No longer just gives the screenshot diff task 8 minutes to pass, because the run time can vary. Now it just exits the process if the last action in the task takes longer than 6 minutes. * Instead of just closing the firebase connection, the process will be exited with an error code. Just closing the connection is not helpful and breaks the screenshot diff Web Interface.
1 parent dfe01f2 commit 6adbfd1

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

tools/gulp/tasks/screenshots.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ const FIREBASE_IMAGE = `${TEMP_FOLDER}/screenshot/images`;
3434
const FIREBASE_DATA_GOLDENS = `screenshot/goldens`;
3535
const FIREBASE_STORAGE_GOLDENS = 'goldens';
3636

37+
const lastActionTimeout = 1000 * 60 * 6;
38+
const lastActionRefreshInterval = 1000 * 45;
39+
3740
/** Task which upload screenshots generated from e2e test. */
3841
task('screenshots', () => {
3942
const prNumber = process.env['TRAVIS_PULL_REQUEST'];
@@ -45,13 +48,18 @@ task('screenshots', () => {
4548
const firebaseApp = connectFirebaseScreenshots();
4649
const database = firebaseApp.database();
4750

51+
let lastActionTime = Date.now();
52+
4853
// If this task hasn't completed in 8 minutes, close the firebase connection.
49-
const timeoutId = setTimeout(() => {
50-
console.error('Screenshot tests did not finish in 8 minutes, closing Firebase connection.');
51-
return firebaseApp.delete();
52-
}, 60 * 1000 * 8);
54+
const timeoutId = setInterval(() => {
55+
if (lastActionTime + lastActionTimeout <= Date.now()) {
56+
clearTimeout(timeoutId);
57+
console.error('Last action for screenshot tests did not finish in ' +
58+
(lastActionTime / 1000 / 60) + ' minutes. Closing Firebase connection...');
59+
return firebaseApp.delete().then(() => process.exit(1));
60+
}
61+
}, lastActionRefreshInterval);
5362

54-
let lastActionTime = Date.now();
5563
return uploadTravisJobInfo(database, prNumber)
5664
.then(() => {
5765
console.log(` Downloading screenshot golds from Firebase...`);

0 commit comments

Comments
 (0)