Answer stability round 1: 1 🔴, 5 🟡 (0 misread); hold a pull request's base on the forge to the recorded one, ask origin for the epic branch, and name where a chunk's work landed
CI / tests (pull_request) Successful in 3m46s
CI / tests (pull_request) Successful in 3m46s
This commit is contained in:
+56
-12
@@ -1024,28 +1024,40 @@ class AnEpicsWorkingBranch(DoEpicTest):
|
||||
self.store = MemoryEpic("ABC-12", [self.issues[0], issue("ABC-22", "do-epic-claude", blockers=("ABC-20",))])
|
||||
self.backend = lambda config, key: (self.store, EpicRecord(Description(self.description))) # type: ignore[method-assign,arg-type]
|
||||
self.git_calls: list[tuple[tuple[str, ...], str | None]] = []
|
||||
self.git_timeouts: list[tuple[str, object]] = []
|
||||
|
||||
def settings(self, more: str) -> None:
|
||||
(self.home / ".claude-projects" / "do-epic" / "config.toml").write_text(SETTINGS + more, encoding="utf-8")
|
||||
|
||||
def with_git(self, fake: FakeEffects, **answers: str | Failure) -> FakeEffects:
|
||||
"""fake, whose git answers each command by its first word: as answers has it, else as a checkout whose origin has the branch ABC-12, which holds origin/main."""
|
||||
answered = {"symbolic-ref": "origin/main\n", "fetch": "", "rev-parse": "aaa\n", "rev-list": "0\n", "config": ""} | {name.replace("_", "-"): answer for name, answer in answers.items()}
|
||||
answered = {"symbolic-ref": "origin/main\n", "fetch": "", "ls-remote": "aaa\trefs/heads/ABC-12\n", "rev-parse": "aaa\n", "rev-list": "0\n", "config": ""} | {name.replace("_", "-"): answer for name, answer in answers.items()}
|
||||
|
||||
def git(*args: str, cwd: str | None = None, **more: object) -> str | Failure:
|
||||
self.git_calls.append((args, cwd))
|
||||
self.git_timeouts.append((args[0], more.get("timeout")))
|
||||
return answered.get(args[0], Failure("no git"))
|
||||
fake.effects = lambda made=fake.effects(): dataclasses.replace(made, git=git) # type: ignore[method-assign]
|
||||
return fake
|
||||
|
||||
def recorded(self, **answers: object) -> Forge:
|
||||
"""A forge like `awaiting`'s, in a checkout that records ABC-12 as the base of ABC-20's branch."""
|
||||
forge = awaiting(**answers)
|
||||
forge.answers["git config"] = "ABC-12\n"
|
||||
return forge
|
||||
|
||||
def test_a_chunk_that_starts_levels_the_branch_and_records_it_as_the_chunks_base(self) -> None:
|
||||
fake = self.with_git(FakeEffects())
|
||||
out = io.StringIO()
|
||||
with contextlib.redirect_stdout(out):
|
||||
self.assertEqual(main.epic_based("ABC-20", self.checkout, self.epic_run(fake)), "ABC-12")
|
||||
self.assertEqual(self.git_calls, [(args, self.checkout) for args in (("symbolic-ref", "--short", "refs/remotes/origin/HEAD"), ("fetch", "--quiet", "origin"), ("rev-parse", "--quiet", "--verify", "refs/remotes/origin/ABC-12"), ("rev-list", "--count", "origin/ABC-12..origin/main"), ("config", "branch.ABC-20.chunk-base", "ABC-12"))])
|
||||
self.assertEqual(self.git_calls, [(args, self.checkout) for args in (("symbolic-ref", "--short", "refs/remotes/origin/HEAD"), ("fetch", "--quiet", "origin"), ("ls-remote", "--heads", "origin", "refs/heads/ABC-12"), ("rev-list", "--count", "origin/ABC-12..origin/main"), ("config", "branch.ABC-20.chunk-base", "ABC-12"))])
|
||||
self.assertIn("origin/ABC-12 already holds origin/main; ABC-20's pull request goes into ABC-12\n", out.getvalue())
|
||||
|
||||
def test_a_call_to_origin_that_levels_the_branch_is_stopped_after_a_minute_so_no_window_hangs_before_its_first_cycle(self) -> None:
|
||||
main.epic_based("ABC-20", self.checkout, self.epic_run(self.with_git(FakeEffects(), ls_remote="", push="")))
|
||||
self.assertEqual([timed for timed in self.git_timeouts if timed[0] in ("fetch", "ls-remote", "push")], [("fetch", 60), ("ls-remote", 60), ("push", 60), ("fetch", 60)])
|
||||
|
||||
def test_says_the_default_branchs_whole_name_however_it_ends(self) -> None:
|
||||
out = io.StringIO()
|
||||
with contextlib.redirect_stdout(out):
|
||||
@@ -1083,7 +1095,7 @@ class AnEpicsWorkingBranch(DoEpicTest):
|
||||
|
||||
def test_its_issue_moves_as_the_pull_request_opens_and_merges_and_no_person_merges_it(self) -> None:
|
||||
self.settings('jira-unblocking-statuses = ["Release Ready"]\njira-automation-moves-issues = true\njira-pull-request-open-status = "Code Review"\njira-pull-request-merged-status = "Release Ready"\n')
|
||||
self.forges = [awaiting(), awaiting(), awaiting(decision="APPROVED")]
|
||||
self.forges = [self.recorded(base="ABC-12"), self.recorded(base="ABC-12"), self.recorded(base="ABC-12", decision="APPROVED")]
|
||||
fake = self.with_git(FakeEffects(streams=[self.worker(), self.worker()], claude=[judged("finished"), judged("finished")], windows=PARKED_WINDOW))
|
||||
code, out, err = self.run_main(["--chunk", "ABC-20", "ABC-12"], fake, MODELS)
|
||||
prompts = [what[what.index("-p") + 1] for seam, what in fake.calls if seam == "stream_claude"]
|
||||
@@ -1097,10 +1109,42 @@ class AnEpicsWorkingBranch(DoEpicTest):
|
||||
self.assertIn("The chunk's pull request goes into the epic's working branch `ABC-12`", prompts[0])
|
||||
self.assertIn(("config", "branch.ABC-20.chunk-base", "ABC-12"), [args for args, _ in self.git_calls])
|
||||
|
||||
def test_a_chunk_parked_on_a_persons_merge_into_the_default_branch_stays_parked_until_its_pull_request_goes_into_the_branch(self) -> None:
|
||||
self.settings('jira-unblocking-statuses = ["Release Ready"]\njira-pull-request-merged-status = "Release Ready"\n')
|
||||
session = main.session_named("A ABC-12 do-epic ABC-20", paths_from(self.home).claude_code_transcripts)
|
||||
parked.park(self.home / ".local/state/do-epic/ABC-12", parked.Parked("ABC-20", "/code/api-ABC-20", "7", str(session.id), "your merge"))
|
||||
self.worker()(["--session-id", str(session.id)])
|
||||
# The pull request was opened into main before the setting was on; a person then changes its base to ABC-12.
|
||||
self.forges = [self.recorded(decision="APPROVED"), self.recorded(decision="APPROVED"), self.recorded(base="ABC-12", decision="APPROVED")]
|
||||
fake = self.with_git(FakeEffects(streams=[self.worker()], claude=[judged("finished")], windows="ABC-20 awaits your merge\t0\t@9\n"))
|
||||
code, out, err = self.run_main(["--chunk", "ABC-20", "ABC-12"], fake, MODELS)
|
||||
prompts = [what[what.index("-p") + 1] for seam, what in fake.calls if seam == "stream_claude"]
|
||||
self.assertEqual(code, 0, err)
|
||||
self.assertEqual(out.count("cannot read the gate: pull request #7 merges into main on the forge, but this checkout takes ABC-12 as the base of its branch; a person settles which holds, and changes the pull request's base on the forge or the branch's `chunk-base` in git's config; trying again every 60 seconds\n"), 1)
|
||||
self.assertEqual(len(prompts), 1)
|
||||
self.assertTrue(prompts[0].startswith("do-epic parked the chunk while its pull request awaited a person's merge. It resumes now: pull request #7 passed its checks and is approved. "), prompts[0])
|
||||
|
||||
def test_a_chunk_that_started_before_the_setting_was_on_keeps_its_merge_for_a_person(self) -> None:
|
||||
self.settings('jira-unblocking-statuses = ["Release Ready"]\njira-pull-request-open-status = "Code Review"\njira-pull-request-merged-status = "Release Ready"\n')
|
||||
set_on = self.repo_config.read_text(encoding="utf-8")
|
||||
self.repo_config.write_text(set_on.replace('epic-branch = "{epic}"\n', ""), encoding="utf-8")
|
||||
worker = self.worker()
|
||||
|
||||
def turns_the_setting_on(args: list[str]) -> object:
|
||||
self.repo_config.write_text(set_on, encoding="utf-8")
|
||||
return worker(args)
|
||||
self.forges = [awaiting(decision="APPROVED"), awaiting(decision="APPROVED"), awaiting(pulls=""), CLEANED]
|
||||
fake = self.with_git(FakeEffects(streams=[turns_the_setting_on, self.worker()], claude=[judged("unfinished"), judged("finished")], windows="ABC-20 awaits your merge\t0\t@9\n"))
|
||||
code, out, err = self.run_main(["--chunk", "ABC-20", "ABC-12"], fake, MODELS)
|
||||
self.assertEqual(code, 0, err)
|
||||
self.assertNotIn("config", [args[0] for args, _ in self.git_calls], "no base recorded, so the pull request goes into the default branch")
|
||||
self.assertIn("parked: pull request #7 awaits your merge\n", out)
|
||||
self.assertNotIn("move ABC-20 to Code Review", self.store.writes)
|
||||
|
||||
def test_an_issue_that_cannot_move_to_the_open_status_says_so_and_its_chunk_goes_on(self) -> None:
|
||||
self.settings('jira-unblocking-statuses = ["Release Ready"]\njira-pull-request-open-status = "Code Review"\njira-pull-request-merged-status = "Release Ready"\n')
|
||||
self.backend = lambda config, key: (StepwiseStore(self.store, {"Code Review": "QA"}), EpicRecord(Description(self.description))) # type: ignore[method-assign,arg-type]
|
||||
self.forges = [awaiting(), awaiting(), awaiting(decision="APPROVED")]
|
||||
self.forges = [self.recorded(base="ABC-12"), self.recorded(base="ABC-12"), self.recorded(base="ABC-12", decision="APPROVED")]
|
||||
fake = self.with_git(FakeEffects(streams=[self.worker(), self.worker()], claude=[judged("finished"), judged("finished")], windows=PARKED_WINDOW))
|
||||
code, out, err = self.run_main(["--chunk", "ABC-20", "ABC-12"], fake, MODELS)
|
||||
self.assertEqual(code, 0, err)
|
||||
@@ -1109,7 +1153,7 @@ class AnEpicsWorkingBranch(DoEpicTest):
|
||||
def test_a_finished_chunk_whose_issue_has_no_pull_request_into_the_epic_branch_moves_it_to_done(self) -> None:
|
||||
self.settings('jira-unblocking-statuses = ["Release Ready"]\njira-pull-request-merged-status = "Release Ready"\n')
|
||||
with contextlib.redirect_stdout(io.StringIO()):
|
||||
self.assertEqual(main.handed_on("ABC-20", self.epic_run(FakeEffects(windows="")), humans=True).code, 0)
|
||||
self.assertEqual(main.handed_on("ABC-20", self.epic_run(FakeEffects(windows="")), main.Landed.WITH_A_HUMAN).code, 0)
|
||||
self.assertEqual((self.store.issues[0].status, self.store.issues[0].done), ("Done", True))
|
||||
# A chunk not marked as in a repo moves its issue to done itself, even where the automation moves issues.
|
||||
self.settings('jira-unblocking-statuses = ["Release Ready"]\njira-automation-moves-issues = true\n')
|
||||
@@ -1124,11 +1168,11 @@ class AnEpicsWorkingBranch(DoEpicTest):
|
||||
lagging = LaggingStore(self.store, before)
|
||||
out = io.StringIO()
|
||||
with contextlib.redirect_stdout(out):
|
||||
stop = main.handed_on("ABC-20", dataclasses.replace(self.epic_run(FakeEffects(windows="")), store=lagging), in_repo=True, to_epic_branch=True)
|
||||
stop = main.handed_on("ABC-20", dataclasses.replace(self.epic_run(FakeEffects(windows="")), store=lagging), main.Landed.ON_EPIC_BRANCH)
|
||||
self.assertEqual(stop.code, 0, stop.reason)
|
||||
self.assertIn("the chunk finished; started ABC-22\n", out.getvalue())
|
||||
unread = LaggingStore(self.store, Failure("Jira answered 503"))
|
||||
stop = main.handed_on("ABC-22", dataclasses.replace(self.epic_run(FakeEffects(windows="")), store=unread), in_repo=True, to_epic_branch=True)
|
||||
stop = main.handed_on("ABC-22", dataclasses.replace(self.epic_run(FakeEffects(windows="")), store=unread), main.Landed.ON_EPIC_BRANCH)
|
||||
self.assertEqual(stop, main.Stop(1, "the chunk finished, but the next could not start: Jira answered 503"))
|
||||
|
||||
def test_the_epics_finishing_is_due_once_every_issue_has_the_merged_status(self) -> None:
|
||||
@@ -1139,13 +1183,13 @@ class AnEpicsWorkingBranch(DoEpicTest):
|
||||
|
||||
def test_without_a_merged_status_a_finished_chunk_stops_where_automation_moves_issues_and_is_done_where_it_doesnt(self) -> None:
|
||||
self.settings('jira-unblocking-statuses = ["Release Ready"]\njira-automation-moves-issues = true\n')
|
||||
stop = main.handed_on("ABC-20", self.epic_run(FakeEffects()), in_repo=True, to_epic_branch=True)
|
||||
stop = main.handed_on("ABC-20", self.epic_run(FakeEffects()), main.Landed.ON_EPIC_BRANCH)
|
||||
self.assertEqual(stop, main.Stop(1, "the chunk finished, but its issue stays as it is: its pull request merged into the epic's working branch, where the team's automation moves no issue, and do-epic's config names no `jira-pull-request-merged-status` to move it to. Move ABC-20 in Jira, then run `do-epic ABC-12` to start the chunks it blocks"))
|
||||
self.assertEqual(self.store.writes, [])
|
||||
self.settings("")
|
||||
out = io.StringIO()
|
||||
with contextlib.redirect_stdout(out):
|
||||
self.assertEqual(main.handed_on("ABC-20", self.epic_run(FakeEffects(windows="")), in_repo=True, to_epic_branch=True).code, 0)
|
||||
self.assertEqual(main.handed_on("ABC-20", self.epic_run(FakeEffects(windows="")), main.Landed.ON_EPIC_BRANCH).code, 0)
|
||||
self.assertTrue(self.store.issues[0].done)
|
||||
|
||||
def test_an_issue_whose_workflow_reaches_the_merged_status_only_through_the_open_status_moves_through_it(self) -> None:
|
||||
@@ -1153,18 +1197,18 @@ class AnEpicsWorkingBranch(DoEpicTest):
|
||||
epic = self.epic_run(FakeEffects(windows=""))
|
||||
stepwise = StepwiseStore(self.store, {"Release Ready": "Code Review"})
|
||||
with contextlib.redirect_stdout(io.StringIO()):
|
||||
stop = main.handed_on("ABC-20", dataclasses.replace(epic, store=stepwise), in_repo=True, to_epic_branch=True)
|
||||
stop = main.handed_on("ABC-20", dataclasses.replace(epic, store=stepwise), main.Landed.ON_EPIC_BRANCH)
|
||||
self.assertEqual(stop.code, 0, stop.reason)
|
||||
self.assertEqual(self.store.writes, ["move ABC-20 to Code Review", "move ABC-20 to Release Ready"])
|
||||
# An issue the open status doesn't lead on from stops on the move it asked for.
|
||||
stuck = StepwiseStore(self.store, {"Release Ready": "QA", "Code Review": "QA"})
|
||||
stop = main.handed_on("ABC-22", dataclasses.replace(epic, store=stuck), in_repo=True, to_epic_branch=True)
|
||||
stop = main.handed_on("ABC-22", dataclasses.replace(epic, store=stuck), main.Landed.ON_EPIC_BRANCH)
|
||||
self.assertTrue(stop.reason.startswith("the chunk finished, but its issue could not move to 'Release Ready': ABC-22 has no transition to 'Release Ready'"), stop.reason)
|
||||
|
||||
def test_an_issue_that_cannot_move_to_the_merged_status_stops_and_says_what_to_do(self) -> None:
|
||||
self.settings('jira-unblocking-statuses = ["Release Ready"]\njira-pull-request-merged-status = "Release Ready"\n')
|
||||
self.store.fails = "Jira answered 503"
|
||||
stop = main.handed_on("ABC-20", self.epic_run(FakeEffects()), in_repo=True, to_epic_branch=True)
|
||||
stop = main.handed_on("ABC-20", self.epic_run(FakeEffects()), main.Landed.ON_EPIC_BRANCH)
|
||||
self.assertEqual(stop.code, 1)
|
||||
self.assertTrue(stop.reason.startswith("the chunk finished, but its issue could not move to 'Release Ready': "), stop.reason)
|
||||
self.assertTrue(stop.reason.endswith("once it has that status in Jira, run `do-epic ABC-12` to start the chunks it blocks"), stop.reason)
|
||||
|
||||
Reference in New Issue
Block a user