Pass over an item whose pull request awaits a person's merge, and hold a sentence about several named things to each
CI / tests (pull_request) Failing after 3m42s

This commit is contained in:
Lilleman
2026-11-19 21:54:43 +01:00
parent 06a1398196
commit 00975177ad
22 changed files with 312 additions and 27 deletions
+31 -5
View File
@@ -16,6 +16,11 @@ and prints that the release reviews and the cuts are the human's to call. It pri
newest version CHANGELOG.md heads `## X.Y.Z - YYYY-MM-DD`; an undated heading doesn't count.
Then how many entries the default branch's CHANGELOG.md holds under ## Unreleased, or else how
many commits followed the cut: the tag, or the commit that added that heading;
- under `merge = "human"` (`project-config --help`), each other worktree whose pull request has
merged, for the worker to run `chunk-pr clean` in, and each item passed over: one that an open
pull request, no draft, finished on its branch, where the checkout holds the plan. Such an item
waits until a person merges. Where every item left in the release waits and one awaits a merge,
it names those pull requests and says the working loop stops there;
- the next release and its first item that does not wait, the item loop-claude routes on, with its L
and E + I; with --item <ID>, the plan item of that ID instead, which loop-claude names in a window
named for an item. An item waits while it is marked question, or while an item still in todo.md
@@ -78,14 +83,15 @@ import typing
from git_cli.git_repo import commit_exists, default_branch, file_at, git, top
from failure import Failure
from forge.commands import Forge, forge_of
from chunk_preflight.gathered import Gathered, ItemFacts, NamedPath, Ran, Worktree
from forge.commands import Forge, forge_of, Run
from chunk_preflight.gathered import Gathered, ItemFacts, LeftWorktree, NamedPath, Ran, Worktree
from chunk_preflight.facts import JOINING_DETAILS, render
from project_config.main import located
from forge.pulls import merged_pull
from plan.named_paths import named_paths
from release_plan.next_chunk import NextChunk, NoItem, plan_name, planned
from release_plan.release_standing import project_plan
from chunk_preflight.choices import pulls_command, worktree_add, worktree_on
from chunk_preflight.choices import pulls_command, worktree_add, worktree_on, worktrees
BIN = pathlib.Path(__file__).resolve().parents[1]
# Each tool run in the item's worktree, {item} standing for the item's ID.
@@ -143,12 +149,13 @@ def preflight(root: pathlib.Path, timeout: float, make: bool, item_id: int | Non
if isinstance(config, Failure):
return config
outside = None if config.tracked("plan") else config.plan_label
held = project_plan(config, ref, str(root))
forge_run = forge_runner(root, timeout)
held = project_plan(config, ref, str(root), forge_run=forge_run)
plan = planned(held.plan, held.cut, ref, config.branch, outside, item_id)
item = plan if isinstance(plan, NoItem) else item_facts(root, ref, plan, timeout, make)
# A `checkout:` path lands in the worktree the chunk works in.
made = located(str(item.worktree.path), pathlib.Path.home()) if isinstance(item, ItemFacts) and isinstance(item.worktree, Worktree) else config
return render(Gathered(ref, note, held.cut, item, plan_name(ref, outside), (config if isinstance(made, Failure) else made).places, outside is not None, config.texts))
return render(Gathered(ref, note, held.cut, item, plan_name(ref, outside), (config if isinstance(made, Failure) else made).places, outside is not None, config.texts, held.merges_unread, left_worktrees(root, forge_run) if config.merge == "human" else ()))
def item_facts(root: pathlib.Path, default: str, plan: NextChunk, timeout: float, make: bool) -> ItemFacts:
@@ -173,6 +180,25 @@ def item_worktree(root: pathlib.Path, branch: str, default: str) -> Worktree | F
return Failure(f"none made: {added.reason}") if isinstance(added, Failure) else Worktree(path, how)
def left_worktrees(root: pathlib.Path, forge_run: Run) -> tuple[LeftWorktree, ...]:
"""Each worktree beside the checkout whose branch's pull request has merged at the worktree's head: under `merge = "human"` a person merges after the chunk's run has ended, so its worker never ran `chunk-pr clean`. A worktree whose forge can't be asked counts as not left."""
listing, url = git("worktree", "list", "--porcelain"), git("remote", "get-url", "origin")
if isinstance(listing, Failure) or isinstance(url, Failure):
return ()
merged = [(path, branch, merged_pull(forge_of(url), branch, head, forge_run)) for path, branch, head in worktrees(listing) if path != root]
return tuple(LeftWorktree(path, branch, pull) for path, branch, pull in merged if isinstance(pull, str))
def forge_runner(root: pathlib.Path, timeout: float) -> Run:
"""Runs the forge's CLI at root, stopped after timeout seconds: what it printed, or a Failure with why it failed."""
def run(command: list[str]) -> str | Failure:
done = ran(command, root, timeout)
if isinstance(done, Failure):
return Failure(f"`{' '.join(command[:3])}` {done.reason}")
return Failure(f"`{' '.join(command[:3])}` exited {done.code}: {done.stderr.strip()}") if done.code else done.stdout
return run
def pull_listing(root: pathlib.Path, branch: str, timeout: float) -> tuple[Forge, Ran | Failure] | None:
url = git("remote", "get-url", "origin")
if isinstance(url, Failure):