playwright-slack-report-burak 3.0.33 → 3.0.35
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/dist/src/ResultsParser.js +138 -21
- package/package.json +1 -1
|
@@ -18,6 +18,11 @@ try {
|
|
|
18
18
|
AdmZip = null;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
const SUMMARIES_DIR = path.join('./', 'playwright-report');
|
|
22
|
+
const NODE_ARTIFACTS_DIR = path.join(SUMMARIES_DIR, 'nodeArtifacts');
|
|
23
|
+
const FINAL_OUTPUT_DIR = path.join(SUMMARIES_DIR, 'finalOutput');
|
|
24
|
+
const TEMP_MERGE_DIR = path.join(NODE_ARTIFACTS_DIR, 'temp-merge');
|
|
25
|
+
|
|
21
26
|
class ResultsParser {
|
|
22
27
|
result;
|
|
23
28
|
separateFlakyTests;
|
|
@@ -50,17 +55,15 @@ class ResultsParser {
|
|
|
50
55
|
}*/
|
|
51
56
|
|
|
52
57
|
// Define the directory to store node summaries
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (!fs.existsSync(summariesDir)) {
|
|
56
|
-
fs.mkdirSync(summariesDir, { recursive: true });
|
|
58
|
+
if (!fs.existsSync(SUMMARIES_DIR)) {
|
|
59
|
+
fs.mkdirSync(SUMMARIES_DIR, { recursive: true });
|
|
57
60
|
}
|
|
58
61
|
|
|
59
62
|
// Determine the current node index
|
|
60
63
|
const currentNodeIndex = this.shardIndex;
|
|
61
64
|
|
|
62
65
|
// Define the file for the current node's summary
|
|
63
|
-
const nodeSummaryFile = path.join(
|
|
66
|
+
const nodeSummaryFile = path.join(SUMMARIES_DIR, `node_summary_${currentNodeIndex}.json`);
|
|
64
67
|
|
|
65
68
|
const totalTestCasesForNode = this.result.reduce((acc, suite) => acc + suite.testSuite.tests.length, 0);
|
|
66
69
|
|
|
@@ -102,7 +105,7 @@ class ResultsParser {
|
|
|
102
105
|
if (this.shardIndex === 1 && this.allNodeSummaryFilesExist() && this.allBlobZipsExist()) {
|
|
103
106
|
// Merge all node summaries into the final summary
|
|
104
107
|
for (let i = 1; i <= this.totalShardCount; i++) {
|
|
105
|
-
const nodeSummaryFile = path.join(
|
|
108
|
+
const nodeSummaryFile = path.join(SUMMARIES_DIR, `node_summary_${i}.json`);
|
|
106
109
|
const fileToRead = nodeSummaryFile;
|
|
107
110
|
|
|
108
111
|
if (fs.existsSync(fileToRead)) {
|
|
@@ -314,10 +317,9 @@ class ResultsParser {
|
|
|
314
317
|
}*/
|
|
315
318
|
allNodeSummaryFilesExist() {
|
|
316
319
|
console.log('Checking if all node summary files exist...');
|
|
317
|
-
const summariesDir = path.join('./', 'playwright-report');
|
|
318
320
|
|
|
319
321
|
for (let i = 1; i <= this.totalShardCount; i++) {
|
|
320
|
-
const nodeSummaryFile = path.join(
|
|
322
|
+
const nodeSummaryFile = path.join(SUMMARIES_DIR, `node_summary_${i}.json`);
|
|
321
323
|
if (!fs.existsSync(nodeSummaryFile)) {
|
|
322
324
|
return false;
|
|
323
325
|
}
|
|
@@ -327,10 +329,9 @@ class ResultsParser {
|
|
|
327
329
|
|
|
328
330
|
allBlobZipsExist() {
|
|
329
331
|
console.log('Checking if all blob zips exist...');
|
|
330
|
-
const summariesDir = path.join('./', 'playwright-report');
|
|
331
332
|
|
|
332
333
|
for (let i = 1; i <= this.totalShardCount; i++) {
|
|
333
|
-
const blobZipFile = path.join(
|
|
334
|
+
const blobZipFile = path.join(NODE_ARTIFACTS_DIR, `blob-report-node-${i}.zip`);
|
|
334
335
|
if (!fs.existsSync(blobZipFile)) {
|
|
335
336
|
return false;
|
|
336
337
|
}
|
|
@@ -339,21 +340,54 @@ class ResultsParser {
|
|
|
339
340
|
}
|
|
340
341
|
|
|
341
342
|
async fetchAllArtifacts() {
|
|
342
|
-
|
|
343
|
+
// Ensure playwright-report directory exists
|
|
344
|
+
if (!fs.existsSync(SUMMARIES_DIR)) {
|
|
345
|
+
fs.mkdirSync(SUMMARIES_DIR, { recursive: true });
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// Create nodeArtifacts directory under playwright-report
|
|
349
|
+
if (!fs.existsSync(NODE_ARTIFACTS_DIR)) {
|
|
350
|
+
fs.mkdirSync(NODE_ARTIFACTS_DIR, { recursive: true });
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// Copy artifacts from node 1 to nodeArtifacts
|
|
354
|
+
// Check multiple potential locations for node 1's blob file
|
|
355
|
+
const possibleNode1BlobSources = [
|
|
356
|
+
path.join(SUMMARIES_DIR, 'blob-report-node-1.zip'),
|
|
357
|
+
path.join('./', 'blob-report-node-1.zip'),
|
|
358
|
+
path.join(SUMMARIES_DIR, 'blob-report-1.zip'),
|
|
359
|
+
];
|
|
360
|
+
|
|
361
|
+
const node1BlobDest = path.join(NODE_ARTIFACTS_DIR, 'blob-report-node-1.zip');
|
|
362
|
+
let node1BlobCopied = false;
|
|
363
|
+
|
|
364
|
+
for (const source of possibleNode1BlobSources) {
|
|
365
|
+
if (fs.existsSync(source)) {
|
|
366
|
+
fs.copyFileSync(source, node1BlobDest);
|
|
367
|
+
console.log(`Copied ${source} to nodeArtifacts`);
|
|
368
|
+
node1BlobCopied = true;
|
|
369
|
+
break;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
if (!node1BlobCopied) {
|
|
374
|
+
console.warn('Warning: blob-report-node-1.zip not found in expected locations');
|
|
375
|
+
}
|
|
376
|
+
|
|
343
377
|
while (!this.allNodeSummaryFilesExist() || !this.allBlobZipsExist()) {
|
|
344
378
|
console.log('Waiting for all blob zips to exist...');
|
|
345
|
-
if (!fs.existsSync(
|
|
346
|
-
fs.mkdirSync(
|
|
379
|
+
if (!fs.existsSync(SUMMARIES_DIR)) {
|
|
380
|
+
fs.mkdirSync(SUMMARIES_DIR, { recursive: true });
|
|
347
381
|
}
|
|
348
382
|
for (let i = 2; i <= this.totalShardCount; i++) {
|
|
349
|
-
await this.fetchArtifact(i, `node_summary_${i}.json`,
|
|
350
|
-
await this.fetchArtifact(i, `blob-report-node-${i}.zip`,
|
|
383
|
+
await this.fetchArtifact(i, `node_summary_${i}.json`, SUMMARIES_DIR);
|
|
384
|
+
await this.fetchArtifact(i, `blob-report-node-${i}.zip`, NODE_ARTIFACTS_DIR);
|
|
351
385
|
}
|
|
352
386
|
}
|
|
353
387
|
}
|
|
354
388
|
|
|
355
|
-
async fetchArtifact(i, file,
|
|
356
|
-
const filePath = path.join(
|
|
389
|
+
async fetchArtifact(i, file, targetDir) {
|
|
390
|
+
const filePath = path.join(targetDir, file);
|
|
357
391
|
await this.fetchArtifactFromGitHubActions(i, file, filePath);
|
|
358
392
|
}
|
|
359
393
|
|
|
@@ -438,10 +472,41 @@ class ResultsParser {
|
|
|
438
472
|
mergeReports() {
|
|
439
473
|
let breakMergeWaiter = false;
|
|
440
474
|
try {
|
|
441
|
-
//
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
475
|
+
// Ensure playwright-report directory exists
|
|
476
|
+
if (!fs.existsSync(SUMMARIES_DIR)) {
|
|
477
|
+
fs.mkdirSync(SUMMARIES_DIR, { recursive: true });
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
// Create finalOutput directory under playwright-report
|
|
481
|
+
if (!fs.existsSync(FINAL_OUTPUT_DIR)) {
|
|
482
|
+
fs.mkdirSync(FINAL_OUTPUT_DIR, { recursive: true });
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
// Copy blob files before merging (Playwright merge-reports expects blob files)
|
|
486
|
+
// We'll copy them temporarily for merging, then extract later for resource copying
|
|
487
|
+
if (!fs.existsSync(TEMP_MERGE_DIR)) {
|
|
488
|
+
fs.mkdirSync(TEMP_MERGE_DIR, { recursive: true });
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
// Copy all blob zip files to temp directory for merging
|
|
492
|
+
for (let i = 1; i <= this.totalShardCount; i++) {
|
|
493
|
+
const blobZipFile = path.join(NODE_ARTIFACTS_DIR, `blob-report-node-${i}.zip`);
|
|
494
|
+
if (fs.existsSync(blobZipFile)) {
|
|
495
|
+
try {
|
|
496
|
+
const destFile = path.join(TEMP_MERGE_DIR, `blob-report-node-${i}.zip`);
|
|
497
|
+
fs.copyFileSync(blobZipFile, destFile);
|
|
498
|
+
console.log(`Copied blob-report-node-${i}.zip for merging`);
|
|
499
|
+
} catch (error) {
|
|
500
|
+
console.warn(`Failed to copy blob-report-node-${i}.zip for merging:`, error.message);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
// Execute the command to merge reports FROM TEMP_MERGE_DIR INTO finalOutput
|
|
506
|
+
exec(`npx playwright merge-reports --reporter html ${TEMP_MERGE_DIR} ${FINAL_OUTPUT_DIR}`);
|
|
507
|
+
|
|
508
|
+
// Wait until index.html exists in finalOutput
|
|
509
|
+
while (!fs.existsSync(path.join(FINAL_OUTPUT_DIR, 'index.html'))) {
|
|
445
510
|
console.log('Waiting 2 seconds for merged html report to be generated...');
|
|
446
511
|
const currentTime = new Date().getTime();
|
|
447
512
|
breakMergeWaiter = false;
|
|
@@ -452,10 +517,62 @@ class ResultsParser {
|
|
|
452
517
|
}
|
|
453
518
|
}
|
|
454
519
|
console.log('Reports merged successfully.');
|
|
520
|
+
|
|
521
|
+
// Once merge is complete, unzip all blobs in nodeArtifacts into separate folders
|
|
522
|
+
this.unzipBlobsAndCopyResources(NODE_ARTIFACTS_DIR, FINAL_OUTPUT_DIR);
|
|
455
523
|
} catch (error) {
|
|
456
524
|
// Log a warning instead of throwing an error
|
|
457
525
|
console.warn('Warning: Failed to merge reports. This may not affect the overall process.', error.message);
|
|
458
526
|
}
|
|
459
527
|
}
|
|
528
|
+
|
|
529
|
+
unzipBlobsAndCopyResources(nodeArtifactsDir, finalOutputDir) {
|
|
530
|
+
if (!AdmZip) {
|
|
531
|
+
console.error('adm-zip is required for blob extraction. Please install it: npm install adm-zip');
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
// Unzip all blob files in nodeArtifacts into separate folders
|
|
536
|
+
for (let i = 1; i <= this.totalShardCount; i++) {
|
|
537
|
+
const blobZipFile = path.join(nodeArtifactsDir, `blob-report-node-${i}.zip`);
|
|
538
|
+
if (fs.existsSync(blobZipFile)) {
|
|
539
|
+
const extractDir = path.join(nodeArtifactsDir, `node-${i}`);
|
|
540
|
+
if (!fs.existsSync(extractDir)) {
|
|
541
|
+
fs.mkdirSync(extractDir, { recursive: true });
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
try {
|
|
545
|
+
const zip = new AdmZip(blobZipFile);
|
|
546
|
+
zip.extractAllTo(extractDir, true);
|
|
547
|
+
console.log(`Extracted blob-report-node-${i}.zip to ${extractDir}`);
|
|
548
|
+
|
|
549
|
+
// Check if this folder contains a "resources" folder with zip files
|
|
550
|
+
const resourcesDir = path.join(extractDir, 'resources');
|
|
551
|
+
if (fs.existsSync(resourcesDir) && fs.statSync(resourcesDir).isDirectory()) {
|
|
552
|
+
const files = fs.readdirSync(resourcesDir);
|
|
553
|
+
const zipFiles = files.filter(file => file.endsWith('.zip'));
|
|
554
|
+
|
|
555
|
+
if (zipFiles.length > 0) {
|
|
556
|
+
// Copy the resources folder to finalOutput
|
|
557
|
+
const finalResourcesDir = path.join(finalOutputDir, 'resources');
|
|
558
|
+
if (!fs.existsSync(finalResourcesDir)) {
|
|
559
|
+
fs.mkdirSync(finalResourcesDir, { recursive: true });
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
// Copy each zip file to finalOutput/resources
|
|
563
|
+
for (const zipFile of zipFiles) {
|
|
564
|
+
const sourceFile = path.join(resourcesDir, zipFile);
|
|
565
|
+
const destFile = path.join(finalResourcesDir, zipFile);
|
|
566
|
+
fs.copyFileSync(sourceFile, destFile);
|
|
567
|
+
console.log(`Copied ${zipFile} to finalOutput/resources`);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
} catch (error) {
|
|
572
|
+
console.warn(`Failed to extract or process blob-report-node-${i}.zip:`, error.message);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
}
|
|
460
577
|
}
|
|
461
578
|
exports.default = ResultsParser;
|
package/package.json
CHANGED