Skip to content

build: cancel screenshot diff if there is no activity #6957

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions tools/gulp/tasks/screenshots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,20 @@ const LOCAL_GOLDENS = path.join(SCREENSHOT_DIR, `golds`);
const LOCAL_DIFFS = path.join(SCREENSHOT_DIR, `diff`);

// Directory to which untrusted screenshot results are temporarily written
// (without authentication required) before they are verified and copied to
// the final storage location.
// (without authentication required) before they are verified and copied to
// the final storage location.
const TEMP_FOLDER = 'untrustedInbox';
const FIREBASE_REPORT = `${TEMP_FOLDER}/screenshot/reports`;
const FIREBASE_IMAGE = `${TEMP_FOLDER}/screenshot/images`;
const FIREBASE_DATA_GOLDENS = `screenshot/goldens`;
const FIREBASE_STORAGE_GOLDENS = 'goldens';

/** Time in ms until the process will be exited if the last action took too long (6 minutes). */
const lastActionTimeout = 1000 * 60 * 6;

/** Time in ms that specifies how often the last action should be checked (45 seconds). */
const lastActionRefreshInterval = 1000 * 45;

/** Task which upload screenshots generated from e2e test. */
task('screenshots', () => {
const prNumber = process.env['TRAVIS_PULL_REQUEST'];
Expand All @@ -44,14 +50,20 @@ task('screenshots', () => {
} else if (prNumber) {
const firebaseApp = connectFirebaseScreenshots();
const database = firebaseApp.database();
let lastActionTime = Date.now();

// If this task hasn't completed in 8 minutes, close the firebase connection.
const timeoutId = setTimeout(() => {
console.error('Screenshot tests did not finish in 8 minutes, closing Firebase connection.');
return firebaseApp.delete();
}, 60 * 1000 * 8);
// If the last action of the task takes longer than 6 minutes, close the firebase connection.
const timeoutId = setInterval(() => {
if (lastActionTime + lastActionTimeout <= Date.now()) {
clearTimeout(timeoutId);
console.error('Last action for screenshot tests did not finish in ' +
(lastActionTimeout / 1000 / 60) + ' minutes. Closing Firebase connection...');
return firebaseApp.delete().then(() => process.exit(1));
}
}, lastActionRefreshInterval);

console.log(` Starting screenshots task with results from e2e task...`);

let lastActionTime = Date.now();
return uploadTravisJobInfo(database, prNumber)
.then(() => {
console.log(` Downloading screenshot golds from Firebase...`);
Expand Down