forked from BitGo/BitGoJS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload-test-reports.js
More file actions
executable file
·50 lines (43 loc) · 1.28 KB
/
Copy pathupload-test-reports.js
File metadata and controls
executable file
·50 lines (43 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const path = require('path');
const fs = require('fs');
const S3 = require('aws-sdk/clients/s3');
const {
reports_s3_akid,
reports_s3_sak,
DRONE,
DRONE_BUILD_NUMBER,
DRONE_STAGE_NAME,
} = process.env;
if (!DRONE) {
console.log('Not running in drone, exiting...');
process.exit(0);
}
const s3 = new S3({
accessKeyId: reports_s3_akid,
secretAccessKey: reports_s3_sak,
signatureVersion: 'v4',
});
const ROOTDIR = path.dirname(path.dirname(require.main.filename));
const MODULE = path.basename(ROOTDIR);
const OBJECT_NAME = `${DRONE_BUILD_NUMBER}/${MODULE}/${DRONE_STAGE_NAME}.html`;
const REPORT_FILE = `${ROOTDIR}/mochawesome-report/mochawesome.html`;
if (!fs.existsSync(REPORT_FILE)) {
console.warn(`Report file '${REPORT_FILE}' not found. Skipping test report upload...`);
} else {
const uploadParams = {
Body: fs.readFileSync(REPORT_FILE),
Bucket: 'bitgo-sdk-test-reports',
Key: OBJECT_NAME,
ACL: 'public-read',
ContentType: 'text/html',
};
s3.putObject(uploadParams, (err, data) => {
if (err) {
console.error(`S3 error: ${err}\n${err.stack}`);
} else {
console.log(`=== TEST REPORT UPLOADED SUCCESSFULLY ===`);
console.log(`https://bitgo-sdk-test-reports.s3.amazonaws.com/${OBJECT_NAME}`);
console.log();
}
});
}