You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tooling.apache.org by sb...@apache.org on 2026/07/24 17:48:50 UTC

(tooling-trusted-releases) branch sbp updated: Make the source tree comparison task fail if there is a problem

This is an automated email from the ASF dual-hosted git repository.

sbp pushed a commit to branch sbp
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git


The following commit(s) were added to refs/heads/sbp by this push:
     new 68169dbf Make the source tree comparison task fail if there is a problem
68169dbf is described below

commit 68169dbf8e8987bcaf7e55c11193b7e74b4fb694
Author: Sean B. Palmer <se...@miscoranda.com>
AuthorDate: Fri Jul 24 18:48:23 2026 +0100

    Make the source tree comparison task fail if there is a problem
---
 atr/tasks/checks/compare.py       |  5 +++--
 tests/unit/test_checks_compare.py | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/atr/tasks/checks/compare.py b/atr/tasks/checks/compare.py
index 6f776d94..dc6bbdfb 100644
--- a/atr/tasks/checks/compare.py
+++ b/atr/tasks/checks/compare.py
@@ -113,11 +113,12 @@ async def source_trees(args: checks.FunctionArguments) -> results.Results | None
             await aiofiles.os.makedirs(github_dir, exist_ok=True)
             checkout_dir = await _checkout_github_source(payload, github_dir)
             if checkout_dir is None:
+                repo_url = f"https://github.com/{payload.repository}.git"
                 await recorder.exception(
                     "Failed to clone GitHub repository for comparison",
-                    {"repo_url": f"https://github.com/{payload.repository}.git", "sha": payload.sha},
+                    {"repo_url": repo_url, "sha": payload.sha},
                 )
-                return None
+                raise RuntimeError(f"Failed to clone {repo_url} at {payload.sha} for source tree comparison")
             archive_root_result = await _find_archive_root(primary_abs_path, extracted_dir)
             if archive_root_result.root is None:
                 await recorder.concern(
diff --git a/tests/unit/test_checks_compare.py b/tests/unit/test_checks_compare.py
index 917408a4..e4072b26 100644
--- a/tests/unit/test_checks_compare.py
+++ b/tests/unit/test_checks_compare.py
@@ -52,6 +52,15 @@ class CheckoutRecorder:
         return str(checkout_dir)
 
 
+class CheckoutFailure:
+    async def __call__(
+        self,
+        payload: atr.models.github.TrustedPublisherPayload,
+        checkout_dir: safe.StatePath,
+    ) -> str | None:
+        return None
+
+
 class CloneRecorder:
     def __init__(self) -> None:
         self.calls: list[tuple[str, str, pathlib.Path]] = []
@@ -733,6 +742,31 @@ async def test_source_trees_permits_pkg_info_when_pyproject_toml_exists(
     assert len(recorder.note_calls) == 1
 
 
+@pytest.mark.asyncio
+async def test_source_trees_raises_when_checkout_fails(monkeypatch: pytest.MonkeyPatch, tmp_path: pathlib.Path) -> None:
+    temp_dir = safe.StatePath(tmp_path)
+    recorder = RecorderStub(True)
+    args = _make_args(recorder)
+    payload = _make_payload()
+    cache_dir = temp_dir / "cache"
+    cache_dir.path.mkdir()
+    tmp_root = temp_dir / "temporary-root"
+
+    monkeypatch.setattr(atr.attestable, "github_tp_payload_read", PayloadLoader(payload))
+    monkeypatch.setattr(atr.tasks.checks.compare, "_checkout_github_source", CheckoutFailure())
+    monkeypatch.setattr(atr.tasks.checks, "resolve_archive_dir", ArchiveDirResolver(cache_dir))
+    monkeypatch.setattr(atr.tasks.checks.compare.paths, "get_tmp_dir", ReturnValue(tmp_root))
+
+    with pytest.raises(RuntimeError, match=r"Failed to clone .* for source tree comparison"):
+        await atr.tasks.checks.compare.source_trees(args)
+
+    assert len(recorder.exception_calls) == 1
+    message, data = recorder.exception_calls[0]
+    assert message == "Failed to clone GitHub repository for comparison"
+    assert isinstance(data, dict)
+    assert data["repo_url"] == "https://github.com/apache/test.git"
+
+
 @pytest.mark.asyncio
 async def test_source_trees_records_failure_when_archive_has_invalid_files(
     monkeypatch: pytest.MonkeyPatch, tmp_path: pathlib.Path


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tooling.apache.org
For additional commands, e-mail: commits-help@tooling.apache.org