playwright-slack-report-burak 3.0.7 → 3.0.9
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.
|
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
|
|
11
11
|
// Helper function to get build URL and CI platform name
|
|
12
12
|
const getBuildInfo = () => {
|
|
13
|
-
if (process.env.GITHUB_ACTIONS || process.env.
|
|
13
|
+
if (process.env.GITHUB_ACTIONS || process.env.SAFETYWINGTEST_GITHUB_TOKEN) {
|
|
14
14
|
const repo = process.env.GITHUB_REPOSITORY;
|
|
15
15
|
const runId = process.env.GITHUB_RUN_ID;
|
|
16
16
|
const serverUrl = process.env.GITHUB_SERVER_URL || 'https://github.com';
|
|
@@ -429,12 +429,12 @@ class ResultsParser {
|
|
|
429
429
|
}
|
|
430
430
|
|
|
431
431
|
async fetchArtifactFromGitHubActions(i, file, filePath) {
|
|
432
|
-
const githubToken = process.env.
|
|
432
|
+
const githubToken = process.env.SAFETYWINGTEST_GITHUB_TOKEN;
|
|
433
433
|
const repo = process.env.GITHUB_REPOSITORY;
|
|
434
434
|
const runId = process.env.GITHUB_RUN_ID;
|
|
435
435
|
|
|
436
436
|
if (!githubToken || !repo) {
|
|
437
|
-
console.error('GitHub Actions: Missing
|
|
437
|
+
console.error('GitHub Actions: Missing SAFETYWINGTEST_GITHUB_TOKEN or GITHUB_REPOSITORY');
|
|
438
438
|
return;
|
|
439
439
|
}
|
|
440
440
|
|
|
@@ -80,14 +80,17 @@ class SlackReporter {
|
|
|
80
80
|
if (!process.env.GITHUB_ACTIONS || process.env.GITHUB_ACTIONS !== 'true') {
|
|
81
81
|
return null;
|
|
82
82
|
}
|
|
83
|
-
|
|
83
|
+
// Try GITHUB_TOKEN first (automatic), then fallback to custom token
|
|
84
|
+
const githubToken = process.env.GITHUB_TOKEN || process.env.SAFETYWINGTEST_GITHUB_TOKEN;
|
|
84
85
|
const repo = process.env.GITHUB_REPOSITORY;
|
|
85
86
|
const runId = process.env.GITHUB_RUN_ID;
|
|
86
87
|
const currentJobId = process.env.GITHUB_JOB;
|
|
87
88
|
if (!githubToken || !repo || !runId) {
|
|
88
|
-
this.log(`🔍 [GitHub Actions Detection] Missing required env vars:
|
|
89
|
+
this.log(`🔍 [GitHub Actions Detection] Missing required env vars: GITHUB_TOKEN=${!!process.env.GITHUB_TOKEN}, SAFETYWINGTEST_GITHUB_TOKEN=${!!process.env.SAFETYWINGTEST_GITHUB_TOKEN}, GITHUB_REPOSITORY=${!!repo}, GITHUB_RUN_ID=${!!runId}`);
|
|
89
90
|
return null;
|
|
90
91
|
}
|
|
92
|
+
this.log(`🔍 [GitHub Actions Detection] Using token: ${process.env.GITHUB_TOKEN ? 'GITHUB_TOKEN' : 'SAFETYWINGTEST_GITHUB_TOKEN'}`);
|
|
93
|
+
this.log(`🔍 [GitHub Actions Detection] Repository: ${repo}, Run ID: ${runId}`);
|
|
91
94
|
if (!axios) {
|
|
92
95
|
this.log(`🔍 [GitHub Actions Detection] axios not available, skipping API detection`);
|
|
93
96
|
return null;
|
|
@@ -170,9 +173,33 @@ class SlackReporter {
|
|
|
170
173
|
totalShards
|
|
171
174
|
};
|
|
172
175
|
} catch (error) {
|
|
176
|
+
const apiUrl = `https://api.github.com/repos/${repo}/actions/runs/${runId}/jobs`;
|
|
173
177
|
this.log(`🔍 [GitHub Actions Detection] Failed to detect via API: ${error.message}`);
|
|
174
178
|
if (error.response) {
|
|
175
|
-
|
|
179
|
+
const status = error.response.status;
|
|
180
|
+
const data = error.response.data;
|
|
181
|
+
this.log(`🔍 Status: ${status}, URL: ${apiUrl}`);
|
|
182
|
+
|
|
183
|
+
if (status === 404) {
|
|
184
|
+
this.log(`🔍 404 Error Details:`);
|
|
185
|
+
this.log(`🔍 - Repository: ${repo}`);
|
|
186
|
+
this.log(`🔍 - Run ID: ${runId}`);
|
|
187
|
+
this.log(`🔍 - Possible causes:`);
|
|
188
|
+
this.log(`🔍 1. Token lacks 'actions: read' permission`);
|
|
189
|
+
this.log(`🔍 2. Workflow run doesn't exist or isn't accessible`);
|
|
190
|
+
this.log(`🔍 3. Jobs not available yet (try accessing after workflow starts)`);
|
|
191
|
+
this.log(`🔍 - Recommendation: Set MATRIX_SHARD and MATRIX_COUNT env vars as fallback`);
|
|
192
|
+
} else if (status === 401 || status === 403) {
|
|
193
|
+
this.log(`🔍 Authentication/Authorization Error:`);
|
|
194
|
+
this.log(`🔍 - Token may be invalid or lack required permissions`);
|
|
195
|
+
this.log(`🔍 - Required permission: 'actions: read' or 'repo' scope`);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (data && data.message) {
|
|
199
|
+
this.log(`🔍 Error message: ${data.message}`);
|
|
200
|
+
}
|
|
201
|
+
} else {
|
|
202
|
+
this.log(`🔍 Network error or no response received`);
|
|
176
203
|
}
|
|
177
204
|
return null;
|
|
178
205
|
}
|
|
@@ -270,7 +297,7 @@ class SlackReporter {
|
|
|
270
297
|
this.log(`💡 env:`);
|
|
271
298
|
this.log(`💡 MATRIX_SHARD: $\{\{ strategy.job-index \}\} # 0-based (only shard 0 posts)`);
|
|
272
299
|
this.log(`💡 MATRIX_COUNT: $\{\{ strategy.job-total \}\}`);
|
|
273
|
-
this.log(`💡 OR ensure
|
|
300
|
+
this.log(`💡 OR ensure SAFETYWINGTEST_GITHUB_TOKEN has workflow permissions for API detection`);
|
|
274
301
|
return;
|
|
275
302
|
}
|
|
276
303
|
|
package/package.json
CHANGED