From 9a7e8f8a06ad3ac5439aaac898898b1711a78fa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 17 Dec 2024 23:51:49 +0100 Subject: [PATCH] simplify get_github_action_eval_result --- nixpkgs_review/github.py | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/nixpkgs_review/github.py b/nixpkgs_review/github.py index dbeb2620..eedc6848 100644 --- a/nixpkgs_review/github.py +++ b/nixpkgs_review/github.py @@ -12,8 +12,6 @@ from .utils import System -http.client.HTTPConnection.debuglevel = 1 - def pr_url(pr: int) -> str: return f"https://github.com/NixOS/nixpkgs/pull/{pr}" @@ -163,20 +161,24 @@ def get_github_action_eval_result( return None for workflow_run in workflow_runs: - if workflow_run["name"] == "Eval": - artifacts: list[Any] = self.get( - workflow_run["artifacts_url"], - )["artifacts"] - - for artifact in artifacts: - if artifact["name"] == "comparison": - changed_paths: Any = self.get_json_from_artifact( - workflow_id=artifact["id"], - json_filename="changed-paths.json", - ) - if changed_paths is not None: - if "rebuildsByPlatform" in changed_paths: - return changed_paths["rebuildsByPlatform"] # type: ignore + if workflow_run["name"] != "Eval": + continue + artifacts: list[Any] = self.get( + workflow_run["artifacts_url"], + )["artifacts"] + + for artifact in artifacts: + if artifact["name"] != "comparison": + continue + changed_paths: Any = self.get_json_from_artifact( + workflow_id=artifact["id"], + json_filename="changed-paths.json", + ) + if changed_paths is None: + continue + if (path := changed_paths.get("rebuildsByPlatform")) is not None: + assert isinstance(path, dict) + return path return None def get_borg_eval_gist(self, pr: dict[str, Any]) -> dict[System, set[str]] | None: