@@ -21,11 +21,17 @@ task('screenshots', () => {
21
21
. then ( ( files : any [ ] ) => downloadAllGoldsAndCompare ( files , database , prNumber ) )
22
22
. then ( ( results : boolean ) => updateResult ( database , prNumber , results ) )
23
23
. 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 ) )
26
26
. then ( ( ) => updateTravis ( database , prNumber ) )
27
27
. then ( ( ) => setScreenFilenames ( database , prNumber ) )
28
28
. 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 ( ) ) ;
29
35
}
30
36
} ) ;
31
37
@@ -70,19 +76,19 @@ function getLocalScreenshotFiles(dir: string): string[] {
70
76
* Upload screenshots to google cloud storage.
71
77
* @param prNumber - The key used in firebase. Here it is the PR number.
72
78
* 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' .
74
80
* If the images are the test results, mode should be 'test'.
75
81
* 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' .
77
83
*/
78
- function uploadScreenshots ( prNumber ?: string , mode ?: 'test' | 'diff' ) {
84
+ function uploadScreenshots ( mode ?: 'test' | 'diff' | 'gold' , prNumber ?: string ) {
79
85
let bucket = openScreenshotsBucket ( ) ;
80
86
81
87
let promises : any [ ] = [ ] ;
82
88
let localDir = mode == 'diff' ? path . join ( SCREENSHOT_DIR , 'diff' ) : SCREENSHOT_DIR ;
83
89
getLocalScreenshotFiles ( localDir ) . forEach ( ( file : string ) => {
84
90
let fileName = path . join ( localDir , file ) ;
85
- let destination = ( mode == null || ! prNumber ) ?
91
+ let destination = ( mode == 'gold' || ! prNumber ) ?
86
92
`golds/${ file } ` : `screenshots/${ prNumber } /${ mode } /${ file } ` ;
87
93
promises . push ( bucket . upload ( fileName , { destination : destination } ) ) ;
88
94
} ) ;
0 commit comments