playwright-slack-report-burak 3.0.13 → 3.0.15

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.
@@ -18,6 +18,18 @@ try {
18
18
  AdmZip = null;
19
19
  }
20
20
 
21
+ // Get package version
22
+ let packageVersion = 'unknown';
23
+ try {
24
+ const packageJsonPath = path.join(__dirname, '../../package.json');
25
+ if (fs.existsSync(packageJsonPath)) {
26
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
27
+ packageVersion = packageJson.version || 'unknown';
28
+ }
29
+ } catch (e) {
30
+ // Version detection failed, use default
31
+ }
32
+
21
33
  class ResultsParser {
22
34
  result;
23
35
  separateFlakyTests;
@@ -34,6 +46,8 @@ class ResultsParser {
34
46
  constructor(options = { separateFlakyTests: false }) {
35
47
  this.result = [];
36
48
  this.separateFlakyTests = options.separateFlakyTests;
49
+ // Log package version
50
+ console.log(`📦 [ResultsParser] playwright-slack-report-burak v${packageVersion}`);
37
51
  // Log shard detection in ResultsParser
38
52
  console.log('🔍 [ResultsParser] Initialized with shard detection:');
39
53
  console.log(`🔍 MATRIX_SHARD env: ${process.env.MATRIX_SHARD !== undefined ? `"${process.env.MATRIX_SHARD}"` : 'undefined'}`);
@@ -42,6 +56,16 @@ class ResultsParser {
42
56
  console.log(`🔍 Calculated shardIndex: ${this.shardIndex}`);
43
57
  console.log(`🔍 Calculated totalShardCount: ${this.totalShardCount}`);
44
58
  }
59
+ /**
60
+ * Update shard information after detection (e.g., from GitHub API)
61
+ * @param {number} shardIndex - The current shard index (0-based)
62
+ * @param {number} totalShardCount - The total number of shards
63
+ */
64
+ updateShardInfo(shardIndex, totalShardCount) {
65
+ this.shardIndex = shardIndex;
66
+ this.totalShardCount = totalShardCount;
67
+ console.log(`🔍 [ResultsParser] Updated shard info: shardIndex=${this.shardIndex}, totalShardCount=${this.totalShardCount}`);
68
+ }
45
69
  async getParsedResults() {
46
70
  const summary = {
47
71
  total: 0,
@@ -13,6 +13,21 @@ try {
13
13
  // axios optional for GitHub Actions API detection
14
14
  axios = null;
15
15
  }
16
+
17
+ // Get package version
18
+ const fs = require('fs');
19
+ const path = require('path');
20
+ let packageVersion = 'unknown';
21
+ try {
22
+ const packageJsonPath = path.join(__dirname, '../../package.json');
23
+ if (fs.existsSync(packageJsonPath)) {
24
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
25
+ packageVersion = packageJson.version || 'unknown';
26
+ }
27
+ } catch (e) {
28
+ // Version detection failed, use default
29
+ }
30
+
16
31
  class SlackReporter {
17
32
  customLayout;
18
33
  customLayoutAsync;
@@ -32,6 +47,8 @@ class SlackReporter {
32
47
  separateFlaky = false;
33
48
  logs = [];
34
49
  onBegin(fullConfig, suite) {
50
+ // Log package version
51
+ console.log(`📦 [SlackReporter] playwright-slack-report-burak v${packageVersion}`);
35
52
  this.suite = suite;
36
53
  this.logs = [];
37
54
  const slackReporterConfig = fullConfig.reporter.filter((f) => f[0].toLowerCase().includes('slackreporter'))[0][1];
@@ -400,6 +417,10 @@ class SlackReporter {
400
417
  this.log(`🔍 shardIndexNum (number): ${shardIndexNum}`);
401
418
  this.log(`🔍 totalShards: ${totalShards}`);
402
419
 
420
+ // CRITICAL: Update ResultsParser with detected shard values immediately after detection
421
+ // This ensures ResultsParser always has correct values, even if we block posting
422
+ this.resultsParser.updateShardInfo(shardIndexNum, totalShards);
423
+
403
424
  // CRITICAL: For GitHub Actions with multiple shards, only shard 0 should post
404
425
  // If we're in CI with multiple shards and don't know which shard we are, block all posts
405
426
  // This prevents duplicate messages when MATRIX_SHARD/MATRIX_INDEX is not set
package/package.json CHANGED
@@ -32,7 +32,7 @@
32
32
  "lint-fix": "npx eslint . --ext .ts --fix"
33
33
  },
34
34
  "name": "playwright-slack-report-burak",
35
- "version": "3.0.13",
35
+ "version": "3.0.15",
36
36
  "main": "index.js",
37
37
  "types": "dist/index.d.ts",
38
38
  "author": "Burak B. <burak.boluk@hotmail.com>",