next-issue 7.8.12 → 7.8.13

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 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
- each one in the worktree, in order, with `bash -c` and stderr merged
163
- into stdout, each for at most `checksTimeoutMinutes`. Their output goes
164
- to the run log (`check.output`, and `check.fail` for a failure). After
165
- each command, the harness resets the worktree to the commit it checked
166
- and removes untracked files that git does not ignore, so a file that a
167
- command writes never lands on the base. A
168
- command that fails or does not finish stops the landing before the push:
169
- the fixer gets the command and the tail of its output (at most
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
@@ -665,7 +670,7 @@ because no pull request is opened.
665
670
  | `checks` | `[]` | Shell commands that must pass in the worktree, in order, before an approved change is pushed; a failure goes to the fixer |
666
671
  | `checksTimeoutMinutes` | `30` | The limit for one command in `checks`, at most `35791` |
667
672
  | `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 |
673
+ | `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
674
  | `models` | `null` per role | The pi model per agent role, as `provider/model`: `implementer`, `reviewer`, `fixer` |
670
675
  | `labels` | see above | The names of the labels that the harness reads and sets |
671
676
 
@@ -688,8 +693,9 @@ The log gives the reason for a skipped issue as `stop-label`, `not-ready`,
688
693
  A role set to `null`, or with no entry in `models`, uses the default model of
689
694
  your pi settings.
690
695
 
691
- Without a `setupCommand`, the harness looks in the new worktree for a lock file
692
- and runs the install command that goes with it:
696
+ Without a `setupCommand`, the harness looks for a lock file in the new
697
+ worktree, and in the worktree after each merge of the base before the
698
+ `checks`, and runs the install command that goes with it:
693
699
 
694
700
  | Lock file | Command |
695
701
  | ----------------------- | ------------------------------------------------------------------------------------ |
@@ -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));
@@ -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 ROUND_CONTINUE;
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
- if (succeeded(setup)) {
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
- : 'The setup command failed in the worktree.';
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "7.8.12",
3
+ "version": "7.8.13",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",