next-issue 6.6.100 → 6.6.102
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 +14 -4
- package/dist/base-checks.mjs +24 -9
- package/dist/gate.mjs +17 -9
- package/dist/land.mjs +3 -3
- package/dist/pending.mjs +18 -2
- 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
|
|
@@ -313,8 +321,10 @@ on such a resume before the base is checked) is saved in the state file of
|
|
|
313
321
|
its issue. The issue waits for a person, so later runs skip it, but no
|
|
314
322
|
later run lands another change meanwhile: an issue that reaches the
|
|
315
323
|
landing ends `stopped` with the reason `base unchecked`, keeps its state,
|
|
316
|
-
branch and labels, and
|
|
317
|
-
`land.blocked` event with the waiting issues.
|
|
324
|
+
branch and labels, and the run claims no more issues; the log holds a
|
|
325
|
+
`land.blocked` event with the waiting issues. Runs take such a halted issue
|
|
326
|
+
before the others, and a running one still resumes, so an older issue that
|
|
327
|
+
reaches the landing first does not keep it from checking the base. Once a person answers or
|
|
318
328
|
takes the label off, the issue resumes, checks the base and waits for the
|
|
319
329
|
checks of its commit; when those are known (the issue is done, or its
|
|
320
330
|
commits are reverted or found not on the base), the next run lands the
|
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
|
});
|
package/dist/land.mjs
CHANGED
|
@@ -49,14 +49,14 @@ function inLandingLock(job, work) {
|
|
|
49
49
|
}
|
|
50
50
|
/** Runs a step that lands a change, unless an earlier run halted with a commit on the base whose checks nobody read. */
|
|
51
51
|
async function unblocked(job, work) {
|
|
52
|
-
const {
|
|
52
|
+
const { log } = job;
|
|
53
53
|
const unchecked = await uncheckedIssues(job);
|
|
54
54
|
if (unchecked.length === 0) {
|
|
55
55
|
return work();
|
|
56
56
|
}
|
|
57
|
-
// Landing now would build on a commit whose checks nobody read.
|
|
57
|
+
// Landing now would build on a commit whose checks nobody read. The run claims no more issues, but it does not
|
|
58
|
+
// set `context.halted`: a blocking issue already running must still resume and check its commit on the base.
|
|
58
59
|
log.event('land.blocked', { issues: unchecked }, 'quiet');
|
|
59
|
-
context.halted = true;
|
|
60
60
|
const held = await holdBack(job, 'base unchecked');
|
|
61
61
|
return { ...held, report: { ...held.report, halt: true } };
|
|
62
62
|
}
|
package/dist/pending.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { message } from './errors.mjs';
|
|
2
2
|
import { readState, savedIssues } from './state.mjs';
|
|
3
|
+
import { blocksLanding } from './unsettled.mjs';
|
|
3
4
|
export async function pendingIssues(context) {
|
|
4
5
|
const { repo, config, ports } = context;
|
|
5
6
|
const { ready, inProgress, inReview } = config.labels;
|
|
@@ -7,7 +8,8 @@ export async function pendingIssues(context) {
|
|
|
7
8
|
const issues = await ports.openIssues(repo, config.issueLimit, labels);
|
|
8
9
|
const listed = new Set(issues.map((issue) => issue.number));
|
|
9
10
|
let openCount = issues.length;
|
|
10
|
-
|
|
11
|
+
const saved = await savedIssues(repo);
|
|
12
|
+
for (const number of saved) {
|
|
11
13
|
if (listed.has(number)) {
|
|
12
14
|
continue;
|
|
13
15
|
}
|
|
@@ -20,7 +22,21 @@ export async function pendingIssues(context) {
|
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
context.recorder.event('issues', { open: openCount }, 'quiet');
|
|
23
|
-
|
|
25
|
+
const blocking = await blockingIssues(context, saved);
|
|
26
|
+
// An issue that blocks every landing goes first, so its resume can lift the block before an older issue reaches the landing.
|
|
27
|
+
return issues.sort((a, b) => Number(blocking.has(b.number)) - Number(blocking.has(a.number)) ||
|
|
28
|
+
a.createdAt.localeCompare(b.createdAt));
|
|
29
|
+
}
|
|
30
|
+
async function blockingIssues(context, saved) {
|
|
31
|
+
const { repo, base } = context;
|
|
32
|
+
const blocking = new Set();
|
|
33
|
+
for (const number of saved) {
|
|
34
|
+
const state = await readState(repo, number).catch(() => undefined);
|
|
35
|
+
if (state !== undefined && blocksLanding(state, base)) {
|
|
36
|
+
blocking.add(number);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return blocking;
|
|
24
40
|
}
|
|
25
41
|
async function savedIssue(context, number) {
|
|
26
42
|
const { repo, ports } = context;
|