From 42021b4d13fe849bbe0c2986329d899c9f993bde Mon Sep 17 00:00:00 2001 From: Eric Engestrom Date: Fri, 28 Jul 2023 13:09:24 +0100 Subject: [PATCH] bin/ci_run_n_monitor: get git sha from pipeline if specified, instead of requiring --rev to match Fixes: 9ce717ab31f24faf0a15 ("ci_run_n_monitor: add ability to specify the pipeline to use, instead of auto-detecting it") Signed-off-by: Eric Engestrom Part-of: --- bin/ci/ci_run_n_monitor.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/bin/ci/ci_run_n_monitor.py b/bin/ci/ci_run_n_monitor.py index dda7797..c56b231 100755 --- a/bin/ci/ci_run_n_monitor.py +++ b/bin/ci/ci_run_n_monitor.py @@ -240,13 +240,6 @@ def parse_args() -> None: ) parser.add_argument("--target", metavar="target-job", help="Target job") parser.add_argument( - "--rev", metavar="revision", help="repository git revision (default: HEAD)" - ) - parser.add_argument( - "--pipeline-url", - help="URL of the pipeline to use, instead of auto-detecting it.", - ) - parser.add_argument( "--token", metavar="token", help="force GitLab token, otherwise it's read from ~/.config/gitlab-token", @@ -255,6 +248,16 @@ def parse_args() -> None: "--force-manual", action="store_true", help="Force jobs marked as manual" ) parser.add_argument("--stress", action="store_true", help="Stresstest job(s)") + + mutex_group1 = parser.add_mutually_exclusive_group() + mutex_group1.add_argument( + "--rev", metavar="revision", help="repository git revision (default: HEAD)" + ) + mutex_group1.add_argument( + "--pipeline-url", + help="URL of the pipeline to use, instead of auto-detecting it.", + ) + return parser.parse_args() @@ -289,9 +292,6 @@ if __name__ == "__main__": retry_transient_errors=True) REV: str = args.rev - if not REV: - REV = check_output(['git', 'rev-parse', 'HEAD']).decode('ascii').strip() - print(f"Revision: {REV}") if args.pipeline_url: assert args.pipeline_url.startswith(GITLAB_URL) @@ -303,9 +303,14 @@ if __name__ == "__main__": pipeline_id = int(url_path_components[5]) cur_project = gl.projects.get(project_name) pipe = cur_project.pipelines.get(pipeline_id) + REV = pipe.sha else: cur_project = get_gitlab_project(gl, "mesa") + if not REV: + REV = check_output(['git', 'rev-parse', 'HEAD']).decode('ascii').strip() pipe = wait_for_pipeline(cur_project, REV) + + print(f"Revision: {REV}") print(f"Pipeline: {pipe.web_url}") deps = set() -- 2.7.4