playwright-slack-report-burak 3.5.3 → 3.5.5

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.
@@ -9,14 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  const fs = require('fs');
10
10
  const os = require('os');
11
11
  const path = require('path');
12
- const { exec, execFileSync } = require('child_process');
13
- let AdmZip;
14
- try {
15
- AdmZip = require('adm-zip');
16
- } catch (e) {
17
- // adm-zip is required for unzipping Playwright blob reports during merge
18
- AdmZip = null;
19
- }
12
+ const { execSync, execFileSync } = require('child_process');
20
13
 
21
14
  // ============================================================================
22
15
  // CONSTANTS
@@ -458,41 +451,17 @@ class ResultsParser {
458
451
  }
459
452
  }
460
453
  async mergeReports() {
461
- let breakMergeWaiter = false;
462
454
  try {
463
-
464
- // Copy all blob files to playwright-report before merging
465
- for (let i = 1; i <= this.totalShardCount; i++) {
466
- const blobZipFile = path.join(SUMMARIES_DIR, `blob-report-node-${i}.zip`);
467
- if (fs.existsSync(blobZipFile)) {
468
- try {
469
- const destFile = path.join(PLAYWRIGHT_REPORT_DIR, `blob-report-node-${i}.zip`);
470
- fs.copyFileSync(blobZipFile, destFile);
471
- } catch (error) {
472
- console.warn(`Failed to copy blob-report-node-${i}.zip for merging:`, error.message);
473
- }
474
- }
475
- }
476
-
477
- // Execute the command to merge reports FROM playwright-report
478
- // Playwright will output to playwright-report directory
479
- exec(`npx playwright merge-reports --reporter html ${PLAYWRIGHT_REPORT_DIR}`);
480
-
481
- // Wait until index.html exists in playwright-report
482
- while (!fs.existsSync(path.join(PLAYWRIGHT_REPORT_DIR, 'index.html'))) {
483
- console.log('Waiting 2 seconds for merged html report to be generated...');
484
- const currentTime = new Date().getTime();
485
- breakMergeWaiter = false;
486
- while (!breakMergeWaiter) {
487
- if(new Date().getTime() - currentTime > 2000) {
488
- breakMergeWaiter = true;
489
- }
490
- }
491
- }
455
+ // Merge FROM SUMMARIES_DIR (where the blob zips live) so the HTML output
456
+ // folder (playwright-report) differs from the blob-extraction folder.
457
+ // When the two match, Playwright wipes the extracted resources before it
458
+ // serializes attachments, which leaves trace paths as absolute runner
459
+ // paths. Keeping them separate lets traces land in playwright-report/data
460
+ // with relative paths that resolve correctly when hosted.
461
+ // execSync blocks until the report (including the base64 data) is fully
462
+ // written, avoiding uploading a half-written index.html.
463
+ execSync(`npx playwright merge-reports --reporter html ${SUMMARIES_DIR}`, { stdio: 'inherit' });
492
464
  console.log('Reports merged successfully.');
493
-
494
- // After merge, extract all blobs from SUMMARIES_DIR to playwright-report
495
- this.unzipBlobsAndCopyResources(SUMMARIES_DIR, PLAYWRIGHT_REPORT_DIR);
496
465
  } catch (error) {
497
466
  // Log a warning instead of throwing an error
498
467
  console.warn('Warning: Failed to merge reports. This may not affect the overall process.', error.message);
@@ -518,53 +487,6 @@ class ResultsParser {
518
487
  }
519
488
  }
520
489
 
521
- unzipBlobsAndCopyResources(ARTIFACTS_DIR, FINAL_OUTPUT_DIR) {
522
- if (!AdmZip) {
523
- console.error('adm-zip is required for blob extraction. Please install it: npm install adm-zip');
524
- return;
525
- }
526
-
527
- // Unzip all blob files into separate folders
528
- for (let i = 1; i <= this.totalShardCount; i++) {
529
- const blobZipFile = path.join(ARTIFACTS_DIR, `blob-report-node-${i}.zip`);
530
- if (fs.existsSync(blobZipFile)) {
531
- const extractDir = path.join(ARTIFACTS_DIR, `${GITHUB_RUN_ID}-blob-contents-node-${i}`);
532
- if (!fs.existsSync(extractDir)) {
533
- fs.mkdirSync(extractDir, { recursive: true });
534
- }
535
-
536
- try {
537
- const zip = new AdmZip(blobZipFile);
538
- zip.extractAllTo(extractDir, true);
539
-
540
- // Check if this folder contains a "resources" folder with zip files
541
- const resourcesDir = path.join(extractDir, 'resources');
542
- if (fs.existsSync(resourcesDir) && fs.statSync(resourcesDir).isDirectory()) {
543
- const files = fs.readdirSync(resourcesDir);
544
- const zipFiles = files.filter(file => file.endsWith('.zip'));
545
-
546
- if (zipFiles.length > 0) {
547
- // Copy the resources folder to finalOutput
548
- const finalResourcesDir = path.join(FINAL_OUTPUT_DIR, 'resources');
549
- if (!fs.existsSync(finalResourcesDir)) {
550
- fs.mkdirSync(finalResourcesDir, { recursive: true });
551
- }
552
-
553
- // Copy each zip file to finalOutput/resources
554
- for (const zipFile of zipFiles) {
555
- const sourceFile = path.join(resourcesDir, zipFile);
556
- const destFile = path.join(finalResourcesDir, zipFile);
557
- fs.copyFileSync(sourceFile, destFile);
558
- }
559
- }
560
- }
561
- } catch (error) {
562
- console.warn(`Failed to extract or process blob-report-node-${i}.zip:`, error.message);
563
- }
564
- }
565
- }
566
- }
567
-
568
490
  async pushReportsToMinio() {
569
491
  if (!process.env.CI) {
570
492
  console.log('Skipping MinIO push: not in CI');
@@ -584,7 +506,11 @@ class ResultsParser {
584
506
  console.log(`Uploading playwright-report to MinIO: ${destination}`);
585
507
  // Pass credentials as separate args (not embedded in a URL) to avoid encoding issues.
586
508
  execFileSync('mc', ['--config-dir', mcConfigDir, 'alias', 'set', MINIO_ALIAS, MINIO_ENDPOINT, MINIO_ACCESS_KEY, MINIO_SECRET_KEY], { stdio: 'ignore' });
587
- execFileSync('mc', ['--config-dir', mcConfigDir, 'cp', '--recursive', `${PLAYWRIGHT_REPORT_DIR}/`, `${destination}/`], { stdio: 'ignore' });
509
+ const cpOutput = execFileSync('mc', ['--config-dir', mcConfigDir, 'cp', '--recursive', `${PLAYWRIGHT_REPORT_DIR}/`, `${destination}/`], { encoding: 'utf8' });
510
+ const summary = cpOutput.split('\n').filter((line) => !line.includes(' -> ')).join('\n').trim();
511
+ if (summary) {
512
+ console.log(summary);
513
+ }
588
514
  console.log(`Successfully uploaded playwright-report to MinIO: ${destination}`);
589
515
  } catch (error) {
590
516
  console.warn('Warning: Failed to push reports to MinIO. This may not affect the overall process.', error.message);
package/package.json CHANGED
@@ -33,7 +33,7 @@
33
33
  "lint-fix": "npx eslint . --ext .ts --fix"
34
34
  },
35
35
  "name": "playwright-slack-report-burak",
36
- "version": "3.5.3",
36
+ "version": "3.5.5",
37
37
  "main": "index.js",
38
38
  "types": "dist/index.d.ts",
39
39
  "author": "Burak B. <burak.boluk@hotmail.com>",