Module: Mesa
Branch: main
Commit: 17843ad7c68ac357641e7257a6d14c202249a1fd
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=17843ad7c68ac357641e7257a6d14c202249a1fd

Author: Helen Koike <[email protected]>
Date:   Fri Sep 29 20:32:48 2023 -0300

ci/ci_run_n_monitor: merge enable_job with retry_job

Signed-off-by: Helen Koike <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25473>

---

 bin/ci/ci_run_n_monitor.py | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/bin/ci/ci_run_n_monitor.py b/bin/ci/ci_run_n_monitor.py
index b9e26ce6c1d..f1b233a548c 100755
--- a/bin/ci/ci_run_n_monitor.py
+++ b/bin/ci/ci_run_n_monitor.py
@@ -21,7 +21,7 @@ from collections import defaultdict
 from concurrent.futures import ThreadPoolExecutor
 from functools import partial
 from itertools import chain
-from typing import Optional
+from typing import Literal, Optional
 
 import gitlab
 from colorama import Fore, Style
@@ -94,11 +94,11 @@ def monitor_pipeline(
             # target jobs
             if target_jobs_regex.match(job.name):
                 if force_manual and job.status == "manual":
-                    enable_job(project, job, True)
+                    enable_job(project, job, "target")
 
                 if stress and job.status in ["success", "failed"]:
                     stress_status_counter[job.name][job.status] += 1
-                    retry_job(project, job)
+                    enable_job(project, job, "retry")
 
                 print_job_status(job, job.status not in 
target_statuses[job.id])
                 target_statuses[job.id] = job.status
@@ -112,7 +112,7 @@ def monitor_pipeline(
             # dependencies and cancelling the rest
             if job.name in dependencies:
                 if job.status == "manual":
-                    enable_job(project, job, False)
+                    enable_job(project, job, "dep")
 
             elif job.status not in [
                 "canceled",
@@ -151,22 +151,22 @@ def monitor_pipeline(
         pretty_wait(REFRESH_WAIT_JOBS)
 
 
-def enable_job(project, job, target: bool) -> None:
-    """enable manual job"""
+def enable_job(project, job, action_type: Literal["target", "dep", "retry"]) 
-> None:
+    """enable job"""
     pjob = project.jobs.get(job.id, lazy=True)
-    pjob.play()
-    if target:
+
+    if job.status in ["success", "failed", "canceled"]:
+        pjob.retry()
+    else:
+        pjob.play()
+
+    if action_type == "target":
         jtype = "🞋 "
+    elif action_type == "retry":
+        jtype = "↻"
     else:
         jtype = "(dependency)"
-    print(Fore.MAGENTA + f"{jtype} job {job.name} manually enabled" + 
Style.RESET_ALL)
-
 
-def retry_job(project, job) -> None:
-    """retry job"""
-    pjob = project.jobs.get(job.id, lazy=True)
-    pjob.retry()
-    jtype = "↻"
     print(Fore.MAGENTA + f"{jtype} job {job.name} manually enabled" + 
Style.RESET_ALL)
 
 

Reply via email to