playwright-slack-report-burak 3.2.3 → 3.3.0

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.
@@ -53,8 +53,8 @@ const getGcsObjectPath = (relativePath) => `${getRunFolder()}/${relativePath}`;
53
53
  class ResultsParser {
54
54
  result;
55
55
  separateFlakyTests;
56
- totalShardCount = process.env.TOTAL_SHARDS
57
- ? parseInt(process.env.TOTAL_SHARDS, 10)
56
+ totalShardCount = process.env.CI && process.env.TOTAL_SHARDS
57
+ ? parseInt(process.env.TOTAL_SHARDS, 10)
58
58
  : 1;
59
59
  shardIndex = process.env.SHARD_INDEX !== undefined
60
60
  ? parseInt(process.env.SHARD_INDEX, 10)
@@ -129,21 +129,34 @@ class ResultsParser {
129
129
  }
130
130
  }
131
131
 
132
- if (this.shardIndex === 1 && this.allNodeSummaryFilesExist() && this.allBlobZipsExist()) {
132
+ // Single shard: copy playwright-report to SUMMARIES_DIR so merge logic finds files
133
+ if (this.shardIndex === 1 && this.totalShardCount === 1) {
134
+ if (!fs.existsSync(SUMMARIES_DIR)) {
135
+ fs.mkdirSync(SUMMARIES_DIR, { recursive: true });
136
+ }
137
+ if (fs.existsSync(PLAYWRIGHT_REPORT_DIR)) {
138
+ this.copyDirectoryRecursive(PLAYWRIGHT_REPORT_DIR, SUMMARIES_DIR);
139
+ }
140
+ }
141
+
142
+ const canMerge = this.shardIndex === 1 && this.allNodeSummaryFilesExist() && this.allBlobZipsExist();
143
+ const singleShardNoBlob = this.shardIndex === 1 && this.totalShardCount === 1 && this.allNodeSummaryFilesExist() && !this.allBlobZipsExist();
144
+
145
+ if (canMerge) {
133
146
  // Merge all node summaries into the final summary
134
147
  for (let i = 1; i <= this.totalShardCount; i++) {
135
148
  const nodeSummaryFile = path.join(SUMMARIES_DIR, `node_summary_${i}.json`);
136
149
  const fileToRead = nodeSummaryFile;
137
150
 
138
151
  if (fs.existsSync(fileToRead)) {
139
- const nodeSummary = JSON.parse(fs.readFileSync(fileToRead, 'utf-8'));
152
+ const nodeSummaryData = JSON.parse(fs.readFileSync(fileToRead, 'utf-8'));
140
153
  // Don't add the inflated totals - calculate from outcomes instead
141
- summary.passed += nodeSummary.passed;
142
- summary.failed += nodeSummary.failed;
143
- summary.flaky += nodeSummary.flaky;
144
- summary.skipped += nodeSummary.skipped;
145
- summary.failures = summary.failures.concat(nodeSummary.failures);
146
- summary.tests = summary.tests.concat(nodeSummary.tests);
154
+ summary.passed += nodeSummaryData.passed;
155
+ summary.failed += nodeSummaryData.failed;
156
+ summary.flaky += nodeSummaryData.flaky;
157
+ summary.skipped += nodeSummaryData.skipped;
158
+ summary.failures = summary.failures.concat(nodeSummaryData.failures);
159
+ summary.tests = summary.tests.concat(nodeSummaryData.tests);
147
160
  }
148
161
  }
149
162
 
@@ -169,6 +182,17 @@ class ResultsParser {
169
182
 
170
183
  await this.mergeReports();
171
184
  await this.pushReportsToGCS();
185
+ } else if (singleShardNoBlob) {
186
+ // Single shard without blob (e.g. different reporter config): use node summary for Slack report
187
+ const nodeSummaryFile = path.join(SUMMARIES_DIR, 'node_summary_1.json');
188
+ const nodeSummaryData = JSON.parse(fs.readFileSync(nodeSummaryFile, 'utf-8'));
189
+ summary.passed = nodeSummaryData.passed;
190
+ summary.failed = nodeSummaryData.failed;
191
+ summary.flaky = nodeSummaryData.flaky;
192
+ summary.skipped = nodeSummaryData.skipped;
193
+ summary.failures = nodeSummaryData.failures || [];
194
+ summary.tests = nodeSummaryData.tests || [];
195
+ summary.total = summary.passed + summary.failed + summary.flaky + summary.skipped;
172
196
  }
173
197
  return summary;
174
198
  }
@@ -420,8 +444,12 @@ class ResultsParser {
420
444
  },
421
445
  params: { per_page: 100 }
422
446
  });
447
+ const runPrefix = `${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}`;
423
448
  const artifact = (listResponse.data.artifacts || []).find(
424
- (a) => (a.name || '').endsWith(`-artifacts-shard-${shard}`)
449
+ (a) => {
450
+ const name = a.name || '';
451
+ return name.startsWith(runPrefix) && name.endsWith(`-artifacts-shard-${shard}`);
452
+ }
425
453
  );
426
454
  if (!artifact?.archive_download_url) return false;
427
455
  const downloadResponse = await axios.get(artifact.archive_download_url, {
@@ -437,7 +465,7 @@ class ResultsParser {
437
465
  const baseName = path.basename(entry.entryName);
438
466
  if (targetFiles.includes(baseName)) {
439
467
  fs.writeFileSync(path.join(SUMMARIES_DIR, baseName), entry.getData());
440
- console.log(`Successfully fetched ${baseName} from shard ${shard}`);
468
+ console.log(`Successfully fetched ${baseName} from artifact ${artifact.name}`);
441
469
  }
442
470
  }
443
471
  return true;
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.2.3",
36
+ "version": "3.3.0",
37
37
  "main": "index.js",
38
38
  "types": "dist/index.d.ts",
39
39
  "author": "Burak B. <burak.boluk@hotmail.com>",