playwright-slack-report-burak 3.0.3 â 3.0.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.
- package/dist/src/ResultsParser.js +17 -2
- package/dist/src/SlackReporter.js +31 -3
- package/package.json +1 -1
|
@@ -34,6 +34,13 @@ class ResultsParser {
|
|
|
34
34
|
constructor(options = { separateFlakyTests: false }) {
|
|
35
35
|
this.result = [];
|
|
36
36
|
this.separateFlakyTests = options.separateFlakyTests;
|
|
37
|
+
// Log shard detection in ResultsParser
|
|
38
|
+
console.log('đ [ResultsParser] Initialized with shard detection:');
|
|
39
|
+
console.log(`đ MATRIX_SHARD env: ${process.env.MATRIX_SHARD !== undefined ? `"${process.env.MATRIX_SHARD}"` : 'undefined'}`);
|
|
40
|
+
console.log(`đ MATRIX_INDEX env: ${process.env.MATRIX_INDEX !== undefined ? `"${process.env.MATRIX_INDEX}"` : 'undefined'}`);
|
|
41
|
+
console.log(`đ MATRIX_COUNT env: ${process.env.MATRIX_COUNT !== undefined ? `"${process.env.MATRIX_COUNT}"` : 'undefined'}`);
|
|
42
|
+
console.log(`đ Calculated shardIndex: ${this.shardIndex}`);
|
|
43
|
+
console.log(`đ Calculated totalShardCount: ${this.totalShardCount}`);
|
|
37
44
|
}
|
|
38
45
|
async getParsedResults() {
|
|
39
46
|
const summary = {
|
|
@@ -90,19 +97,27 @@ class ResultsParser {
|
|
|
90
97
|
// Create the file
|
|
91
98
|
fs.writeFileSync(nodeSummaryFile, JSON.stringify(nodeSummary, null, 2));
|
|
92
99
|
|
|
100
|
+
console.log(`đ [ResultsParser] Current shard: ${this.shardIndex}, Total shards: ${this.totalShardCount}`);
|
|
101
|
+
console.log(`đ [ResultsParser] Created node summary file: ${nodeSummaryFile}`);
|
|
102
|
+
|
|
93
103
|
if (this.shardIndex === 0 && this.totalShardCount > 1) {
|
|
104
|
+
console.log(`đ [ResultsParser] Shard 0 detected with ${this.totalShardCount} total shards - will fetch artifacts from other shards`);
|
|
94
105
|
if (process.env.CI) {
|
|
95
|
-
console.log('
|
|
106
|
+
console.log('đ [ResultsParser] CI environment detected - fetching all artifacts from GitHub Actions...');
|
|
96
107
|
await this.fetchAllArtifacts();
|
|
97
108
|
} else {
|
|
109
|
+
console.log('đ [ResultsParser] Local environment - waiting for artifacts to appear...');
|
|
98
110
|
while (!this.allNodeSummaryFilesExist() || !this.allBlobZipsExist()) {
|
|
99
|
-
console.log('Waiting for all
|
|
111
|
+
console.log('đ [ResultsParser] Waiting for all artifacts to exist...');
|
|
100
112
|
await new Promise(resolve => setTimeout(resolve, 1000)); // Wait for 1 second
|
|
101
113
|
}
|
|
102
114
|
}
|
|
115
|
+
} else {
|
|
116
|
+
console.log(`đ [ResultsParser] Not shard 0 (current: ${this.shardIndex}) or single shard (total: ${this.totalShardCount}) - skipping artifact fetch`);
|
|
103
117
|
}
|
|
104
118
|
|
|
105
119
|
if (this.shardIndex === 0 && this.allNodeSummaryFilesExist() && this.allBlobZipsExist()) {
|
|
120
|
+
console.log(`đ [ResultsParser] Shard 0: All artifacts available, merging results from all shards...`);
|
|
106
121
|
// Merge all node summaries into the final summary
|
|
107
122
|
for (let i = 0; i < this.totalShardCount; i++) {
|
|
108
123
|
const nodeSummaryFile = path.join(summariesDir, `node_summary_${i}.json`);
|
|
@@ -73,31 +73,58 @@ class SlackReporter {
|
|
|
73
73
|
// SHARDING SUPPORT - Stop slack messages for non-zero index shard(s)
|
|
74
74
|
// Only shard 0 (0-based) should post when aggregating results from multiple shards
|
|
75
75
|
|
|
76
|
+
this.log('đ [Shard Detection] Starting shard detection logic...');
|
|
77
|
+
|
|
78
|
+
// Log all relevant environment variables
|
|
79
|
+
this.log(`đ [Shard Detection] Environment variables:`);
|
|
80
|
+
this.log(`đ CI: ${process.env.CI !== undefined ? `"${process.env.CI}"` : 'undefined'}`);
|
|
81
|
+
this.log(`đ MATRIX_SHARD: ${process.env.MATRIX_SHARD !== undefined ? `"${process.env.MATRIX_SHARD}"` : 'undefined'}`);
|
|
82
|
+
this.log(`đ MATRIX_INDEX: ${process.env.MATRIX_INDEX !== undefined ? `"${process.env.MATRIX_INDEX}"` : 'undefined'}`);
|
|
83
|
+
this.log(`đ MATRIX_COUNT: ${process.env.MATRIX_COUNT !== undefined ? `"${process.env.MATRIX_COUNT}"` : 'undefined'}`);
|
|
84
|
+
|
|
76
85
|
// Detect shard index from multiple sources (GitHub Actions compatible)
|
|
86
|
+
// Note: In GitHub Actions workflow, you need to set these env vars:
|
|
87
|
+
// env:
|
|
88
|
+
// MATRIX_SHARD: ${{ strategy.job-index }} # 0-based
|
|
89
|
+
// MATRIX_COUNT: ${{ strategy.job-total }}
|
|
77
90
|
let currentShardIndex = process.env.MATRIX_SHARD !== undefined
|
|
78
91
|
? process.env.MATRIX_SHARD
|
|
79
92
|
: (process.env.MATRIX_INDEX !== undefined ? process.env.MATRIX_INDEX : undefined);
|
|
80
93
|
|
|
94
|
+
this.log(`đ [Shard Detection] Initial currentShardIndex: ${currentShardIndex !== undefined ? `"${currentShardIndex}"` : 'undefined'}`);
|
|
95
|
+
|
|
81
96
|
// Get shard info from ResultsParser which might have detected it
|
|
82
97
|
const parserShardIndex = this.resultsParser.shardIndex;
|
|
83
98
|
const parserTotalShards = this.resultsParser.totalShardCount;
|
|
84
99
|
|
|
100
|
+
this.log(`đ [Shard Detection] ResultsParser values:`);
|
|
101
|
+
this.log(`đ parserShardIndex: ${parserShardIndex !== undefined ? parserShardIndex : 'undefined'}`);
|
|
102
|
+
this.log(`đ parserTotalShards: ${parserTotalShards !== undefined ? parserTotalShards : 'undefined'}`);
|
|
103
|
+
|
|
85
104
|
// Use parser values if env vars not set
|
|
86
105
|
const totalShards = process.env.MATRIX_COUNT ? parseInt(process.env.MATRIX_COUNT, 10) : parserTotalShards;
|
|
87
106
|
|
|
107
|
+
this.log(`đ [Shard Detection] Calculated totalShards: ${totalShards}`);
|
|
108
|
+
|
|
88
109
|
// If we still don't have shard index, try to infer from parser
|
|
89
110
|
if (currentShardIndex === undefined && parserShardIndex !== undefined) {
|
|
90
111
|
currentShardIndex = parserShardIndex.toString();
|
|
112
|
+
this.log(`đ [Shard Detection] Using parserShardIndex as fallback: "${currentShardIndex}"`);
|
|
91
113
|
}
|
|
92
114
|
|
|
93
115
|
// Convert to number for comparison (default to 0 if undefined)
|
|
94
116
|
const shardIndexNum = currentShardIndex !== undefined ? parseInt(currentShardIndex, 10) : 0;
|
|
95
117
|
|
|
118
|
+
this.log(`đ [Shard Detection] Final values:`);
|
|
119
|
+
this.log(`đ currentShardIndex (string): ${currentShardIndex !== undefined ? `"${currentShardIndex}"` : 'undefined'}`);
|
|
120
|
+
this.log(`đ shardIndexNum (number): ${shardIndexNum}`);
|
|
121
|
+
this.log(`đ totalShards: ${totalShards}`);
|
|
122
|
+
|
|
96
123
|
// CRITICAL: For GitHub Actions with multiple shards, only shard 0 should post
|
|
97
124
|
// If we're in CI with multiple shards and don't know which shard we are, block all posts
|
|
98
125
|
// This prevents duplicate messages when MATRIX_SHARD/MATRIX_INDEX is not set
|
|
99
126
|
if (process.env.CI && totalShards > 1 && currentShardIndex === undefined) {
|
|
100
|
-
this.log(`â
|
|
127
|
+
this.log(`â [Shard Detection] BLOCKING: CI environment detected with ${totalShards} shards but shard index not set (MATRIX_SHARD/MATRIX_INDEX missing).`);
|
|
101
128
|
this.log(`â Skipping Slack report to prevent duplicate messages from all shards.`);
|
|
102
129
|
this.log(`đĄ Fix: Add these env vars to your workflow:`);
|
|
103
130
|
this.log(`đĄ env:`);
|
|
@@ -109,6 +136,7 @@ class SlackReporter {
|
|
|
109
136
|
// Only allow shard 0 (0-based) to post when there are multiple shards
|
|
110
137
|
// This ensures only one shard posts the aggregated report
|
|
111
138
|
if (totalShards > 1 && shardIndexNum !== 0) {
|
|
139
|
+
this.log(`â [Shard Detection] BLOCKING: Non-zero shard detected (shard ${currentShardIndex} of ${totalShards})`);
|
|
112
140
|
this.log(`â Stopping reporter for non-zero index shard ${currentShardIndex} of ${totalShards}`);
|
|
113
141
|
this.log(`âšī¸ Only shard 0 will post the aggregated report.`);
|
|
114
142
|
return;
|
|
@@ -116,9 +144,9 @@ class SlackReporter {
|
|
|
116
144
|
|
|
117
145
|
// Single shard - always allow posting
|
|
118
146
|
if (totalShards === 1) {
|
|
119
|
-
this.log(
|
|
147
|
+
this.log(`â
[Shard Detection] ALLOWING: Single shard detected. Posting Slack report.`);
|
|
120
148
|
} else {
|
|
121
|
-
this.log(
|
|
149
|
+
this.log(`â
[Shard Detection] ALLOWING: Multiple shards detected (${totalShards}). Shard ${currentShardIndex} (index ${shardIndexNum}) will post aggregated report.`);
|
|
122
150
|
}
|
|
123
151
|
|
|
124
152
|
const resultSummary = await this.resultsParser.getParsedResults();
|
package/package.json
CHANGED