@@ -21,11 +21,17 @@ task('screenshots', () => {
2121 . then ( ( files : any [ ] ) => downloadAllGoldsAndCompare ( files , database , prNumber ) )
2222 . then ( ( results : boolean ) => updateResult ( database , prNumber , results ) )
2323 . then ( ( result : boolean ) => updateGithubStatus ( result , prNumber ) )
24- . then ( ( ) => uploadScreenshots ( prNumber , 'diff' ) )
25- . then ( ( ) => uploadScreenshots ( prNumber , 'test' ) )
24+ . then ( ( ) => uploadScreenshots ( 'diff' , prNumber ) )
25+ . then ( ( ) => uploadScreenshots ( 'test' , prNumber ) )
2626 . then ( ( ) => updateTravis ( database , prNumber ) )
2727 . then ( ( ) => setScreenFilenames ( database , prNumber ) )
2828 . then ( ( ) => database . goOffline ( ) , ( ) => database . goOffline ( ) ) ;
29+ } else if ( process . env [ 'TRAVIS' ] ) {
30+ // Only update golds and filenames for build
31+ let database = openFirebaseScreenshotsDatabase ( ) ;
32+ uploadScreenshots ( 'gold' )
33+ . then ( ( ) => setScreenFilenames ( database ) )
34+ . then ( ( ) => database . goOffline ( ) , ( ) => database . goOffline ( ) ) ;
2935 }
3036} ) ;
3137
@@ -70,19 +76,19 @@ function getLocalScreenshotFiles(dir: string): string[] {
7076 * Upload screenshots to google cloud storage.
7177 * @param prNumber - The key used in firebase. Here it is the PR number.
7278 * If there's no prNumber, we will upload images to 'golds/' folder
73- * @param mode - Can be 'test' or 'diff' or null .
79+ * @param mode - Can be 'test' or 'diff' or 'gold' .
7480 * If the images are the test results, mode should be 'test'.
7581 * If the images are the diff images generated, mode should be 'diff'.
76- * For golds mode should be null .
82+ * For golds mode should be 'gold' .
7783 */
78- function uploadScreenshots ( prNumber ?: string , mode ?: 'test' | 'diff' ) {
84+ function uploadScreenshots ( mode ?: 'test' | 'diff' | 'gold' , prNumber ?: string ) {
7985 let bucket = openScreenshotsBucket ( ) ;
8086
8187 let promises : any [ ] = [ ] ;
8288 let localDir = mode == 'diff' ? path . join ( SCREENSHOT_DIR , 'diff' ) : SCREENSHOT_DIR ;
8389 getLocalScreenshotFiles ( localDir ) . forEach ( ( file : string ) => {
8490 let fileName = path . join ( localDir , file ) ;
85- let destination = ( mode == null || ! prNumber ) ?
91+ let destination = ( mode == 'gold' || ! prNumber ) ?
8692 `golds/${ file } ` : `screenshots/${ prNumber } /${ mode } /${ file } ` ;
8793 promises . push ( bucket . upload ( fileName , { destination : destination } ) ) ;
8894 } ) ;
0 commit comments