|
|
@@ -124,14 +124,29 @@ def test_publish_commits_pushes_and_opens_a_pr(
|
|
|
|
task_id="demo-abc", milestone=2, project="demo", plan="the plan"
|
|
|
|
task_id="demo-abc", milestone=2, project="demo", plan="the plan"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
assert git.pushed == ["demo-abc/milestone-2"]
|
|
|
|
assert git.pushed == ["demo-abc-milestone-2"]
|
|
|
|
assert client.opened[0]["head"] == "demo-abc/milestone-2"
|
|
|
|
assert client.opened[0]["head"] == "demo-abc-milestone-2"
|
|
|
|
assert client.opened[0]["base"] == "main"
|
|
|
|
assert client.opened[0]["base"] == "main"
|
|
|
|
assert "the plan" in client.opened[0]["body"]
|
|
|
|
assert "the plan" in client.opened[0]["body"]
|
|
|
|
assert result.pull_request is not None
|
|
|
|
assert result.pull_request is not None
|
|
|
|
assert "opened PR #1" in result.note
|
|
|
|
assert "opened PR #1" in result.note
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_a_branch_named_after_the_task_does_not_block_publishing(
|
|
|
|
|
|
|
|
store: StateStore, tmp_path: Path
|
|
|
|
|
|
|
|
) -> None:
|
|
|
|
|
|
|
|
# Live run 3: the executor ran `git checkout -b <task id>` itself. With
|
|
|
|
|
|
|
|
# "<task>/milestone-1" as the harness's branch, git refused it, since a
|
|
|
|
|
|
|
|
# branch name can't also be a directory of other branch names.
|
|
|
|
|
|
|
|
git = FakeGit(tmp_path / "work")
|
|
|
|
|
|
|
|
git.repo.checkout_new_branch("demo-abc")
|
|
|
|
|
|
|
|
result = build(store, git, FakeGitea()).publish(
|
|
|
|
|
|
|
|
task_id="demo-abc", milestone=1, project="demo", plan="p"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result.pull_request is not None
|
|
|
|
|
|
|
|
assert git.pushed == ["demo-abc-milestone-1"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_intent_is_recorded_then_committed(store: StateStore, tmp_path: Path) -> None:
|
|
|
|
def test_intent_is_recorded_then_committed(store: StateStore, tmp_path: Path) -> None:
|
|
|
|
build(store, FakeGit(tmp_path / "work"), FakeGitea()).publish(
|
|
|
|
build(store, FakeGit(tmp_path / "work"), FakeGitea()).publish(
|
|
|
|
task_id="t", milestone=1, project="demo", plan="p"
|
|
|
|
task_id="t", milestone=1, project="demo", plan="p"
|
|
|
@@ -150,7 +165,7 @@ def test_failure_after_intent_leaves_it_pending_for_reconciliation(
|
|
|
|
|
|
|
|
|
|
|
|
[pending] = store.pending_intents()
|
|
|
|
[pending] = store.pending_intents()
|
|
|
|
assert pending.kind == OPEN_PR_INTENT
|
|
|
|
assert pending.kind == OPEN_PR_INTENT
|
|
|
|
assert pending.payload["branch"] == "t/milestone-1"
|
|
|
|
assert pending.payload["branch"] == "t-milestone-1"
|
|
|
|
assert pending.payload["sha"]
|
|
|
|
assert pending.payload["sha"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -171,7 +186,7 @@ def test_nothing_to_commit_is_reported_not_raised(
|
|
|
|
|
|
|
|
|
|
|
|
def test_branch_is_namespaced_by_task(store: StateStore, tmp_path: Path) -> None:
|
|
|
|
def test_branch_is_namespaced_by_task(store: StateStore, tmp_path: Path) -> None:
|
|
|
|
publisher = build(store, FakeGit(tmp_path / "work"), FakeGitea())
|
|
|
|
publisher = build(store, FakeGit(tmp_path / "work"), FakeGitea())
|
|
|
|
assert publisher.branch_for("greet-9f2", 3) == "greet-9f2/milestone-3"
|
|
|
|
assert publisher.branch_for("greet-9f2", 3) == "greet-9f2-milestone-3"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_reconciler_settles_an_intent_left_by_a_crash(
|
|
|
|
def test_reconciler_settles_an_intent_left_by_a_crash(
|
|
|
@@ -183,9 +198,9 @@ def test_reconciler_settles_an_intent_left_by_a_crash(
|
|
|
|
client = FakeGitea()
|
|
|
|
client = FakeGitea()
|
|
|
|
publisher = build(store, FakeGit(tmp_path / "work"), client)
|
|
|
|
publisher = build(store, FakeGit(tmp_path / "work"), client)
|
|
|
|
intent_id = store.begin_intent(
|
|
|
|
intent_id = store.begin_intent(
|
|
|
|
OPEN_PR_INTENT, {"branch": "t/milestone-1"}, cause="crash simulation"
|
|
|
|
OPEN_PR_INTENT, {"branch": "t-milestone-1"}, cause="crash simulation"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
client.existing.append("t/milestone-1")
|
|
|
|
client.existing.append("t-milestone-1")
|
|
|
|
|
|
|
|
|
|
|
|
reconcilers = publisher.reconcilers()
|
|
|
|
reconcilers = publisher.reconcilers()
|
|
|
|
assert set(reconcilers) == {OPEN_PR_INTENT}
|
|
|
|
assert set(reconcilers) == {OPEN_PR_INTENT}
|
|
|
@@ -205,8 +220,8 @@ def test_work_the_executor_committed_itself_is_published(
|
|
|
|
task_id="t", milestone=1, project="demo", plan="p"
|
|
|
|
task_id="t", milestone=1, project="demo", plan="p"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
assert result.pull_request is not None
|
|
|
|
assert result.pull_request is not None
|
|
|
|
assert git.pushed == ["t/milestone-1"]
|
|
|
|
assert git.pushed == ["t-milestone-1"]
|
|
|
|
assert git.remote["t/milestone-1"] == git.head_sha()
|
|
|
|
assert git.remote["t-milestone-1"] == git.head_sha()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_a_followup_the_executor_committed_itself_is_pushed(
|
|
|
|
def test_a_followup_the_executor_committed_itself_is_pushed(
|
|
|
@@ -219,7 +234,7 @@ def test_a_followup_the_executor_committed_itself_is_pushed(
|
|
|
|
git.repo.commit_all("Address review")
|
|
|
|
git.repo.commit_all("Address review")
|
|
|
|
sha = publisher.push_followup(task_id="t", milestone=1, message="m")
|
|
|
|
sha = publisher.push_followup(task_id="t", milestone=1, message="m")
|
|
|
|
assert sha == git.head_sha()
|
|
|
|
assert sha == git.head_sha()
|
|
|
|
assert git.pushed == ["t/milestone-1", "t/milestone-1"]
|
|
|
|
assert git.pushed == ["t-milestone-1", "t-milestone-1"]
|
|
|
|
# Nothing new since that push: no second push, and it says so.
|
|
|
|
# Nothing new since that push: no second push, and it says so.
|
|
|
|
assert publisher.push_followup(task_id="t", milestone=1, message="m") is None
|
|
|
|
assert publisher.push_followup(task_id="t", milestone=1, message="m") is None
|
|
|
|
assert len(git.pushed) == 2
|
|
|
|
assert len(git.pushed) == 2
|
|
|
@@ -239,15 +254,15 @@ def test_publishing_again_adopts_the_open_pr_instead_of_opening_another(
|
|
|
|
assert len(client.opened) == 1
|
|
|
|
assert len(client.opened) == 1
|
|
|
|
assert result.pull_request is not None and result.pull_request.number == 1
|
|
|
|
assert result.pull_request is not None and result.pull_request.number == 1
|
|
|
|
assert "already open" in result.note
|
|
|
|
assert "already open" in result.note
|
|
|
|
assert git.pushed == ["t/milestone-1", "t/milestone-1"] # updated it
|
|
|
|
assert git.pushed == ["t-milestone-1", "t-milestone-1"] # updated it
|
|
|
|
assert store.pending_intents() == []
|
|
|
|
assert store.pending_intents() == []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_a_closed_pr_is_not_adopted(store: StateStore, tmp_path: Path) -> None:
|
|
|
|
def test_a_closed_pr_is_not_adopted(store: StateStore, tmp_path: Path) -> None:
|
|
|
|
git = FakeGit(tmp_path / "work")
|
|
|
|
git = FakeGit(tmp_path / "work")
|
|
|
|
client = FakeGitea()
|
|
|
|
client = FakeGitea()
|
|
|
|
client.existing.append("t/milestone-1")
|
|
|
|
client.existing.append("t-milestone-1")
|
|
|
|
client.closed.add("t/milestone-1")
|
|
|
|
client.closed.add("t-milestone-1")
|
|
|
|
publisher = build(store, git, client)
|
|
|
|
publisher = build(store, git, client)
|
|
|
|
assert publisher.published_pull_request("t", 1) is None
|
|
|
|
assert publisher.published_pull_request("t", 1) is None
|
|
|
|
publisher.publish(task_id="t", milestone=1, project="demo", plan="p")
|
|
|
|
publisher.publish(task_id="t", milestone=1, project="demo", plan="p")
|
|
|
|