@graphql-inspector/action 6.2.5 → 6.2.6
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/cjs/checks.js +21 -2
- package/esm/checks.js +21 -2
- package/package.json +1 -1
package/cjs/checks.js
CHANGED
|
@@ -6,12 +6,31 @@ const core = tslib_1.__importStar(require("@actions/core"));
|
|
|
6
6
|
const github = tslib_1.__importStar(require("@actions/github"));
|
|
7
7
|
const types_js_1 = require("../helpers/types.js");
|
|
8
8
|
const utils_js_1 = require("./utils.js");
|
|
9
|
+
const NOT_FOUND_RETRY_DELAYS_MS = [1000, 2000, 4000];
|
|
10
|
+
function sleep(ms) {
|
|
11
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
12
|
+
}
|
|
13
|
+
async function updateWithNotFoundRetry(octokit, params) {
|
|
14
|
+
for (let attempt = 0;; attempt++) {
|
|
15
|
+
try {
|
|
16
|
+
return await octokit.rest.checks.update(params);
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
const delay = NOT_FOUND_RETRY_DELAYS_MS[attempt];
|
|
20
|
+
if (error?.status !== 404 || delay === undefined) {
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
core.warning(`Check run ${params.check_run_id} not found, retrying in ${delay}ms (attempt ${attempt + 1} of ${NOT_FOUND_RETRY_DELAYS_MS.length})`);
|
|
24
|
+
await sleep(delay);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
9
28
|
async function updateCheckRun(octokit, checkId, { conclusion, output }) {
|
|
10
29
|
core.info(`Updating check: ${checkId}`);
|
|
11
30
|
const { title, summary, annotations = [] } = output;
|
|
12
31
|
const batches = (0, utils_js_1.batch)(annotations, 50);
|
|
13
32
|
core.info(`annotations to be sent: ${annotations.length}`);
|
|
14
|
-
await octokit
|
|
33
|
+
await updateWithNotFoundRetry(octokit, {
|
|
15
34
|
check_run_id: checkId,
|
|
16
35
|
completed_at: new Date().toISOString(),
|
|
17
36
|
status: 'completed',
|
|
@@ -24,7 +43,7 @@ async function updateCheckRun(octokit, checkId, { conclusion, output }) {
|
|
|
24
43
|
});
|
|
25
44
|
try {
|
|
26
45
|
for (const chunk of batches) {
|
|
27
|
-
await octokit
|
|
46
|
+
await updateWithNotFoundRetry(octokit, {
|
|
28
47
|
check_run_id: checkId,
|
|
29
48
|
...github.context.repo,
|
|
30
49
|
output: {
|
package/esm/checks.js
CHANGED
|
@@ -2,12 +2,31 @@ import * as core from '@actions/core';
|
|
|
2
2
|
import * as github from '@actions/github';
|
|
3
3
|
import { CheckConclusion } from '../helpers/types.js';
|
|
4
4
|
import { batch } from './utils.js';
|
|
5
|
+
const NOT_FOUND_RETRY_DELAYS_MS = [1000, 2000, 4000];
|
|
6
|
+
function sleep(ms) {
|
|
7
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
8
|
+
}
|
|
9
|
+
async function updateWithNotFoundRetry(octokit, params) {
|
|
10
|
+
for (let attempt = 0;; attempt++) {
|
|
11
|
+
try {
|
|
12
|
+
return await octokit.rest.checks.update(params);
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
const delay = NOT_FOUND_RETRY_DELAYS_MS[attempt];
|
|
16
|
+
if (error?.status !== 404 || delay === undefined) {
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
core.warning(`Check run ${params.check_run_id} not found, retrying in ${delay}ms (attempt ${attempt + 1} of ${NOT_FOUND_RETRY_DELAYS_MS.length})`);
|
|
20
|
+
await sleep(delay);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
5
24
|
export async function updateCheckRun(octokit, checkId, { conclusion, output }) {
|
|
6
25
|
core.info(`Updating check: ${checkId}`);
|
|
7
26
|
const { title, summary, annotations = [] } = output;
|
|
8
27
|
const batches = batch(annotations, 50);
|
|
9
28
|
core.info(`annotations to be sent: ${annotations.length}`);
|
|
10
|
-
await octokit
|
|
29
|
+
await updateWithNotFoundRetry(octokit, {
|
|
11
30
|
check_run_id: checkId,
|
|
12
31
|
completed_at: new Date().toISOString(),
|
|
13
32
|
status: 'completed',
|
|
@@ -20,7 +39,7 @@ export async function updateCheckRun(octokit, checkId, { conclusion, output }) {
|
|
|
20
39
|
});
|
|
21
40
|
try {
|
|
22
41
|
for (const chunk of batches) {
|
|
23
|
-
await octokit
|
|
42
|
+
await updateWithNotFoundRetry(octokit, {
|
|
24
43
|
check_run_id: checkId,
|
|
25
44
|
...github.context.repo,
|
|
26
45
|
output: {
|