Skip to content

Commit b9c03e3

Browse files
committed
chore(screenshot): update screenshot ci
1 parent 3a4b214 commit b9c03e3

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"ionicons": "4.4.4"
3131
},
3232
"devDependencies": {
33-
"@stencil/core": "0.14.0-3",
33+
"@stencil/core": "0.14.0-4",
3434
"@stencil/dev-server": "latest",
3535
"@stencil/sass": "0.1.1",
3636
"@stencil/utils": "latest",

core/scripts/screenshot/ci.js

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const S3 = require('aws-sdk/clients/s3');
55
const execa = require('execa');
66
const stream = require('stream');
77

8+
const BUILD_URL = 'https://github.com/ionic-team/ionic/commit/';
89
const S3_BUCKET = 'screenshot.ionicframework.com';
910
const s3 = new S3({ apiVersion: '2006-03-01' });
1011

@@ -18,6 +19,7 @@ class CIScreenshotConnector extends IonicConnector {
1819
opts.buildId = sha1short;
1920
opts.buildMessage = msg;
2021
opts.buildAuthor = author;
22+
opts.buildUrl = BUILD_URL + sha1short;
2123
opts.buildTimestamp = (timestamp * 1000);
2224

2325
await super.initBuild(opts);
@@ -48,25 +50,45 @@ class CIScreenshotConnector extends IonicConnector {
4850
await super.pullIonicMasterBuild();
4951
}
5052

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+
5259
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));
5563
const buildStream = new stream.PassThrough();
5664
buildStream.end(buildBuffer);
5765

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+
);
6076

6177
if (this.updateMaster) {
6278
const buildStream = new stream.PassThrough();
6379
buildStream.end(buildBuffer);
6480
const key = `data/builds/master.json`;
6581
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+
);
6785
}
6886

87+
await Promise.all(uploads);
88+
6989
timespan.finish(`publishing build finished`);
90+
91+
return results;
7092
}
7193

7294
}

0 commit comments

Comments
 (0)