ci_run_n_monitor: Poll mesa/mesa and user/mesa for pipelines at the same time.
authorEric Anholt <eric@anholt.net>
Thu, 19 Oct 2023 10:03:34 +0000 (12:03 +0200)
committerMarge Bot <emma+marge@anholt.net>
Fri, 20 Oct 2023 08:23:24 +0000 (08:23 +0000)
Now you don't fail if you're trying to test a mesa/mesa MR pipeline and
gitlab takes more than 10s to create it.  And you don't have to wait 10
seconds to get things started (aka see if your regex was right) if you're
testing a user/mesa fork pipeline.

Fixes: 941d92408ee5 ("bin/ci_run_n_monitor: automatically pick MR pipelines when they exist")
Closes: #9894
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25810>

bin/ci/ci_run_n_monitor.py
bin/ci/gitlab_common.py
bin/ci/update_traces_checksum.py

index 1dfcd65..253d141 100755 (executable)
@@ -327,13 +327,9 @@ if __name__ == "__main__":
         else:
             if not REV:
                 REV = check_output(['git', 'rev-parse', 'HEAD']).decode('ascii').strip()
-            # Look for an MR pipeline first
-            cur_project = gl.projects.get("mesa/mesa")
-            pipe = wait_for_pipeline(cur_project, REV, timeout=10)
-            if not pipe:
-                # Fallback to a pipeline in the user's fork
-                cur_project = get_gitlab_project(gl, args.project)
-                pipe = wait_for_pipeline(cur_project, REV)
+            mesa_project = gl.projects.get("mesa/mesa")
+            user_project = get_gitlab_project(gl, args.project)
+            (pipe, cur_project) = wait_for_pipeline([mesa_project, user_project], REV)
 
         print(f"Revision: {REV}")
         print(f"Pipeline: {pipe.web_url}")
index 7d20cc9..758f81b 100644 (file)
@@ -34,17 +34,19 @@ def read_token(token_arg: Optional[str]) -> str:
     )
 
 
-def wait_for_pipeline(project, sha: str, timeout=None):
+def wait_for_pipeline(projects, sha: str, timeout=None):
     """await until pipeline appears in Gitlab"""
-    print(f"⏲ for the pipeline to appear in {project.path_with_namespace}..", end="")
+    project_names = [project.path_with_namespace for project in projects]
+    print(f"⏲ for the pipeline to appear in {project_names}..", end="")
     start_time = time.time()
     while True:
-        pipelines = project.pipelines.list(sha=sha)
-        if pipelines:
-            print("", flush=True)
-            return pipelines[0]
+        for project in projects:
+            pipelines = project.pipelines.list(sha=sha)
+            if pipelines:
+                print("", flush=True)
+                return (pipelines[0], project)
         print("", end=".", flush=True)
         if timeout and time.time() - start_time > timeout:
             print(" not found", flush=True)
-            return None
+            return (None, None)
         time.sleep(1)
index c0da34f..064573d 100755 (executable)
@@ -134,7 +134,7 @@ if __name__ == "__main__":
         cur_project = get_gitlab_project(gl, "mesa")
 
         print(f"Revision: {args.rev}")
-        pipe = wait_for_pipeline(cur_project, args.rev)
+        (pipe, cur_project) = wait_for_pipeline([cur_project], args.rev)
         print(f"Pipeline: {pipe.web_url}")
         gather_results(cur_project, pipe)