test_trust_live: ride out a transient Gitea error while waiting for the dismissal
CI / checks (push) Skipped
CI / checks (pull_request) Successful in 1m55s
CI / e2e (pull_request) Successful in 4m45s

A dropped connection or a 5xx inside the wait is retried until the
deadline; any other error fails at once (review on #164).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J5Utyfzw7gF7UhjRDEtjTk
This commit is contained in:
dongarandClaude Opus 5.5 committed 2026-10-18 13:16:10 +00:00
1 parent 63ad679c8b
commit a1eeab1bc7
1 file changed
+18 -1
+18 -1
View File
@@ -5,6 +5,7 @@ and a commit pushed after the approval needs approving again: at once by the
agent's own check, and by Gitea once it has dismissed the approval.""" agent's own check, and by Gitea once it has dismissed the approval."""
import base64 import base64
import re
import time import time
import uuid import uuid
from pathlib import Path from pathlib import Path
@@ -44,13 +45,29 @@ def wait_for_dismissal(gitea: GiteaClient, repo: str, pr: int) -> None:
in the push itself, and its merge check counts what isn't dismissed yet. in the push itself, and its merge check counts what isn't dismissed yet.
A merge tried before that job has run can still go through (#162).""" A merge tried before that job has run can still go through (#162)."""
deadline = time.monotonic() + DISMISS_WAIT_S deadline = time.monotonic() + DISMISS_WAIT_S
while gitea.approvals(repo, pr): # dismissed ones aren't listed while True:
try:
if not gitea.approvals(repo, pr): # dismissed ones aren't listed
return
except GiteaError as exc:
# A busy Gitea may drop a call or answer 5xx; ask again. Anything
# else, such as a 4xx, is a real failure.
if not transient(exc) or time.monotonic() > deadline:
raise
assert time.monotonic() < deadline, ( assert time.monotonic() < deadline, (
f"Gitea didn't dismiss the approval within {DISMISS_WAIT_S}s" f"Gitea didn't dismiss the approval within {DISMISS_WAIT_S}s"
) )
time.sleep(0.5) time.sleep(0.5)
def transient(exc: GiteaError) -> bool:
"""A dropped connection or a 5xx: worth asking again."""
text = str(exc)
return text.startswith("gitea request failed") or bool(
re.search(r" returned 5\d\d:", text)
)
def test_merging_needs_the_operators_approval_of_the_pr_as_it_is( def test_merging_needs_the_operators_approval_of_the_pr_as_it_is(
tmp_path: Path, live_config: AgentConfig, gitea: GiteaClient tmp_path: Path, live_config: AgentConfig, gitea: GiteaClient
) -> None: ) -> None: