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

sjanc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new d80d39121 ci: Fix PR maintenance without previous successful run
d80d39121 is described below

commit d80d39121aced6f3e06c81a7d79fa0b614b71cba
Author: Szymon Janc <[email protected]>
AuthorDate: Thu Oct 22 18:43:48 2026 +0200

    ci: Fix PR maintenance without previous successful run
    
    gh prints empty line when previous successful run query returns no
    runs, and json.loads() of it raised JSONDecodeError, failing the run.
    As failed runs are not counted, workflow that never succeeded kept
    failing forever. Parse whole response instead and treat empty list as
    no previous run, which processes all pull requests.
    
    Assisted-by: Claude:claude-opus-5-5
---
 .github/scripts/pr_maintenance.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/.github/scripts/pr_maintenance.py 
b/.github/scripts/pr_maintenance.py
index a0d89d82a..636b52e14 100644
--- a/.github/scripts/pr_maintenance.py
+++ b/.github/scripts/pr_maintenance.py
@@ -163,14 +163,20 @@ def merge_base(base, head):
 def previous_run():
     """Returns previous successful run of this workflow, or None"""
     try:
-        return json.loads(gh("api", f"repos/{REPO}/actions/workflows/"
+        runs = json.loads(gh("api", f"repos/{REPO}/actions/workflows/"
                              f"{WORKFLOW}/runs?branch={BRANCH}"
-                             f"&status=success&per_page=1",
-                             "--jq", ".workflow_runs[0]"))
+                             f"&status=success&per_page=1"))
     except subprocess.CalledProcessError as e:
         print(f"Failed to get previous run: {e.stderr.strip()}")
         return None
 
+    # No successful run yet, e.g. right after workflow was added
+    if not runs["workflow_runs"]:
+        print("No previous successful run")
+        return None
+
+    return runs["workflow_runs"][0]
+
 
 def list_pulls():
     """

Reply via email to