next-issue 6.6.100 → 6.6.101
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/README.md +10 -2
- package/dist/base-checks.mjs +24 -9
- package/dist/gate.mjs +17 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -204,7 +204,13 @@ the run handles one issue. For each issue:
|
|
|
204
204
|
reruns the failed GitHub Actions jobs once with
|
|
205
205
|
`gh run rerun <id> --failed`, records a
|
|
206
206
|
`main-checks.rerun` event, saves the rerun in the state file and waits
|
|
207
|
-
again once the runs restart.
|
|
207
|
+
again once the runs restart. A rerun that GitHub refuses because the run
|
|
208
|
+
is already running counts as started. When at least one run restarted
|
|
209
|
+
and a later rerun or read fails, the event carries the error and the
|
|
210
|
+
harness still waits for the checks again, counting each restarted run as
|
|
211
|
+
running until a later attempt of it completes, so the fixer never runs
|
|
212
|
+
while a rerun is queued or in progress. When the rerun cannot start (no
|
|
213
|
+
run restarted, a `main-checks.rerun-failed` event), or the checks
|
|
208
214
|
fail again, the fixer gets their logs from the check budget (for a check
|
|
209
215
|
from another CI service, only its name and link), and its fix
|
|
210
216
|
lands the same way. When the fixer cannot fix them, its fix cannot land,
|
|
@@ -292,7 +298,9 @@ and comments the reason on the issue, when:
|
|
|
292
298
|
awaited;
|
|
293
299
|
- a step of the run fails with an error. A `gh` call that is safe to repeat,
|
|
294
300
|
such as a read or a label edit, is tried up to three times first when the
|
|
295
|
-
network fails.
|
|
301
|
+
network fails. So is a `gh run rerun`: when GitHub took the first try, it
|
|
302
|
+
refuses the next as already running, which counts as a started rerun. A
|
|
303
|
+
`gh issue comment` is
|
|
296
304
|
tried once, so a lost reply never makes a duplicate. On a resume whose
|
|
297
305
|
state holds a landed commit, or a push or revert that may have reached the
|
|
298
306
|
base, an error before the harness checks the base (for example a failed
|
package/dist/base-checks.mjs
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { setTimeout as delay } from 'node:timers/promises';
|
|
2
2
|
import { pollChecks } from './check-poll.mjs';
|
|
3
3
|
import { secondsToMs } from './durations.mjs';
|
|
4
|
+
import { errorMatches } from './errors.mjs';
|
|
4
5
|
import { gh, ghApi } from './gh.mjs';
|
|
5
6
|
import { runLogs } from './run-logs.mjs';
|
|
6
7
|
const RESTART_TRIES = 10;
|
|
8
|
+
const ALREADY_RUNNING = /already running/i;
|
|
7
9
|
const ACTIONS_APP = 'github-actions';
|
|
8
10
|
const FAILED_STATES = new Set(['failure', 'error']);
|
|
9
11
|
const AWAITS_APPROVAL = 'action_required';
|
|
@@ -39,12 +41,14 @@ async function externalChecks(repo, sha) {
|
|
|
39
41
|
}));
|
|
40
42
|
return [...checkRuns, ...commitStatuses];
|
|
41
43
|
}
|
|
42
|
-
async function baseChecks(repo, sha, branch) {
|
|
44
|
+
async function baseChecks(repo, sha, branch, restarted) {
|
|
43
45
|
const [runs, external] = await Promise.all([
|
|
44
46
|
baseRuns(repo, sha, branch),
|
|
45
47
|
externalChecks(repo, sha),
|
|
46
48
|
]);
|
|
47
|
-
|
|
49
|
+
// A rerun run counts as running until a later attempt of it completes, so its old failure never ends the wait.
|
|
50
|
+
const rerunning = restarted.some((entry) => !runs.some((run) => run.databaseId === entry.id && run.attempt > entry.attempt && run.status === 'completed'));
|
|
51
|
+
return { checks: [...runs.map((entry) => ({ ...entry, url: '' })), ...external], rerunning };
|
|
48
52
|
}
|
|
49
53
|
function failedRun(entry) {
|
|
50
54
|
return entry.status === 'completed' && FAILED_CONCLUSIONS.has(entry.conclusion);
|
|
@@ -58,27 +62,38 @@ function baseState(runs) {
|
|
|
58
62
|
}
|
|
59
63
|
return runs.some((entry) => entry.conclusion === 'cancelled') ? 'cancelled' : 'pass';
|
|
60
64
|
}
|
|
61
|
-
export function waitForBaseChecks(repo, sha, branch, options) {
|
|
62
|
-
let
|
|
65
|
+
export function waitForBaseChecks(repo, sha, branch, options, restarted = []) {
|
|
66
|
+
let read = { checks: [], rerunning: false };
|
|
63
67
|
return pollChecks({
|
|
64
68
|
head: async () => sha,
|
|
65
69
|
lags: async () => true,
|
|
66
70
|
list: async () => {
|
|
67
|
-
|
|
68
|
-
return checks.length === 0 ? 'none' : 'some';
|
|
71
|
+
read = await baseChecks(repo, sha, branch, restarted);
|
|
72
|
+
return read.checks.length === 0 && !read.rerunning ? 'none' : 'some';
|
|
69
73
|
},
|
|
70
|
-
watch: async () => baseState(checks),
|
|
74
|
+
watch: async () => (read.rerunning ? 'pending' : baseState(read.checks)),
|
|
71
75
|
}, options);
|
|
72
76
|
}
|
|
73
77
|
export async function rerunFailedBase(repo, sha, branch, started = () => { }) {
|
|
74
78
|
const failed = (await baseRuns(repo, sha, branch)).filter((entry) => failedRun(entry) && entry.conclusion !== AWAITS_APPROVAL);
|
|
75
79
|
for (const entry of failed) {
|
|
76
|
-
await
|
|
80
|
+
await rerun(repo, entry.databaseId);
|
|
81
|
+
started({ id: entry.databaseId, attempt: entry.attempt });
|
|
77
82
|
}
|
|
78
|
-
started();
|
|
79
83
|
await waitForRestart(repo, sha, branch, failed);
|
|
80
84
|
return failed.map((entry) => String(entry.databaseId));
|
|
81
85
|
}
|
|
86
|
+
async function rerun(repo, id) {
|
|
87
|
+
try {
|
|
88
|
+
await gh(repo, ['run', 'rerun', String(id), '--failed']);
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
// A rerun repeated after a lost reply finds the run running again, so that answer means the rerun started.
|
|
92
|
+
if (!errorMatches(error, ALREADY_RUNNING)) {
|
|
93
|
+
throw error;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
82
97
|
async function waitForRestart(repo, sha, branch, failed) {
|
|
83
98
|
for (let attempt = 1; attempt <= RESTART_TRIES; attempt += 1) {
|
|
84
99
|
const runs = await baseRuns(repo, sha, branch);
|
package/dist/gate.mjs
CHANGED
|
@@ -36,10 +36,10 @@ export async function checkGate(job, sha) {
|
|
|
36
36
|
}
|
|
37
37
|
return failedChecksFix(job, sha);
|
|
38
38
|
}
|
|
39
|
-
async function waitForChecks(job, sha, fields = {}) {
|
|
39
|
+
async function waitForChecks(job, sha, fields = {}, restarted = []) {
|
|
40
40
|
const { context, log } = job;
|
|
41
41
|
const { repo, config, ports } = context;
|
|
42
|
-
const checks = await log.step('main-checks', { sha, ...fields }, () => ports.waitForBaseChecks(repo, sha, context.base, checkWaiting(config, true)));
|
|
42
|
+
const checks = await log.step('main-checks', { sha, ...fields }, () => ports.waitForBaseChecks(repo, sha, context.base, checkWaiting(config, true), restarted));
|
|
43
43
|
log.event('main-checks.state', { state: checks, ...fields });
|
|
44
44
|
return checks;
|
|
45
45
|
}
|
|
@@ -51,26 +51,34 @@ async function rerunOnce(job, sha, checks) {
|
|
|
51
51
|
const before = state.rerun;
|
|
52
52
|
state.rerun = sha;
|
|
53
53
|
await writeState(context.repo, state);
|
|
54
|
-
|
|
54
|
+
const restarted = [];
|
|
55
55
|
try {
|
|
56
|
-
const runs = await context.ports.rerunFailedBase(context.repo, sha, context.base, () => {
|
|
57
|
-
|
|
56
|
+
const runs = await context.ports.rerunFailedBase(context.repo, sha, context.base, (run) => {
|
|
57
|
+
restarted.push(run);
|
|
58
58
|
});
|
|
59
59
|
log.event('main-checks.rerun', { sha, runs });
|
|
60
60
|
}
|
|
61
61
|
catch (error) {
|
|
62
62
|
if (runStopped()) {
|
|
63
|
-
if (
|
|
63
|
+
if (restarted.length > 0) {
|
|
64
64
|
throw error;
|
|
65
65
|
}
|
|
66
66
|
state.rerun = before;
|
|
67
67
|
await writeState(context.repo, state);
|
|
68
68
|
throw error;
|
|
69
69
|
}
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
if (restarted.length === 0) {
|
|
71
|
+
log.event('main-checks.rerun-failed', { sha, error: asError(error).message });
|
|
72
|
+
return checks;
|
|
73
|
+
}
|
|
74
|
+
// Some runs restarted, so the fixer waits for them rather than getting a failure with no log.
|
|
75
|
+
log.event('main-checks.rerun', {
|
|
76
|
+
sha,
|
|
77
|
+
runs: restarted.map((run) => String(run.id)),
|
|
78
|
+
error: asError(error).message,
|
|
79
|
+
});
|
|
72
80
|
}
|
|
73
|
-
return waitForChecks(job, sha, { rerun: true }).catch((error) => {
|
|
81
|
+
return waitForChecks(job, sha, { rerun: true }, restarted).catch((error) => {
|
|
74
82
|
job.mainBroken = true;
|
|
75
83
|
throw error;
|
|
76
84
|
});
|