playwright-slack-report-burak 3.0.8 → 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.
@@ -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
- const githubToken = process.env.SAFETYWINGTEST_GITHUB_TOKEN;
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: SAFETYWINGTEST_GITHUB_TOKEN=${!!githubToken}, GITHUB_REPOSITORY=${!!repo}, GITHUB_RUN_ID=${!!runId}`);
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
- this.log(`🔍 Status: ${error.response.status}, Data: ${JSON.stringify(error.response.data)}`);
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
  }
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.8",
35
+ "version": "3.0.9",
36
36
  "main": "index.js",
37
37
  "types": "dist/index.d.ts",
38
38
  "author": "Burak B. <burak.boluk@hotmail.com>",