@testomatio/reporter 1.6.2 → 1.6.3-beta-artifacts-2

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 CHANGED
@@ -219,7 +219,28 @@ program
219
219
  await client.addTestRun(undefined, { rid, files });
220
220
  }
221
221
 
222
- console.log(APP_PREFIX, '🗄️', client.uploader.totalSuccessfulUploadsCount, 'artifacts 🟢uploaded');
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) {
@@ -74,7 +74,7 @@ program
74
74
  });
75
75
  }
76
76
 
77
- console.log(APP_PREFIX, client.uploader.totalSuccessfulUploadsCount, 'artifacts uploaded');
77
+ console.log(APP_PREFIX, client.uploader.successfulUploads.length, 'artifacts uploaded');
78
78
  if (client.uploader.failedUploads.length) {
79
79
  console.log(APP_PREFIX, client.uploader.failedUploads.length, 'artifacts failed to upload');
80
80
  }
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,10 +251,12 @@ 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.totalSuccessfulUploadsCount && this.uploader.isEnabled) {
254
+ if (!this.uploader.isEnabled) return;
255
+
256
+ if (this.uploader.successfulUploads.length) {
255
257
  console.log(
256
258
  APP_PREFIX,
257
- `🗄️ ${this.uploader.totalSuccessfulUploadsCount} artifacts ${
259
+ `🗄️ ${this.uploader.successfulUploads.length} artifacts ${
258
260
  process.env.TESTOMATIO_PRIVATE_ARTIFACTS ? 'privately' : chalk.bold('publicly')
259
261
  } 🟢 uploaded to S3 bucket`,
260
262
  );
@@ -262,6 +264,26 @@ class Client {
262
264
 
263
265
  const filesizeStrMaxLength = 7;
264
266
 
267
+ if (this.uploader.successfulUploads.length) {
268
+ debug('\n', APP_PREFIX, `🗄️ ${this.uploader.successfulUploads.length} artifacts uploaded to S3 bucket`);
269
+ const uploadedArtifacts = this.uploader.successfulUploads.map(file => ({
270
+ relativePath: file.path.replace(process.cwd(), ''),
271
+ link: file.link,
272
+ sizePretty: prettyBytes(file.size, { round: 0 }).toString(),
273
+ }));
274
+
275
+ uploadedArtifacts.forEach(upload => {
276
+ debug(
277
+ `🟢 Uploaded artifact`,
278
+ `${upload.relativePath},`,
279
+ 'size:',
280
+ `${upload.sizePretty},`,
281
+ 'link:',
282
+ `${upload.link}`,
283
+ );
284
+ });
285
+ }
286
+
265
287
  if (this.uploader.failedUploads.length) {
266
288
  console.log(
267
289
  '\n',
@@ -284,7 +306,7 @@ class Client {
284
306
  });
285
307
  }
286
308
 
287
- if (this.uploader.isEnabled && this.uploader.skippedUploads.length) {
309
+ if (this.uploader.skippedUploads.length) {
288
310
  console.log(
289
311
  '\n',
290
312
  APP_PREFIX,
package/lib/uploader.js CHANGED
@@ -21,9 +21,10 @@ class S3Uploader {
21
21
  */
22
22
  this.skippedUploads = [];
23
23
  this.failedUploads = [];
24
- this.totalSuccessfulUploadsCount = 0;
25
-
26
- this.succesfulUploads = {};
24
+ /**
25
+ * @type {{path: string, size: number, link: string}[]}
26
+ */
27
+ this.successfulUploads = [];
27
28
 
28
29
  this.configKeys = [
29
30
  'S3_ENDPOINT',
@@ -66,7 +67,7 @@ class S3Uploader {
66
67
  if (this.isEnabled !== undefined) return this.isEnabled;
67
68
 
68
69
  const { S3_BUCKET, TESTOMATIO_DISABLE_ARTIFACTS } = this.getConfig();
69
- if (!S3_BUCKET) debug(`Upload is disabled because S3_BUCKET is not set`);
70
+ if (!S3_BUCKET) debug(`Artifacts uploading is disabled because S3_BUCKET is not set`);
70
71
  this.isEnabled = !!(S3_BUCKET && !TESTOMATIO_DISABLE_ARTIFACTS);
71
72
 
72
73
  if (this.isEnabled) debug('S3 uploader is enabled');
@@ -119,8 +120,8 @@ class S3Uploader {
119
120
  });
120
121
 
121
122
  const link = await this.getS3LocationLink(upload);
122
- this.totalSuccessfulUploadsCount++;
123
- this.succesfulUploads[Key] = link;
123
+ this.successfulUploads.push({ path: file.path, size: file.size, link });
124
+ debug(`📤 Uploaded artifact. File: ${file.path}, size: ${prettyBytes(file.size)}, link: ${link}`);
124
125
  return link;
125
126
  } catch (e) {
126
127
  this.failedUploads.push({ path: file.path, size: file.size });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testomatio/reporter",
3
- "version": "1.6.2",
3
+ "version": "1.6.3-beta-artifacts-2",
4
4
  "description": "Testomatio Reporter Client",
5
5
  "main": "./lib/reporter.js",
6
6
  "typings": "typings/index.d.ts",