Skip to content

Commit

Permalink
chore: fix screenshot results to be per-sha (#3887)
Browse files Browse the repository at this point in the history
  • Loading branch information
tinayuangao authored and jelbourn committed Apr 5, 2017
1 parent bc074a1 commit 9361ced
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions tools/gulp/tasks/screenshots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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();

Expand All @@ -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());
}
});

Expand All @@ -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,
Expand Down

0 comments on commit 9361ced

Please sign in to comment.