@testomatio/reporter 1.6.3-beta-artlog → 1.6.3-beta-artifacts-3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bin/cli.js +21 -0
- package/lib/client.js +6 -4
- package/lib/uploader.js +15 -8
- package/package.json +1 -1
package/lib/bin/cli.js
CHANGED
|
@@ -220,6 +220,27 @@ program
|
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
console.log(APP_PREFIX, '🗄️', client.uploader.successfulUploads.length, 'artifacts 🟢uploaded');
|
|
223
|
+
|
|
224
|
+
if (client.uploader.successfulUploads.length) {
|
|
225
|
+
debug('\n', APP_PREFIX, `🗄️ ${client.uploader.successfulUploads.length} artifacts uploaded to S3 bucket`);
|
|
226
|
+
const uploadedArtifacts = client.uploader.successfulUploads.map(file => ({
|
|
227
|
+
relativePath: file.path.replace(process.cwd(), ''),
|
|
228
|
+
link: file.link,
|
|
229
|
+
sizePretty: prettyBytes(file.size, { round: 0 }).toString(),
|
|
230
|
+
}));
|
|
231
|
+
|
|
232
|
+
uploadedArtifacts.forEach(upload => {
|
|
233
|
+
debug(
|
|
234
|
+
`🟢 Uploaded artifact`,
|
|
235
|
+
`${upload.relativePath},`,
|
|
236
|
+
'size:',
|
|
237
|
+
`${upload.sizePretty},`,
|
|
238
|
+
'link:',
|
|
239
|
+
`${upload.link}`,
|
|
240
|
+
);
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
|
|
223
244
|
const filesizeStrMaxLength = 7;
|
|
224
245
|
|
|
225
246
|
if (client.uploader.failedUploads.length) {
|
package/lib/client.js
CHANGED
|
@@ -35,7 +35,6 @@ class Client {
|
|
|
35
35
|
this.version = JSON.parse(fs.readFileSync(join(__dirname, '..', 'package.json')).toString()).version;
|
|
36
36
|
this.executionList = Promise.resolve();
|
|
37
37
|
this.uploader = new S3Uploader();
|
|
38
|
-
this.uploader.checkEnabled();
|
|
39
38
|
|
|
40
39
|
console.log(APP_PREFIX, `Testomatio Reporter v${this.version}`);
|
|
41
40
|
}
|
|
@@ -110,7 +109,8 @@ class Client {
|
|
|
110
109
|
const runId = this.pipeStore?.runId;
|
|
111
110
|
if (runId) this.runId = runId;
|
|
112
111
|
storeRunId(this.runId);
|
|
113
|
-
|
|
112
|
+
})
|
|
113
|
+
.then(() => {
|
|
114
114
|
this.uploader.checkEnabled();
|
|
115
115
|
})
|
|
116
116
|
.then(() => undefined); // fixes return type
|
|
@@ -251,7 +251,9 @@ class Client {
|
|
|
251
251
|
this.queue = this.queue
|
|
252
252
|
.then(() => Promise.all(this.pipes.map(p => p.finishRun(runParams))))
|
|
253
253
|
.then(() => {
|
|
254
|
-
if (this.uploader.
|
|
254
|
+
if (!this.uploader.isEnabled) return;
|
|
255
|
+
|
|
256
|
+
if (this.uploader.successfulUploads.length) {
|
|
255
257
|
console.log(
|
|
256
258
|
APP_PREFIX,
|
|
257
259
|
`🗄️ ${this.uploader.successfulUploads.length} artifacts ${
|
|
@@ -304,7 +306,7 @@ class Client {
|
|
|
304
306
|
});
|
|
305
307
|
}
|
|
306
308
|
|
|
307
|
-
if (this.uploader.
|
|
309
|
+
if (this.uploader.skippedUploads.length) {
|
|
308
310
|
console.log(
|
|
309
311
|
'\n',
|
|
310
312
|
APP_PREFIX,
|
package/lib/uploader.js
CHANGED
|
@@ -67,7 +67,7 @@ class S3Uploader {
|
|
|
67
67
|
if (this.isEnabled !== undefined) return this.isEnabled;
|
|
68
68
|
|
|
69
69
|
const { S3_BUCKET, TESTOMATIO_DISABLE_ARTIFACTS } = this.getConfig();
|
|
70
|
-
if (!S3_BUCKET) debug(`
|
|
70
|
+
if (!S3_BUCKET) debug(`Artifacts uploading is disabled because S3_BUCKET is not set`);
|
|
71
71
|
this.isEnabled = !!(S3_BUCKET && !TESTOMATIO_DISABLE_ARTIFACTS);
|
|
72
72
|
|
|
73
73
|
if (this.isEnabled) debug('S3 uploader is enabled');
|
|
@@ -106,17 +106,24 @@ class S3Uploader {
|
|
|
106
106
|
|
|
107
107
|
debug('Uploading to S3:', Key);
|
|
108
108
|
|
|
109
|
-
const
|
|
109
|
+
const s3Config = this.#getS3Config()
|
|
110
|
+
const s3 = new S3(s3Config);
|
|
111
|
+
|
|
112
|
+
const params = {
|
|
113
|
+
Bucket: S3_BUCKET,
|
|
114
|
+
Key,
|
|
115
|
+
Body,
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// disable ACL for I AM roles
|
|
119
|
+
if (!s3Config.credentials.sessionToken) {
|
|
120
|
+
params.ACL = ACL;
|
|
121
|
+
}
|
|
110
122
|
|
|
111
123
|
try {
|
|
112
124
|
const upload = new Upload({
|
|
113
125
|
client: s3,
|
|
114
|
-
params
|
|
115
|
-
Bucket: S3_BUCKET,
|
|
116
|
-
Key,
|
|
117
|
-
Body,
|
|
118
|
-
ACL,
|
|
119
|
-
},
|
|
126
|
+
params,
|
|
120
127
|
});
|
|
121
128
|
|
|
122
129
|
const link = await this.getS3LocationLink(upload);
|