Add the project setting merge = "human", under which chunk-pr merge leaves the pull request ready and a do-epic chunk parks on your merge

This commit is contained in:
Lilleman
2026-11-19 15:51:44 +01:00
parent 017cf33611
commit e2f5661760
15 changed files with 240 additions and 58 deletions
+6 -1
View File
@@ -94,6 +94,11 @@ approval of the pull request, as its branch protection requires on GitHub, befor
false. `project-config wait-for-approval` prints true or false; the full listing shows the setting only where
it is true.
`merge` is an optional setting, "chunk" or "human": who merges a chunk's pull request. Left out, it is
"chunk": `chunk-pr merge` merges it. Under "human", for a team whose rules keep the merge with a person,
`chunk-pr merge` leaves the pull request ready and says it awaits a person's merge. `project-config merge`
prints chunk or human; the full listing shows the setting only where it is human.
`tooling-on-host` is an optional setting, true or false: whether the loop may run the project's language
runtime, package manager, tests and task runner directly on the host, for a project with no container
setup. Left out, it is false, and they run through the project's container setup.
@@ -142,7 +147,7 @@ and its commits and pull request are titled "ABC-123 - …".
Exit 1, naming each fault on stderr, where no config names the checkout, or its config leaves out a
setting, names an unknown one, misspells a path, a language or a template, sets `coding-conventions` to anything but a list of paths, sets `wait-for-approval` or
`tooling-on-host` to anything but true or false, sets `notifier` to anything but mattermost or slack or
`tooling-on-host` to anything but true or false, sets `merge` to anything but chunk or human, sets `notifier` to anything but mattermost or slack or
without `env-file`, sets `jira-finish-transition` or `jira-finish-status` to anything but a name, without the other or
without a `plan` in Jira, names a Jira `plan` and leaves out `jira-score-formula` or `jira-score-bar`, sets
one of those two without a `plan` in Jira, sets the formula to one that doesn't parse or the bar to anything
+10
View File
@@ -33,6 +33,10 @@ Notifier = typing.Literal["mattermost", "slack"]
NOTIFIERS: tuple[Notifier, ...] = typing.get_args(Notifier)
# An optional boolean setting: whether `chunk-pr merge` waits for a human's approval of the pull request. False where left out.
WAIT_FOR_APPROVAL = "wait-for-approval"
# An optional setting: who merges a chunk's pull request, one of MERGERS. The chunk does where it is left out; under "human", `chunk-pr merge` leaves the pull request ready for a person to merge, for a team whose rules keep the merge with a person.
MERGE = "merge"
Merger = typing.Literal["chunk", "human"]
MERGERS: tuple[Merger, ...] = typing.get_args(Merger)
# An optional boolean setting: whether the loop may run the project's language runtime, package manager, tests and task runner on the host, for a project with no container setup. False where left out.
TOOLING_ON_HOST = "tooling-on-host"
# An optional number setting: the comprehension score under which code health is very important. A legacy project, whose code scores low, may lower it.
@@ -124,6 +128,7 @@ class ProjectConfig:
# The config's `env-file`, or None where it sets none.
env_file: pathlib.Path | None = None
wait_for_approval: bool = False
merge: Merger = "chunk"
tooling_on_host: bool = False
readability_floor: decimal.Decimal = DEFAULT_FLOOR
parallel_chunks: int = 1
@@ -265,6 +270,10 @@ def parallel_read(value: object) -> int | Unfit:
return value if type(value) is int and value >= 1 else Unfit(f"not a whole number of 1 or more, such as `{PARALLEL_CHUNKS} = 2`")
def merger_read(value: object) -> Merger | Unfit:
return next((name for name in MERGERS if name == value), None) or Unfit(f"not {' or '.join(f'"{name}"' for name in MERGERS)}")
def notifier_read(value: object) -> Notifier | Unfit:
return next((name for name in NOTIFIERS if name == value), None) or Unfit(f"not {' or '.join(NOTIFIERS)}")
@@ -341,6 +350,7 @@ def language_fault(value: object) -> str | None:
# Each one-value setting, in the order `project-config` lists them.
SCALARS = (
Scalar(WAIT_FOR_APPROVAL, "wait_for_approval", switch, lambda on: "true" if on else "false"),
Scalar(MERGE, "merge", merger_read),
Scalar(TOOLING_ON_HOST, "tooling_on_host", switch, lambda on: "true" if on else "false"),
Scalar(READABILITY_FLOOR, "readability_floor", floor_read),
Scalar(PARALLEL_CHUNKS, "parallel_chunks", parallel_read),
+30 -1
View File
@@ -390,6 +390,27 @@ class LoadTest(ConfigCase):
(folder / "config.toml").write_text(CLIENT + f"coding-conventions = {value}\n", encoding="utf-8")
self.assertIn(f"`coding-conventions` is {shown}, not a list of paths, each \"checkout:<path>\"", self.failure())
def test_merge_is_chunk_where_left_out_and_takes_human(self) -> None:
folder = self.write("acme", CLIENT)
left_out = load(self.checkout, self.checkout, self.home)
assert isinstance(left_out, ProjectConfig), left_out
self.assertEqual(left_out.merge, "chunk")
for spelled in ("chunk", "human"):
with self.subTest(spelled):
(folder / "config.toml").write_text(CLIENT + f'merge = "{spelled}"\n')
found = load(self.checkout, self.checkout, self.home)
assert isinstance(found, ProjectConfig), found
self.assertEqual(found.merge, spelled)
def test_a_merge_that_is_neither_chunk_nor_human_fails_naming_it(self) -> None:
folder = self.write("acme", CLIENT)
for spelled in ('"person"', "true"):
with self.subTest(spelled):
(folder / "config.toml").write_text(CLIENT + f"merge = {spelled}\n")
found = load(self.checkout, self.checkout, self.home)
assert isinstance(found, Failure), found
self.assertIn(f'`merge` is {spelled.strip(chr(34)) if spelled == "true" else repr(spelled.strip(chr(34)))}, not "chunk" or "human"'.replace("true", "True"), found.reason)
def test_wait_for_approval_is_an_optional_boolean_that_is_false_where_left_out(self) -> None:
folder = self.write("acme", CLIENT)
left_out = load(self.checkout, self.checkout, self.home)
@@ -506,7 +527,7 @@ class LoadTest(ConfigCase):
def test_the_failure_for_a_misplaced_env_file_and_a_missing_setting_names_both_and_lists_every_setting(self) -> None:
folder = self.write("acme", "".join(line + "\n" for line in CLIENT.splitlines() if not line.startswith("plan")) + 'env-file = "checkout:.env"\n')
self.assertEqual(self.failure(), f"{folder / 'config.toml'}: `plan` is missing; `env-file` is 'checkout:.env', not {OUTSIDE}. The settings are {', '.join(SETTINGS)}, and optionally branch, coding-conventions, commit-title, env-file, jira-finish-status, jira-finish-transition, jira-score-bar, jira-score-formula, language, notifier, parallel-chunks, pull-request-title, readability-floor, tooling-on-host, touch-predictions and wait-for-approval.")
self.assertEqual(self.failure(), f"{folder / 'config.toml'}: `plan` is missing; `env-file` is 'checkout:.env', not {OUTSIDE}. The settings are {', '.join(SETTINGS)}, and optionally branch, coding-conventions, commit-title, env-file, jira-finish-status, jira-finish-transition, jira-score-bar, jira-score-formula, language, merge, notifier, parallel-chunks, pull-request-title, readability-floor, tooling-on-host, touch-predictions and wait-for-approval.")
def test_two_configs_naming_one_checkout_fail_naming_both(self) -> None:
self.write("acme", CLIENT)
@@ -685,6 +706,14 @@ class ToolTest(ConfigCase):
self.assertEqual((self.run_tool("jira-score-formula").stdout, self.run_tool("jira-score-bar").stdout), ("100 * V / (2**S + 8)\n", "0.5\n"))
self.assertIn("jira-score-formula: 100 * V / (2**S + 8)\njira-score-bar: 0.5\n", self.run_tool().stdout)
def test_prints_who_merges_and_lists_it_only_where_a_human_does(self) -> None:
folder = self.write("acme", CLIENT)
self.assertEqual(self.run_tool("merge").stdout, "chunk\n")
self.assertNotIn("merge", self.run_tool().stdout)
(folder / "config.toml").write_text(CLIENT + 'merge = "human"\n')
self.assertEqual(self.run_tool("merge").stdout, "human\n")
self.assertEqual(self.run_tool().stdout.splitlines()[-1], "merge: human")
def test_prints_true_or_false_for_wait_for_approval_and_lists_it_only_where_the_config_sets_it(self) -> None:
folder = self.write("acme", CLIENT)
left_out = self.run_tool("wait-for-approval")