Skip to content

Commit 9361ced

Browse files
tinayuangaojelbourn
authored andcommitted
chore: fix screenshot results to be per-sha (#3887)
1 parent bc074a1 commit 9361ced

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

tools/gulp/tasks/screenshots.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
openFirebaseScreenshotsDatabase,
99
connectFirebaseScreenshots} from '../util/firebase';
1010
import {setGithubStatus} from '../util/github';
11+
import {isTravisPushBuild} from '../util/travis-ci';
1112

1213
const imageDiff = require('image-diff');
1314

@@ -23,7 +24,13 @@ const FIREBASE_FILELIST = 'screenshot/filenames';
2324
/** Task which upload screenshots generated from e2e test. */
2425
task('screenshots', () => {
2526
let prNumber = process.env['TRAVIS_PULL_REQUEST'];
26-
if (prNumber) {
27+
if (isTravisPushBuild()) {
28+
// Only update golds and filenames for build
29+
let database = openFirebaseScreenshotsDatabase();
30+
uploadScreenshots()
31+
.then(() => setScreenFilenames(database))
32+
.then(() => database.goOffline(), () => database.goOffline());
33+
} else if (prNumber) {
2734
let firebaseApp = connectFirebaseScreenshots();
2835
let database = firebaseApp.database();
2936

@@ -36,12 +43,6 @@ task('screenshots', () => {
3643
.then(() => updateTravis(database, prNumber))
3744
.then(() => setScreenFilenames(database, prNumber))
3845
.then(() => database.goOffline(), () => database.goOffline());
39-
} else if (process.env['TRAVIS']) {
40-
// Only update golds and filenames for build
41-
let database = openFirebaseScreenshotsDatabase();
42-
uploadScreenshots()
43-
.then(() => setScreenFilenames(database))
44-
.then(() => database.goOffline(), () => database.goOffline());
4546
}
4647
});
4748

@@ -51,7 +52,8 @@ function updateFileResult(database: firebase.database.Database, prNumber: string
5152
}
5253

5354
function updateResult(database: firebase.database.Database, prNumber: string, result: boolean) {
54-
return getPullRequestRef(database, prNumber).child('result').set(result).then(() => result);
55+
return getPullRequestRef(database, prNumber).child('result')
56+
.child(process.env['TRAVIS_PULL_REQUEST_SHA']).set(result).then(() => result);
5557
}
5658

5759
function getPullRequestRef(database: firebase.database.Database | admin.database.Database,

0 commit comments

Comments
 (0)