playwright-slack-report-burak 3.1.1 → 3.1.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.
@@ -39,20 +39,12 @@ const GCS_SERVICE_ACCOUNT_KEY = process.env.GCS_SERVICE_ACCOUNT_KEY;
39
39
  const GCS_REPORTS_FOLDER_PREFIX = process.env.GCS_REPORTS_FOLDER_PREFIX;
40
40
  const GCS_UPLOAD_API_BASE_URL = process.env.GCS_UPLOAD_API_BASE_URL;
41
41
 
42
- // Artifact patterns
43
- const ARTIFACT_NAME_PATTERNS = [
44
- 'html-report',
45
- 'blob-report-node',
46
- 'test-results',
47
- ];
48
-
49
42
  // GitHub API endpoints (for artifact fetching)
50
43
  const GITHUB_API_BASE_URL = 'https://api.github.com';
51
44
  const GITHUB_API_ARTIFACTS_ENDPOINT = '/actions/artifacts';
52
45
 
53
- // Helper functions for building GitHub API URLs and patterns
46
+ // Helper functions for building GitHub API URLs
54
47
  const getGitHubArtifactsApiUrl = () => `${GITHUB_API_BASE_URL}/repos/${GITHUB_REPOSITORY}${GITHUB_API_ARTIFACTS_ENDPOINT}`;
55
- const getArtifactNamePatterns = (shardIndex) => ARTIFACT_NAME_PATTERNS.map(pattern => `${pattern}-${shardIndex}`);
56
48
 
57
49
  // Helper functions for report paths
58
50
  const getRunFolder = () => `${GCS_REPORTS_FOLDER_PREFIX}/${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}`;
@@ -388,14 +380,11 @@ class ResultsParser {
388
380
  const playwrightReportDir = path.join('./', 'playwright-report');
389
381
  if (fs.existsSync(playwrightReportDir)) {
390
382
  this.copyDirectoryRecursive(playwrightReportDir, SUMMARIES_DIR);
391
- console.log(`Copied entire contents of playwright-report to ${SUMMARIES_DIR}`);
392
383
  } else {
393
384
  console.warn('Warning: playwright-report directory not found');
394
385
  }
395
386
 
396
387
  while (!this.allNodeSummaryFilesExist() || !this.allBlobZipsExist()) {
397
- console.log('Checking if all node summary files exist...');
398
- console.log('Waiting for all blob zips to exist...');
399
388
  if (!fs.existsSync(SUMMARIES_DIR)) {
400
389
  fs.mkdirSync(SUMMARIES_DIR, { recursive: true });
401
390
  }
@@ -413,11 +402,15 @@ class ResultsParser {
413
402
 
414
403
  async fetchArtifactFromGitHubActions(i, file, filePath) {
415
404
  const githubApiUrl = getGitHubArtifactsApiUrl();
416
- const artifactNamePatterns = getArtifactNamePatterns(i);
405
+
406
+ if (!AdmZip) {
407
+ console.error('adm-zip is required for GitHub Actions artifact extraction. Please install it: npm install adm-zip');
408
+ return;
409
+ }
417
410
 
418
411
  while (true) {
419
412
  try {
420
- // List all artifacts to find the one we need
413
+ // List all artifacts
421
414
  const listResponse = await axios.get(githubApiUrl, {
422
415
  headers: {
423
416
  'Authorization': `token ${GITHUB_TOKEN}`,
@@ -428,46 +421,41 @@ class ResultsParser {
428
421
  }
429
422
  });
430
423
 
431
- // Try to find artifact matching any of our patterns
432
- let artifact = null;
433
- for (const pattern of artifactNamePatterns) {
434
- artifact = listResponse.data.artifacts.find(
435
- (a) => a.name === pattern ||
436
- a.name.includes(`shard-${i}`) ||
437
- a.name.includes(`node-${i}`)
438
- );
439
- if (artifact) break;
440
- }
441
-
442
- if (artifact && artifact.archive_download_url) {
443
- // Download the artifact ZIP
444
- const downloadResponse = await axios.get(artifact.archive_download_url, {
445
- headers: {
446
- 'Authorization': `token ${GITHUB_TOKEN}`,
447
- 'Accept': 'application/vnd.github.v3+json'
448
- },
449
- responseType: 'arraybuffer'
450
- });
451
-
452
- if (!AdmZip) {
453
- console.error('adm-zip is required for GitHub Actions artifact extraction. Please install it: npm install adm-zip');
454
- return;
455
- }
424
+ // Search through all artifacts to find the one containing our file
425
+ let found = false;
426
+ for (const artifact of listResponse.data.artifacts) {
427
+ if (!artifact.archive_download_url) continue;
456
428
 
457
- // Extract ZIP and find the specific file
458
- const zip = new AdmZip(downloadResponse.data);
459
- const zipEntry = zip.getEntry(file) || zip.getEntry(`playwright-artifacts/${file}`);
460
-
461
- if (zipEntry) {
462
- fs.writeFileSync(filePath, zipEntry.getData());
463
- console.log(`Successfully fetched file ${file} from shard ${i}`);
464
- break;
465
- } else {
466
- console.warn(`File ${file} not found in artifact ${artifact.name}. Retrying in 10 seconds...`);
467
- await new Promise(resolve => setTimeout(resolve, 10000));
429
+ try {
430
+ // Download the artifact ZIP
431
+ const downloadResponse = await axios.get(artifact.archive_download_url, {
432
+ headers: {
433
+ 'Authorization': `token ${GITHUB_TOKEN}`,
434
+ 'Accept': 'application/vnd.github.v3+json'
435
+ },
436
+ responseType: 'arraybuffer'
437
+ });
438
+
439
+ // Extract ZIP and find the specific file
440
+ const zip = new AdmZip(downloadResponse.data);
441
+ const zipEntry = zip.getEntry(file) || zip.getEntry(`playwright-artifacts/${file}`);
442
+
443
+ if (zipEntry) {
444
+ fs.writeFileSync(filePath, zipEntry.getData());
445
+ console.log(`Successfully fetched file ${file} from artifact ${artifact.name}`);
446
+ found = true;
447
+ break;
448
+ }
449
+ } catch (searchError) {
450
+ // Continue searching other artifacts
451
+ continue;
468
452
  }
453
+ }
454
+
455
+ if (found) {
456
+ break;
469
457
  } else {
470
- console.warn(`Artifact not found (tried: ${artifactNamePatterns.join(', ')}). Retrying in 10 seconds...`);
458
+ console.warn(`File ${file} not found in any artifact. Retrying in 10 seconds...`);
471
459
  await new Promise(resolve => setTimeout(resolve, 10000));
472
460
  }
473
461
  } catch (error) {
@@ -492,7 +480,6 @@ class ResultsParser {
492
480
  try {
493
481
  const destFile = path.join(PLAYWRIGHT_REPORT_DIR, `blob-report-node-${i}.zip`);
494
482
  fs.copyFileSync(blobZipFile, destFile);
495
- console.log(`Copied blob-report-node-${i}.zip to playwright-report for merging`);
496
483
  } catch (error) {
497
484
  console.warn(`Failed to copy blob-report-node-${i}.zip for merging:`, error.message);
498
485
  }
@@ -561,7 +548,6 @@ class ResultsParser {
561
548
  try {
562
549
  const zip = new AdmZip(blobZipFile);
563
550
  zip.extractAllTo(extractDir, true);
564
- console.log(`Extracted blob-report-node-${i}.zip to ${extractDir}`);
565
551
 
566
552
  // Check if this folder contains a "resources" folder with zip files
567
553
  const resourcesDir = path.join(extractDir, 'resources');
@@ -581,7 +567,6 @@ class ResultsParser {
581
567
  const sourceFile = path.join(resourcesDir, zipFile);
582
568
  const destFile = path.join(finalResourcesDir, zipFile);
583
569
  fs.copyFileSync(sourceFile, destFile);
584
- console.log(`Copied ${zipFile} to finalOutput/resources`);
585
570
  }
586
571
  }
587
572
  }
@@ -667,8 +652,6 @@ class ResultsParser {
667
652
  'Content-Type': this.getContentType(file)
668
653
  }
669
654
  });
670
-
671
- console.log(`Uploaded ${objectPath} to GCS`);
672
655
  }
673
656
 
674
657
  console.log(`Successfully uploaded ${files.length} files to GCS bucket: ${GCS_BUCKET_NAME} in folder: ${getRunFolder()}`);
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.1.1",
36
+ "version": "3.1.3",
37
37
  "main": "index.js",
38
38
  "types": "dist/index.d.ts",
39
39
  "author": "Burak B. <burak.boluk@hotmail.com>",