next-issue 6.6.43 → 6.6.45

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
@@ -134,17 +134,20 @@ the run handles one issue. For each issue:
134
134
  holds the commit during the push, so a run stopped meanwhile, or the
135
135
  next run after that hand-over, checks the base on resume and waits for
136
136
  the checks of the commit when it landed. The harness then waits for the
137
- checks of the pushed commit on the base branch: its GitHub Actions
138
- workflow runs, its commit statuses and the check runs of every other
139
- GitHub App, so checks from another CI service count too. It leaves out
140
- the check runs of the GitHub Actions app, since it judges GitHub Actions
141
- by its workflow runs. A failed or errored commit status, or a check run
142
- that ends with `failure`, `timed_out` or `action_required`, fails the
143
- checks. When any check ends `cancelled`, for example because a later
144
- push cancelled the workflow run, that check never finished, even when
145
- another check (such as a release workflow) ends `success`: the harness
146
- hands the issue to a person with the reason `main checks cancelled` and
147
- halts, and the issue stays open. A repository
137
+ checks of the pushed commit on the base branch: the GitHub Actions
138
+ workflow runs that a `push` event started on it, its commit statuses
139
+ and the check runs of every other GitHub App, so checks from another CI
140
+ service count too. It leaves out the check runs of the GitHub Actions
141
+ app, since it judges GitHub Actions by its workflow runs. It leaves out
142
+ workflow runs that any other event (such as `issues`, `issue_comment` or
143
+ `schedule`) started, since GitHub gives such a run the tip of the
144
+ default branch as its commit. A failed or errored commit status, or a
145
+ check run that ends with `failure`, `timed_out` or `action_required`,
146
+ fails the checks. When any check ends `cancelled`, for example because
147
+ a later push cancelled the workflow run, that check never finished,
148
+ even when another check (such as a release workflow) ends `success`:
149
+ the harness hands the issue to a person with the reason
150
+ `main checks cancelled` and halts, and the issue stays open. A repository
148
151
  that reports no check keeps asking for `checkGraceSeconds`. A pending state
149
152
  waits again, up to `checkTimeoutMinutes`. A read that fails is tried three
150
153
  times. When the checks pass, the harness closes the issue and sets
@@ -14,8 +14,8 @@ function jsonLines(raw) {
14
14
  .map((line) => JSON.parse(line));
15
15
  }
16
16
  async function baseRuns(repo, sha) {
17
- const runs = await ghApi(repo, `actions/runs?head_sha=${sha}&per_page=100`, '.workflow_runs[] | {databaseId: .id, name, status, conclusion: (.conclusion // ""), attempt: .run_attempt} | @json', { paginate: true });
18
- return jsonLines(runs);
17
+ const runs = await ghApi(repo, `actions/runs?head_sha=${sha}&per_page=100`, '.workflow_runs[] | {databaseId: .id, name, status, conclusion: (.conclusion // ""), attempt: .run_attempt, event} | @json', { paginate: true });
18
+ return jsonLines(runs).filter((entry) => entry.event === 'push');
19
19
  }
20
20
  async function externalChecks(repo, sha) {
21
21
  const [runs, statuses] = await Promise.all([
package/dist/verdict.mjs CHANGED
@@ -31,18 +31,45 @@ export function readVerdict(value) {
31
31
  }
32
32
  return { summary, findings: checked };
33
33
  }
34
- const JSON_BLOCK = /```json[^\n]*\n([\s\S]*?)```/g;
34
+ const JSON_FENCE = /```json[^\n]*\n/g;
35
+ const FENCE = '```';
36
+ function parseJson(text) {
37
+ try {
38
+ return { value: JSON.parse(text) };
39
+ }
40
+ catch {
41
+ return undefined;
42
+ }
43
+ }
35
44
  export function parseVerdict(text) {
36
- const last = [...text.matchAll(JSON_BLOCK)].at(-1);
45
+ const fences = [...text.matchAll(JSON_FENCE)];
46
+ const last = fences.at(-1);
37
47
  if (last === undefined) {
38
48
  return undefined;
39
49
  }
40
- try {
41
- return readVerdict(JSON.parse(last[1]));
50
+ for (const fence of fences.toReversed()) {
51
+ const block = readBlock(text, fence.index + fence[0].length);
52
+ if (block === undefined) {
53
+ continue;
54
+ }
55
+ if (block.end < last.index) {
56
+ return undefined;
57
+ }
58
+ const verdict = readVerdict(block.value);
59
+ if (verdict !== undefined) {
60
+ return verdict;
61
+ }
42
62
  }
43
- catch {
44
- return undefined;
63
+ return undefined;
64
+ }
65
+ function readBlock(text, start) {
66
+ for (let end = text.indexOf(FENCE, start); end !== -1; end = text.indexOf(FENCE, end + 1)) {
67
+ const parsed = parseJson(text.slice(start, end));
68
+ if (parsed !== undefined) {
69
+ return { value: parsed.value, end };
70
+ }
45
71
  }
72
+ return undefined;
46
73
  }
47
74
  export function blockingFindings(verdict) {
48
75
  return verdict.findings.filter((finding) => finding.severity === 'blocking');
package/dist/watch.mjs CHANGED
@@ -50,6 +50,9 @@ async function huntIssues(hunter, running, failed, claims, stopped, signal) {
50
50
  let step = 0;
51
51
  while (!stopped()) {
52
52
  const ready = await hunter.ready(running, failed).catch(() => undefined);
53
+ if (stopped()) {
54
+ return;
55
+ }
53
56
  claims.take();
54
57
  const waiting = ready?.filter((issue) => !running.has(issue.number)).length;
55
58
  if (waiting !== undefined && waiting < hunter.cap) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "6.6.43",
3
+ "version": "6.6.45",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",