mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
feat(screenshot): Update screenshot golds for merged PR (#3365)
This commit is contained in:
@@ -21,11 +21,17 @@ 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('gold')
|
||||
.then(() => setScreenFilenames(database))
|
||||
.then(() => database.goOffline(), () => database.goOffline());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -70,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 }));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user