playwright-slack-report-burak 3.0.30 → 3.0.32

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.
@@ -697,16 +697,18 @@ class ResultsParser {
697
697
 
698
698
  // Create temporary config file to specify output folder
699
699
  tempConfigPath = path.join(summariesDir, 'merge-config.js');
700
+ const tempConfigAbsolutePath = path.resolve(tempConfigPath);
700
701
  // Escape backslashes and single quotes in path for JavaScript string
701
702
  const escapedPath = mergedBlobsAbsolutePath.replace(/\\/g, '/').replace(/'/g, "\\'");
702
703
  const configContent = `module.exports = {
703
704
  reporter: [['html', { outputFolder: '${escapedPath}' }]]
704
705
  };`;
705
706
  fs.writeFileSync(tempConfigPath, configContent);
706
- console.log(`Created temporary config file: ${tempConfigPath}`);
707
+ console.log(`Created temporary config file: ${tempConfigAbsolutePath}`);
707
708
  console.log(`Config content: ${configContent}`);
708
709
 
709
- const mergeCommand = `npx playwright merge-reports --reporter html --config "${tempConfigPath}" "${blobReportsRelativePath}"`;
710
+ // Use absolute path for config file to avoid path resolution issues
711
+ const mergeCommand = `npx playwright merge-reports --reporter html --config "${tempConfigAbsolutePath}" "${blobReportsRelativePath}"`;
710
712
  console.log(`Executing: ${mergeCommand}`);
711
713
  const mergeResult = await execAsync(mergeCommand, { cwd: summariesDir });
712
714
  console.log('Merge command output:', mergeResult.stdout);
@@ -733,12 +735,15 @@ class ResultsParser {
733
735
  execSync(`npx playwright merge-reports --reporter html -c ./playwright-report playwright-report`, { stdio: 'inherit' });
734
736
  } finally {
735
737
  // Clean up temporary config file
736
- if (tempConfigPath && fs.existsSync(tempConfigPath)) {
737
- try {
738
- fs.unlinkSync(tempConfigPath);
739
- console.log(`Cleaned up temporary config file: ${tempConfigPath}`);
740
- } catch (cleanupError) {
741
- console.warn(`Warning: Failed to clean up temp config file: ${cleanupError.message}`);
738
+ if (tempConfigPath) {
739
+ const configPathToDelete = fs.existsSync(tempConfigPath) ? tempConfigPath : path.resolve(tempConfigPath);
740
+ if (fs.existsSync(configPathToDelete)) {
741
+ try {
742
+ fs.unlinkSync(configPathToDelete);
743
+ console.log(`Cleaned up temporary config file: ${configPathToDelete}`);
744
+ } catch (cleanupError) {
745
+ console.warn(`Warning: Failed to clean up temp config file: ${cleanupError.message}`);
746
+ }
742
747
  }
743
748
  }
744
749
  }
@@ -6,27 +6,6 @@ const webhook_1 = require("@slack/webhook");
6
6
  const ResultsParser_1 = require("./ResultsParser");
7
7
  const SlackClient_1 = require("./SlackClient");
8
8
  const SlackWebhookClient_1 = require("./SlackWebhookClient");
9
- let axios;
10
- try {
11
- axios = require('axios');
12
- } catch (e) {
13
- // axios optional for GitHub Actions API detection
14
- axios = null;
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
9
 
31
10
  class SlackReporter {
32
11
  customLayout;
@@ -46,11 +25,7 @@ class SlackReporter {
46
25
  suite;
47
26
  separateFlaky = false;
48
27
  logs = [];
49
- fullConfig;
50
28
  onBegin(fullConfig, suite) {
51
- // Log package version
52
- console.log(`đŸ“Ļ [SlackReporter] playwright-slack-report-burak v${packageVersion}`);
53
- this.fullConfig = fullConfig;
54
29
  this.suite = suite;
55
30
  this.logs = [];
56
31
  const slackReporterConfig = fullConfig.reporter.filter((f) => f[0].toLowerCase().includes('slackreporter'))[0][1];
@@ -96,52 +71,11 @@ class SlackReporter {
96
71
  this.log(message);
97
72
  return;
98
73
  }
99
- // SHARDING SUPPORT - Stop slack messages for non-shard-1 shard(s)
100
- // Only shard 1 should post when aggregating results from multiple shards
101
-
102
- // Get shard info from environment variables
103
- const currentShardIndex = process.env.SHARD_INDEX;
104
- const totalShards = process.env.TOTAL_SHARDS ? parseInt(process.env.TOTAL_SHARDS, 10) : 1;
105
-
106
- // CRITICAL: In CI, if we can't detect shard info, block posting
107
- // This prevents duplicate messages when running with multiple shards
108
- if (process.env.CI && currentShardIndex === undefined && totalShards > 1) {
109
- this.log(`❌ [Shard Detection] BLOCKING: CI environment detected but SHARD_INDEX not set.`);
110
- this.log(`❌ This prevents duplicate messages when running with multiple shards.`);
111
- this.log(`❌ Skipping Slack report to prevent duplicate messages from all shards.`);
112
- this.log(`💡 Fix: Add SHARD_INDEX env var to your workflow:`);
113
- this.log(`💡 env:`);
114
- this.log(`💡 SHARD_INDEX: $\{\{ strategy.job-index \}\} # Only shard 1 should post`);
115
- this.log(`💡 TOTAL_SHARDS: $\{\{ strategy.job-total \}\}`);
116
- return;
117
- }
118
-
119
- // Convert to number for comparison (default to 1 if undefined, since shard 1 is the aggregator)
120
- const shardIndexNum = currentShardIndex !== undefined ? parseInt(currentShardIndex, 10) : 1;
121
-
122
- // CRITICAL: Update ResultsParser with detected shard values immediately after detection
123
- // This ensures ResultsParser always has correct values, even if we block posting
124
- this.resultsParser.updateShardInfo(shardIndexNum, totalShards);
125
-
126
- // CRITICAL: ALL shards must create their node_summary files, even if they don't post to Slack
127
- // This must happen BEFORE the early return for non-shard-1 shards
128
74
  const resultSummary = await this.resultsParser.getParsedResults();
129
-
130
- // Only allow shard 1 to post when there are multiple shards
131
- // This ensures only one shard posts the aggregated report
132
- if (totalShards > 1 && shardIndexNum !== 1) {
133
- this.log(`❌ [Shard Detection] BLOCKING: Non-shard-1 detected (shard ${shardIndexNum} of ${totalShards})`);
134
- this.log(`❌ Stopping reporter for shard ${shardIndexNum} of ${totalShards}`);
135
- this.log(`â„šī¸ Only shard 1 will post the aggregated report.`);
136
- this.log(`✅ Node summary file created for shard ${shardIndexNum}`);
137
- return;
138
- }
139
-
140
- // Single shard - always allow posting
141
- if (totalShards === 1) {
142
- this.log(`✅ [Shard Detection] ALLOWING: Single shard detected. Posting Slack report.`);
143
- } else {
144
- this.log(`✅ [Shard Detection] ALLOWING: Multiple shards detected (${totalShards}). Shard ${shardIndexNum} will post aggregated report.`);
75
+ // SHARDING SUPPORT - Stop slack messages for non-shard-1 shard(s)
76
+ if (process.env.SHARD_INDEX && process.env.SHARD_INDEX !== '1') {
77
+ this.log(`❌ Stopping reporter for non-shard-1 index ${process.env.SHARD_INDEX} of ${process.env.TOTAL_SHARDS}`);
78
+ return;
145
79
  }
146
80
  resultSummary.meta = this.meta;
147
81
  const maxRetry = Math.max(...resultSummary.tests.map((o) => o.retry));
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.30",
35
+ "version": "3.0.32",
36
36
  "main": "index.js",
37
37
  "types": "dist/index.d.ts",
38
38
  "author": "Burak B. <burak.boluk@hotmail.com>",