Refuse chunk-pr merge while a scoring run the plan calls is unrecorded, and call one for a release cut with none
CI / tests (pull_request) Successful in 2m15s

This commit is contained in:
2026-11-10 23:45:06 +01:00
parent 0301ca01c4
commit 92867f64cd
9 changed files with 208 additions and 11 deletions
+10 -1
View File
@@ -21,6 +21,7 @@ GH_LIST = ["gh", "pr", "list", "--head", "item-7", "--json", "number,headRefOid,
TEA_LIST = ["tea", "api", "repos/{owner}/{repo}/pulls?state=open&limit=50"]
GH_SETTINGS = ["gh", "repo", "view", "--json", "mergeCommitAllowed,rebaseMergeAllowed,squashMergeAllowed"]
TEA_SETTINGS = ["tea", "api", "repos/{owner}/{repo}"]
OWED = [str(pathlib.Path(__file__).resolve().parents[1] / "larv-review"), "scoring-run-owed"]
class Checkout:
@@ -58,7 +59,7 @@ class Checkout:
def acted(self) -> list[list[str]]:
"""What it ran beyond reading the checkout, the pull requests and the repository's settings."""
reads = [GH_LIST, TEA_LIST, GH_SETTINGS, TEA_SETTINGS]
reads = [GH_LIST, TEA_LIST, GH_SETTINGS, TEA_SETTINGS, OWED]
return [command for command in self.ran if tuple(command) not in self.answers and command not in reads]
@@ -137,6 +138,14 @@ class Merge(unittest.TestCase):
self.assertIsInstance(step(["merge"], checkout), Failure)
self.assertEqual(checkout.ran, [])
def test_a_scoring_run_the_chunk_owes_and_has_not_recorded_refuses_the_merge(self):
for origin in (GITHUB, GITEA):
with self.subTest(origin=origin):
checkout = Checkout(origin, open=True)
checkout.answers[tuple(OWED)] = Failure("larv-review scoring-run-owed: the chunk owes 2 scoring runs")
self.assertEqual(step(["merge", "--gate-passed"], checkout), Failure("larv-review scoring-run-owed: the chunk owes 2 scoring runs"))
self.assertEqual(checkout.acted(), [])
def test_github_merges_with_a_merge_commit_pinned_to_the_head(self):
checkout = Checkout(GITHUB, open=True, allowed=("squashMergeAllowed", "mergeCommitAllowed"))
self.assertEqual(step(["merge", "--gate-passed"], checkout), "Merged pull request #12 (merge).")