From 2ae4d71bb8d06cc8831126fb2449d708ff26b2a2 Mon Sep 17 00:00:00 2001 From: Yuan Gao Date: Mon, 3 Apr 2017 13:01:00 -0700 Subject: [PATCH] Fix current screenshots --- tools/gulp/tasks/screenshots.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tools/gulp/tasks/screenshots.ts b/tools/gulp/tasks/screenshots.ts index 7859929ddf7e..4d9615231424 100644 --- a/tools/gulp/tasks/screenshots.ts +++ b/tools/gulp/tasks/screenshots.ts @@ -8,6 +8,7 @@ import { openFirebaseScreenshotsDatabase, connectFirebaseScreenshots} from '../util/firebase'; import {setGithubStatus} from '../util/github'; +import {isTravisPushBuild} from '../util/travis-ci'; const imageDiff = require('image-diff'); @@ -23,7 +24,13 @@ const FIREBASE_FILELIST = 'screenshot/filenames'; /** Task which upload screenshots generated from e2e test. */ task('screenshots', () => { let prNumber = process.env['TRAVIS_PULL_REQUEST']; - if (prNumber) { + if (isTravisPushBuild()) { + // Only update golds and filenames for build + let database = openFirebaseScreenshotsDatabase(); + uploadScreenshots() + .then(() => setScreenFilenames(database)) + .then(() => database.goOffline(), () => database.goOffline()); + } else if (prNumber) { let firebaseApp = connectFirebaseScreenshots(); let database = firebaseApp.database(); @@ -36,12 +43,6 @@ 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() - .then(() => setScreenFilenames(database)) - .then(() => database.goOffline(), () => database.goOffline()); } }); @@ -51,7 +52,8 @@ function updateFileResult(database: firebase.database.Database, prNumber: string } function updateResult(database: firebase.database.Database, prNumber: string, result: boolean) { - return getPullRequestRef(database, prNumber).child('result').set(result).then(() => result); + return getPullRequestRef(database, prNumber).child('result') + .child(process.env['TRAVIS_PULL_REQUEST_SHA']).set(result).then(() => result); } function getPullRequestRef(database: firebase.database.Database | admin.database.Database,