@e2e-dev/github 0.4.2-nightly-20261016073603 → 0.4.2
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/.build.json +1 -1
- package/dist/post.js +23 -4
- package/package.json +3 -3
package/dist/.build.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.4.2
|
|
1
|
+
{"version":"0.4.2"}
|
package/dist/post.js
CHANGED
|
@@ -33,19 +33,38 @@ function send(params, method, route, body) {
|
|
|
33
33
|
signal: params.signal,
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
|
+
/** The start of a response's body, for error messages. */
|
|
37
|
+
async function bodyStart(response) {
|
|
38
|
+
return (await response.text().catch(() => '')).slice(0, 200);
|
|
39
|
+
}
|
|
36
40
|
/** The error for a response the protocol has no meaning for, with the start of its body. */
|
|
37
|
-
|
|
38
|
-
const detail = (await response.text().catch(() => '')).slice(0, 200);
|
|
41
|
+
function unexpected(response, method, route, detail) {
|
|
39
42
|
return new Error(`GitHub responded ${response.status} to ${method} ${route}${detail === '' ? '' : `: ${detail}`}`);
|
|
40
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Whether GitHub throttled the request rather than refused it: a 429, or a
|
|
46
|
+
* 403 for a spent primary limit, a `Retry-After`, or a secondary limit.
|
|
47
|
+
*/
|
|
48
|
+
function isRateLimited(response, detail) {
|
|
49
|
+
if (response.status === 429)
|
|
50
|
+
return true;
|
|
51
|
+
return (response.status === 403 &&
|
|
52
|
+
(response.headers.get('x-ratelimit-remaining') === '0' ||
|
|
53
|
+
response.headers.has('retry-after') ||
|
|
54
|
+
/secondary rate limit/i.test(detail)));
|
|
55
|
+
}
|
|
41
56
|
/** The error the runner prints for a response that is not a success. */
|
|
42
57
|
async function failure(params, response, method, route) {
|
|
43
58
|
if (response.status === 401)
|
|
44
59
|
return new Error('GitHub rejected the token (GITHUB_TOKEN or GH_TOKEN)');
|
|
60
|
+
const detail = await bodyStart(response);
|
|
61
|
+
if (isRateLimited(response, detail)) {
|
|
62
|
+
return new Error(`GitHub rate limited ${method} ${route}; wait for the rate-limit reset or Retry-After before rerunning the job`);
|
|
63
|
+
}
|
|
45
64
|
if (response.status === 403 || response.status === 404) {
|
|
46
65
|
return new Error(`the token cannot comment on ${params.repository}#${params.pullRequest}: a pull request from a fork runs with a read-only token, and the job needs \`permissions: pull-requests: write\``);
|
|
47
66
|
}
|
|
48
|
-
return unexpected(response, method, route);
|
|
67
|
+
return unexpected(response, method, route, detail);
|
|
49
68
|
}
|
|
50
69
|
/** One GitHub REST call; anything but success is an error the runner can print. */
|
|
51
70
|
async function request(params, method, route, body) {
|
|
@@ -75,7 +94,7 @@ async function tokenAuthor(params) {
|
|
|
75
94
|
}
|
|
76
95
|
if (response.status === 401)
|
|
77
96
|
throw await failure(params, response, 'GET', '/user');
|
|
78
|
-
throw
|
|
97
|
+
throw unexpected(response, 'GET', '/user', await bodyStart(response));
|
|
79
98
|
}
|
|
80
99
|
/**
|
|
81
100
|
* Whether a comment body is the reporter's own for this marker: its first
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e2e-dev/github",
|
|
3
|
-
"version": "0.4.2
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "GitHub reporter for e2e: one pull request comment per run, from GitHub Actions",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"e2e",
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
"NOTICE"
|
|
44
44
|
],
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"e2e": "0.
|
|
46
|
+
"e2e": ">=0.15.0 <1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"e2e": "0.21.2
|
|
49
|
+
"e2e": "0.21.2",
|
|
50
50
|
"@types/node": "26.6.2",
|
|
51
51
|
"typescript": "7.0.2",
|
|
52
52
|
"vitest": "5.0.1"
|