pi-dev-flow 0.95.1 → 0.95.2

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/CHANGELOG.md CHANGED
@@ -4,6 +4,13 @@ Format: newest first. `Unreleased` collects what's merged but not yet tagged.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.95.2] - 2026-11-20
8
+
9
+ **`flow release` stops waiting on a check that GitHub left stuck at "in progress" after its job finished.**
10
+
11
+ ### Fixed
12
+ - **`flow release` no longer waits on a check that GitHub left stuck at "in progress" (gh#275).** Sometimes a check run on the PR keeps saying `in_progress` after its Actions job has finished. In one case the gate spent three 30-minute waits on `actionlint` this way. Now, when a check has been pending for 5 minutes, the gate asks GitHub for the job's own result (`gh api …/actions/jobs/<id>`). If the job has finished, the gate uses that result, so a pass counts as green and a failure counts as red, and the release note names the stale check. A wait that still runs out of time now also says how to clear a stale check: push a new commit to the branch.
13
+
7
14
  ## [0.95.1] - 2026-11-20
8
15
 
9
16
  **`flow release` waits for the merge commit's CI to go green before it cuts the tag; `tagWait = none` opts out.**
package/docs/gates.md CHANGED
@@ -163,7 +163,7 @@ On GitHub, the same `flow release` call then publishes. Your Release? answer is
163
163
  (`.github/pull_request_template.md`), the gate refuses until `pr-body.md` exists, before
164
164
  Release? is asked, so the template's sections are filled before the merge.
165
165
  2. Checks the branch merges cleanly into the default branch. On a conflict it names the files and pushes nothing.
166
- 3. Waits for the PR's CI, up to 30 minutes. A repo with no CI is given a minute for checks to show up.
166
+ 3. Waits for the PR's CI, up to 30 minutes. A repo with no CI is given a minute for checks to show up. A check pending for 5 minutes has its Actions job asked directly: GitHub can leave a check run `in_progress` after its job finished, and the job's result is used then.
167
167
  4. Merges in the playbook's `merge` style.
168
168
  5. Waits for the merge commit's own CI to go green, because the tag publishes from that commit. If it's red, the
169
169
  gate stops without tagging. If no CI runs on that commit, it tags after a minute. `tagWait = none` under
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-dev-flow",
3
- "version": "0.95.1",
3
+ "version": "0.95.2",
4
4
  "description": "Enforced feature workflow for Pi: plan → implement → pre-release → release, gated checkpoints, self-improvement reflections, one git worktree per feature, changelog + publish as part of the release",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -19,8 +19,25 @@ export const publishWait = {
19
19
  checks: (pr: number, cwd: string): Promise<PrCheck[] | null> => prChecks(pr, cwd),
20
20
  /** the CI runs a commit started — the merge commit, before it is tagged (gh#271) */
21
21
  commitChecks: (sha: string, cwd: string): Promise<PrCheck[] | null> => commitRuns(sha, cwd),
22
+ /** gh#275: a check pending this long has its Actions job asked directly — GitHub can leave a check run
23
+ * `in_progress` for good after its job concluded */
24
+ staleMs: 5 * 60_000,
25
+ /** the bucket of the Actions job or run behind a check's link once it has concluded; null while it runs or when
26
+ * the link is not an Actions one */
27
+ probe: (link: string, cwd: string): Promise<string | null> => actionsConclusion(link, cwd),
22
28
  };
23
29
 
30
+ /** gh#275: the Actions job (or run) a check links to — its own conclusion, which GitHub sets even when the check
31
+ * run shown on the PR is stuck at in_progress. */
32
+ async function actionsConclusion(link: string, cwd: string): Promise<string | null> {
33
+ const m = /github\.com\/([^/]+)\/([^/]+)\/actions\/runs\/(\d+)(?:\/job\/(\d+))?/.exec(link);
34
+ if (!m) return null;
35
+ const api = m[4] ? `repos/${m[1]}/${m[2]}/actions/jobs/${m[4]}` : `repos/${m[1]}/${m[2]}/actions/runs/${m[3]}`;
36
+ const r = await sh(`gh api ${sq(api)} --jq '.conclusion // ""'`, cwd, 60_000);
37
+ const k = r.ok ? r.out.trim() : "";
38
+ return /^[a-z_]+$/.test(k) ? checkBucket({ status: "COMPLETED", conclusion: k.toUpperCase() }) : null;
39
+ }
40
+
24
41
  /** Workflow runs of one commit as checks; [] when none started, null when gh cannot say. */
25
42
  async function commitRuns(sha: string, cwd: string): Promise<PrCheck[] | null> {
26
43
  const r = await sh(`gh run list --commit ${sha} --limit 50 --json status,conclusion,name,url`, cwd, 60_000);
@@ -82,27 +99,57 @@ export type CiVerdict = { state: "green" | "none"; note: string } | { state: "re
82
99
 
83
100
  /** Wait (bounded) for the PR's checks to settle. */
84
101
  export const awaitPrChecks = (pr: number, cwd: string): Promise<CiVerdict> =>
85
- awaitChecks(() => publishWait.checks(pr, cwd), { who: `PR #${pr}`, read: `gh pr view ${pr} --json statusCheckRollup`, none: "no CI checks on the PR", green: "CI green" });
102
+ awaitChecks(() => publishWait.checks(pr, cwd), cwd, {
103
+ who: `PR #${pr}`,
104
+ read: `gh pr view ${pr} --json statusCheckRollup`,
105
+ none: "no CI checks on the PR",
106
+ green: "CI green",
107
+ stuck: "a check whose job already finished on GitHub but still shows in_progress is a stale check run: pushing a new commit to the branch clears it",
108
+ });
86
109
 
87
110
  /** gh#271: wait (bounded) for the CI the merge commit started — a tag publishes from it, so it is cut on green only. */
88
111
  export const awaitCommitChecks = (sha: string, cwd: string): Promise<CiVerdict> =>
89
- awaitChecks(() => publishWait.commitChecks(sha, cwd), { who: `merge commit ${sha.slice(0, 9)}`, read: `gh run list --commit ${sha}`, none: "no CI ran on the merge commit", green: "merge-commit CI green" });
112
+ awaitChecks(() => publishWait.commitChecks(sha, cwd), cwd, { who: `merge commit ${sha.slice(0, 9)}`, read: `gh run list --commit ${sha}`, none: "no CI ran on the merge commit", green: "merge-commit CI green" });
90
113
 
91
- async function awaitChecks(read: () => Promise<PrCheck[] | null>, l: { who: string; read: string; none: string; green: string }): Promise<CiVerdict> {
114
+ async function awaitChecks(read: () => Promise<PrCheck[] | null>, cwd: string, l: { who: string; read: string; none: string; green: string; stuck?: string }): Promise<CiVerdict> {
92
115
  const start = publishWait.clock();
93
116
  const mins = () => `${Math.max(1, Math.round((publishWait.clock() - start) / 60_000))} min`;
117
+ // gh#275: when each check was first seen pending, and what its job concluded once asked — a check run GitHub left
118
+ // at in_progress after its job finished burned three 30-min waits; it is taken at its job's word instead
119
+ const since = new Map<string, number>();
120
+ const settled = new Map<string, string>();
121
+ const stale: string[] = [];
94
122
  for (;;) {
95
- const rows = await read();
123
+ const raw = await read();
96
124
  const elapsed = publishWait.clock() - start;
125
+ const rows = raw?.map((c) => {
126
+ if (c.bucket !== "pending") return c;
127
+ const key = `${c.name}\u0000${c.link}`;
128
+ const b = settled.get(key);
129
+ return b ? { ...c, bucket: b } : c;
130
+ }) ?? null;
131
+ for (const c of rows ?? []) {
132
+ if (c.bucket !== "pending" || !c.link) continue;
133
+ const key = `${c.name}\u0000${c.link}`;
134
+ const first = since.get(key) ?? elapsed;
135
+ since.set(key, first);
136
+ if (elapsed - first < publishWait.staleMs) continue;
137
+ const b = await publishWait.probe(c.link, cwd);
138
+ if (!b || b === "pending") continue;
139
+ settled.set(key, b);
140
+ stale.push(`${c.name}: its job concluded ${b} while the check still said in_progress`);
141
+ c.bucket = b;
142
+ }
143
+ const staleNote = stale.length ? `; ${stale.join(", ")}` : "";
97
144
  if (rows === null) return { state: "unknown", why: `cannot read the checks of ${l.who} (${l.read})` };
98
145
  if (!rows.length) {
99
146
  if (elapsed >= publishWait.appearMs) return { state: "none", note: l.none };
100
147
  } else {
101
148
  const failed = rows.filter((c) => c.bucket === "fail" || c.bucket === "cancel");
102
- if (failed.length) return { state: "red", why: `${l.who} checks failed — ${failed.map((c) => `${c.name}: ${c.bucket}${c.link ? ` (${c.link})` : ""}`).join(", ")}` };
149
+ if (failed.length) return { state: "red", why: `${l.who} checks failed — ${failed.map((c) => `${c.name}: ${c.bucket}${c.link ? ` (${c.link})` : ""}`).join(", ")}${staleNote}` };
103
150
  const pending = rows.filter((c) => c.bucket !== "pass" && c.bucket !== "skipping");
104
- if (!pending.length) return { state: "green", note: `${l.green} (${rows.length} check${rows.length === 1 ? "" : "s"}${elapsed >= 60_000 ? `, waited ${mins()}` : ""})` };
105
- if (elapsed >= publishWait.budgetMs) return { state: "running", why: `${l.who} checks still running after ${mins()} (${pending.map((c) => c.name).join(", ")})` };
151
+ if (!pending.length) return { state: "green", note: `${l.green} (${rows.length} check${rows.length === 1 ? "" : "s"}${elapsed >= 60_000 ? `, waited ${mins()}` : ""}${staleNote})` };
152
+ if (elapsed >= publishWait.budgetMs) return { state: "running", why: `${l.who} checks still running after ${mins()} (${pending.map((c) => c.name).join(", ")})${l.stuck ? ` — ${l.stuck}` : ""}` };
106
153
  }
107
154
  await publishWait.sleep(publishWait.pollMs);
108
155
  }