@@ -5,6 +5,7 @@ const S3 = require('aws-sdk/clients/s3');
5
5
const execa = require ( 'execa' ) ;
6
6
const stream = require ( 'stream' ) ;
7
7
8
+ const BUILD_URL = 'https://github.com/ionic-team/ionic/commit/' ;
8
9
const S3_BUCKET = 'screenshot.ionicframework.com' ;
9
10
const s3 = new S3 ( { apiVersion : '2006-03-01' } ) ;
10
11
@@ -18,6 +19,7 @@ class CIScreenshotConnector extends IonicConnector {
18
19
opts . buildId = sha1short ;
19
20
opts . buildMessage = msg ;
20
21
opts . buildAuthor = author ;
22
+ opts . buildUrl = BUILD_URL + sha1short ;
21
23
opts . buildTimestamp = ( timestamp * 1000 ) ;
22
24
23
25
await super . initBuild ( opts ) ;
@@ -48,25 +50,45 @@ class CIScreenshotConnector extends IonicConnector {
48
50
await super . pullIonicMasterBuild ( ) ;
49
51
}
50
52
51
- async publishBuild ( build ) {
53
+ async publishBuild ( results ) {
54
+ const currentBuild = results . currentBuild ;
55
+ const compare = results . compare ;
56
+
57
+ compare . url = `https://${ S3_BUCKET } /${ compare . a . id } /${ compare . b . id } ` ;
58
+
52
59
const timespan = this . logger . createTimeSpan ( `publishing build started` ) ;
53
- const images = build . screenshots . map ( screenshot => screenshot . image ) ;
54
- const buildBuffer = Buffer . from ( JSON . stringify ( build , undefined , 2 ) ) ;
60
+ const images = currentBuild . screenshots . map ( screenshot => screenshot . image ) ;
61
+
62
+ const buildBuffer = Buffer . from ( JSON . stringify ( currentBuild , undefined , 2 ) ) ;
55
63
const buildStream = new stream . PassThrough ( ) ;
56
64
buildStream . end ( buildBuffer ) ;
57
65
58
- await Promise . all ( images . map ( async image => this . uploadImage ( image ) ) ) ;
59
- await this . uploadStream ( buildStream , `data/builds/${ build . id } .json` , { ContentType : 'application/json' } ) ;
66
+ const compareBuffer = Buffer . from ( JSON . stringify ( compare , undefined , 2 ) ) ;
67
+ const compareStream = new stream . PassThrough ( ) ;
68
+ compareStream . end ( compareBuffer ) ;
69
+
70
+ const uploads = images . map ( async image => this . uploadImage ( image ) ) ;
71
+
72
+ uploads . push (
73
+ this . uploadStream ( buildStream , `data/builds/${ currentBuild . id } .json` , { ContentType : 'application/json' } ) ,
74
+ this . uploadStream ( compareBuffer , `data/compares/${ compare . id } .json` , { ContentType : 'application/json' } )
75
+ ) ;
60
76
61
77
if ( this . updateMaster ) {
62
78
const buildStream = new stream . PassThrough ( ) ;
63
79
buildStream . end ( buildBuffer ) ;
64
80
const key = `data/builds/master.json` ;
65
81
this . logger . debug ( `uploading: ${ key } ` ) ;
66
- await s3 . upload ( { Bucket : S3_BUCKET , Key : key , Body : buildStream , ContentType : 'application/json' } ) . promise ( ) ;
82
+ uploads . push (
83
+ s3 . upload ( { Bucket : S3_BUCKET , Key : key , Body : buildStream , ContentType : 'application/json' } ) . promise ( )
84
+ ) ;
67
85
}
68
86
87
+ await Promise . all ( uploads ) ;
88
+
69
89
timespan . finish ( `publishing build finished` ) ;
90
+
91
+ return results ;
70
92
}
71
93
72
94
}
0 commit comments