From 398d5e7587a0dfd38eb5112cade1acc0d71c5f82 Mon Sep 17 00:00:00 2001 From: Yuan Gao Date: Mon, 27 Feb 2017 12:42:33 -0800 Subject: [PATCH 1/2] Upload golds and filenames --- tools/gulp/tasks/screenshots.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/gulp/tasks/screenshots.ts b/tools/gulp/tasks/screenshots.ts index 05143c823d8e..0ccf2d8c23e4 100644 --- a/tools/gulp/tasks/screenshots.ts +++ b/tools/gulp/tasks/screenshots.ts @@ -26,6 +26,12 @@ task('screenshots', () => { .then(() => updateTravis(database, prNumber)) .then(() => setScreenFilenames(database, prNumber)) .then(() => database.goOffline(), () => database.goOffline()); + } else if (process.env['TRAVIS']) { + // Only update golds and filenames for build + let database = openFirebaseScreenshotsDatabase(); + uploadScreenshots(null, null) + .then(() => setScreenFilenames(database, null)) + .then(() => database.goOffline(), () => database.goOffline()); } }); From 28a237bd9d644d606600f758480bcc0ad0272ae1 Mon Sep 17 00:00:00 2001 From: Yuan Gao Date: Wed, 1 Mar 2017 14:01:55 -0800 Subject: [PATCH 2/2] Add mode gold --- tools/gulp/tasks/screenshots.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/gulp/tasks/screenshots.ts b/tools/gulp/tasks/screenshots.ts index 0ccf2d8c23e4..699a77b14fde 100644 --- a/tools/gulp/tasks/screenshots.ts +++ b/tools/gulp/tasks/screenshots.ts @@ -21,16 +21,16 @@ task('screenshots', () => { .then((files: any[]) => downloadAllGoldsAndCompare(files, database, prNumber)) .then((results: boolean) => updateResult(database, prNumber, results)) .then((result: boolean) => updateGithubStatus(result, prNumber)) - .then(() => uploadScreenshots(prNumber, 'diff')) - .then(() => uploadScreenshots(prNumber, 'test')) + .then(() => uploadScreenshots('diff', prNumber)) + .then(() => uploadScreenshots('test', prNumber)) .then(() => updateTravis(database, prNumber)) .then(() => setScreenFilenames(database, prNumber)) .then(() => database.goOffline(), () => database.goOffline()); } else if (process.env['TRAVIS']) { // Only update golds and filenames for build let database = openFirebaseScreenshotsDatabase(); - uploadScreenshots(null, null) - .then(() => setScreenFilenames(database, null)) + uploadScreenshots('gold') + .then(() => setScreenFilenames(database)) .then(() => database.goOffline(), () => database.goOffline()); } }); @@ -76,19 +76,19 @@ function getLocalScreenshotFiles(dir: string): string[] { * Upload screenshots to google cloud storage. * @param prNumber - The key used in firebase. Here it is the PR number. * If there's no prNumber, we will upload images to 'golds/' folder - * @param mode - Can be 'test' or 'diff' or null. + * @param mode - Can be 'test' or 'diff' or 'gold'. * If the images are the test results, mode should be 'test'. * If the images are the diff images generated, mode should be 'diff'. - * For golds mode should be null. + * For golds mode should be 'gold'. */ -function uploadScreenshots(prNumber?: string, mode?: 'test' | 'diff') { +function uploadScreenshots(mode?: 'test' | 'diff' | 'gold', prNumber?: string) { let bucket = openScreenshotsBucket(); let promises: any[] = []; let localDir = mode == 'diff' ? path.join(SCREENSHOT_DIR, 'diff') : SCREENSHOT_DIR; getLocalScreenshotFiles(localDir).forEach((file: string) => { let fileName = path.join(localDir, file); - let destination = (mode == null || !prNumber) ? + let destination = (mode == 'gold' || !prNumber) ? `golds/${file}` : `screenshots/${prNumber}/${mode}/${file}`; promises.push(bucket.upload(fileName, { destination: destination })); });