next-issue 7.8.12 → 7.8.14
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 +22 -13
- package/dist/base-checks.mjs +6 -2
- package/dist/local-checks.mjs +8 -0
- package/dist/worktree-setup.mjs +20 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -159,14 +159,19 @@ the run handles one issue. For each issue:
|
|
|
159
159
|
conflict marker or the merge unresolved, aborts the merge, or fails, the
|
|
160
160
|
harness undoes the merge and hands the issue to a person with the reason
|
|
161
161
|
`merge conflict`. When `checks` lists commands, the harness then runs
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
162
|
+
the setup command again in the worktree, so the checks use the
|
|
163
|
+
dependencies of the merged base. A setup that fails or does not finish
|
|
164
|
+
in `setupTimeoutMinutes` stops the landing before the push and hands the
|
|
165
|
+
issue to a person with the reason `setup failed` or `setup timeout`. The
|
|
166
|
+
harness then runs each command in `checks` in the worktree, in order,
|
|
167
|
+
with `bash -c` and stderr merged into stdout, each for at most
|
|
168
|
+
`checksTimeoutMinutes`. Their output goes to the run log
|
|
169
|
+
(`check.output`, and `check.fail` for a failure). After each command,
|
|
170
|
+
the harness resets the worktree to the commit it checked and removes
|
|
171
|
+
untracked files that git does not ignore, so a file that a command
|
|
172
|
+
writes never lands on the base. A command that fails or does not
|
|
173
|
+
finish stops the landing before the push: the fixer gets the command
|
|
174
|
+
and the tail of its output (at most
|
|
170
175
|
`logMaxChars`) from the check budget, `maxCiFixes`, and its fix is
|
|
171
176
|
squashed into the change, which keeps its subject. The harness then
|
|
172
177
|
merges the base again and runs every command again, so nothing lands
|
|
@@ -251,8 +256,11 @@ the run handles one issue. For each issue:
|
|
|
251
256
|
was rerun, a run that waits for approval, a check from another CI
|
|
252
257
|
service) waits until every check has finished, so a workflow run that
|
|
253
258
|
fails later, even after the first rerun started, still gets its own
|
|
254
|
-
rerun before any fixer. A
|
|
255
|
-
|
|
259
|
+
rerun before any fixer. A workflow run whose kept job failed while a
|
|
260
|
+
job in `ignoredChecks` still runs gets its rerun only once the whole
|
|
261
|
+
run has finished on GitHub, as GitHub refuses to rerun a running run.
|
|
262
|
+
A rerun that GitHub refuses because the run is already running counts
|
|
263
|
+
as started. When at least one run restarted
|
|
256
264
|
and a later rerun or read fails, the event carries the error and the
|
|
257
265
|
harness still waits for the checks again, counting each restarted run as
|
|
258
266
|
running until a later attempt of it completes, so the fixer never runs
|
|
@@ -665,7 +673,7 @@ because no pull request is opened.
|
|
|
665
673
|
| `checks` | `[]` | Shell commands that must pass in the worktree, in order, before an approved change is pushed; a failure goes to the fixer |
|
|
666
674
|
| `checksTimeoutMinutes` | `30` | The limit for one command in `checks`, at most `35791` |
|
|
667
675
|
| `ignoredChecks` | `[]` | Names of GitHub Actions jobs, check runs and commit statuses, such as `release`, that the checks on the base branch do not wait for and whose failure does not count |
|
|
668
|
-
| `setupCommand` | from the lock file | A shell command to run in a new worktree, before the implementer
|
|
676
|
+
| `setupCommand` | from the lock file | A shell command to run in a new worktree, before the implementer, and after each merge of the base before the `checks` |
|
|
669
677
|
| `models` | `null` per role | The pi model per agent role, as `provider/model`: `implementer`, `reviewer`, `fixer` |
|
|
670
678
|
| `labels` | see above | The names of the labels that the harness reads and sets |
|
|
671
679
|
|
|
@@ -688,8 +696,9 @@ The log gives the reason for a skipped issue as `stop-label`, `not-ready`,
|
|
|
688
696
|
A role set to `null`, or with no entry in `models`, uses the default model of
|
|
689
697
|
your pi settings.
|
|
690
698
|
|
|
691
|
-
Without a `setupCommand`, the harness looks
|
|
692
|
-
and
|
|
699
|
+
Without a `setupCommand`, the harness looks for a lock file in the new
|
|
700
|
+
worktree, and in the worktree after each merge of the base before the
|
|
701
|
+
`checks`, and runs the install command that goes with it:
|
|
693
702
|
|
|
694
703
|
| Lock file | Command |
|
|
695
704
|
| ----------------------- | ------------------------------------------------------------------------------------ |
|
package/dist/base-checks.mjs
CHANGED
|
@@ -25,7 +25,7 @@ async function baseRuns(repo, sha, branch, ignored) {
|
|
|
25
25
|
const judged = await Promise.all(pushed.map((entry) => withoutIgnored(repo, entry, ignored)));
|
|
26
26
|
return judged.filter((entry) => entry !== undefined);
|
|
27
27
|
}
|
|
28
|
-
/** Judges a workflow run by its jobs outside the ignored checks; a run with no job yet, or a running one whose listed jobs all finished, keeps its own state, as a job not listed yet may follow. */
|
|
28
|
+
/** Judges a workflow run by its jobs outside the ignored checks; a run with no job yet, or a running one whose listed jobs all finished, keeps its own state, as a job not listed yet may follow. A running one whose kept jobs failed waits until it finishes, as GitHub refuses to rerun a running run. */
|
|
29
29
|
async function withoutIgnored(repo, run, ignored) {
|
|
30
30
|
const jobs = jsonLines(await ghApi(repo, `actions/runs/${run.databaseId}/jobs?filter=latest&per_page=100`, '.jobs[] | {databaseId: .id, name, status, conclusion: (.conclusion // "")} | @json', { paginate: true }));
|
|
31
31
|
if (jobs.length === 0 || (run.status !== 'completed' && jobs.every(completedJob))) {
|
|
@@ -38,7 +38,11 @@ async function withoutIgnored(repo, run, ignored) {
|
|
|
38
38
|
if (!kept.every(completedJob)) {
|
|
39
39
|
return { ...run, status: 'in_progress', conclusion: '', jobs: kept };
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
const judged = { ...run, status: 'completed', conclusion: jobsConclusion(kept), jobs: kept };
|
|
42
|
+
if (run.status !== 'completed' && rerunnable(judged)) {
|
|
43
|
+
return { ...run, status: 'in_progress', conclusion: '', jobs: kept };
|
|
44
|
+
}
|
|
45
|
+
return judged;
|
|
42
46
|
}
|
|
43
47
|
function completedJob(job) {
|
|
44
48
|
return job.status === 'completed';
|
package/dist/local-checks.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import { escalateCheckFix, fixRound } from './fix.mjs';
|
|
|
6
6
|
import { escalateAndFinish } from './handover.mjs';
|
|
7
7
|
import { writeState } from './state.mjs';
|
|
8
8
|
import { keepTail } from './text.mjs';
|
|
9
|
+
import { setUpBeforeChecks } from './worktree-setup.mjs';
|
|
9
10
|
const COMMENT_OUTPUT_CHARS = 3000;
|
|
10
11
|
/**
|
|
11
12
|
* Runs the configured check commands in the worktree before a push.
|
|
@@ -15,6 +16,13 @@ const COMMENT_OUTPUT_CHARS = 3000;
|
|
|
15
16
|
export async function localChecks(job) {
|
|
16
17
|
const { context, log, worktree } = job;
|
|
17
18
|
const { config, ports } = context;
|
|
19
|
+
if (config.checks.length === 0) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
const setup = await setUpBeforeChecks(job);
|
|
23
|
+
if (setup !== undefined) {
|
|
24
|
+
return setup;
|
|
25
|
+
}
|
|
18
26
|
const head = await ports.revision(worktree);
|
|
19
27
|
for (const command of config.checks) {
|
|
20
28
|
const result = await log.step('check', { cmd: command }, () => ports.runCheck(command, worktree, minutesToMs(config.checksTimeoutMinutes), config.logMaxChars));
|
package/dist/worktree-setup.mjs
CHANGED
|
@@ -6,30 +6,41 @@ import { ROUND_CONTINUE } from './job.mjs';
|
|
|
6
6
|
import { keepTail } from './text.mjs';
|
|
7
7
|
import { heldOnBase, unsettledNote } from './unsettled.mjs';
|
|
8
8
|
export async function setUp(job) {
|
|
9
|
+
const setup = await runSetup(job);
|
|
10
|
+
if (setup === undefined || succeeded(setup)) {
|
|
11
|
+
return ROUND_CONTINUE;
|
|
12
|
+
}
|
|
13
|
+
return setupFailed(job, setup, unsettledBase(job));
|
|
14
|
+
}
|
|
15
|
+
/** Installs the dependencies of the merged base before the local checks; gives the hand-over when the setup fails. */
|
|
16
|
+
export async function setUpBeforeChecks(job) {
|
|
17
|
+
const setup = await runSetup(job);
|
|
18
|
+
if (setup === undefined || succeeded(setup)) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
return setupFailed(job, setup, '', ' before the local checks');
|
|
22
|
+
}
|
|
23
|
+
async function runSetup(job) {
|
|
9
24
|
const { context, log, worktree } = job;
|
|
10
25
|
const { config, ports } = context;
|
|
11
26
|
const setupCommand = config.setupCommand ?? (await ports.detectSetupCommand(worktree));
|
|
12
27
|
if (setupCommand === undefined) {
|
|
13
|
-
return
|
|
28
|
+
return undefined;
|
|
14
29
|
}
|
|
15
30
|
const setup = await log.step('setup', { cmd: setupCommand, found: config.setupCommand === undefined }, () => ports.runSetup(setupCommand, worktree, minutesToMs(config.setupTimeoutMinutes)));
|
|
16
31
|
refuseWhenStopped();
|
|
17
|
-
|
|
18
|
-
return ROUND_CONTINUE;
|
|
19
|
-
}
|
|
20
|
-
return setupFailed(job, setup);
|
|
32
|
+
return setup;
|
|
21
33
|
}
|
|
22
|
-
async function setupFailed(job, setup) {
|
|
34
|
+
async function setupFailed(job, setup, unsettled, when = '') {
|
|
23
35
|
const late = setup.timedOut === true;
|
|
24
36
|
job.log.event('setup.fail', { code: setup.code, timedOut: late, stderr: keepTail(setup.stderr.trim(), 2000) }, 'quiet');
|
|
25
|
-
const unsettled = unsettledBase(job);
|
|
26
37
|
if (unsettled !== '') {
|
|
27
38
|
job.mainBroken = true;
|
|
28
39
|
job.state.halted = true;
|
|
29
40
|
}
|
|
30
41
|
const note = late
|
|
31
|
-
? `The setup command did not finish in ${job.context.config.setupTimeoutMinutes} minutes.`
|
|
32
|
-
:
|
|
42
|
+
? `The setup command did not finish in ${job.context.config.setupTimeoutMinutes} minutes${when}.`
|
|
43
|
+
: `The setup command failed in the worktree${when}.`;
|
|
33
44
|
return escalateAndFinish(job, `${note}${unsettled}`, late ? 'setup timeout' : 'setup failed');
|
|
34
45
|
}
|
|
35
46
|
function unsettledBase(job) {
|