Skip to content
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

fix(screenshot): Fix screenshot test #3887

Merged
merged 1 commit into from
Apr 5, 2017
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
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