From e99236bad4282918273504cd4a58cbcf4d054b0e Mon Sep 17 00:00:00 2001 From: Sergi Blanch-Torne Date: Mon, 30 Jun 2025 11:55:10 +0200 Subject: [PATCH] ci: crnm: extend it to work with other instances ci-run_n_monitor tool can work with more projects than Mesa. It would be split to its own repo with transparent access from the scripts in Mesa. But meanwhile, this simple change allows using more GitLab instances than the default gl.fd.o. Signed-off-by: Sergi Blanch-Torne Reviewed-by: Guilherme Gallo Acked-by: Eric Engestrom Part-of: --- bin/ci/ci_run_n_monitor.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/bin/ci/ci_run_n_monitor.py b/bin/ci/ci_run_n_monitor.py index 96da644998f..024b9a45f5e 100755 --- a/bin/ci/ci_run_n_monitor.py +++ b/bin/ci/ci_run_n_monitor.py @@ -429,6 +429,13 @@ def parse_args() -> argparse.Namespace: epilog="Example: mesa-monitor.py --rev $(git rev-parse HEAD) " + '--target ".*traces" ', ) + parser.add_argument( + "--server", + metavar="gitlab-server", + type=str, + default=GITLAB_URL, + help=f"Specify the GitLab server work with (Default: {GITLAB_URL})", + ) parser.add_argument( "--target", metavar="target-job", @@ -534,6 +541,7 @@ def print_detected_jobs( def find_dependencies( + server: str, token: str | None, target_jobs_regex: re.Pattern, include_stage_regex: re.Pattern, @@ -549,6 +557,7 @@ def find_dependencies( dependencies, and returns the names of these jobs. Args: + server (str): The url to the GitLab server. token (str | None): The GitLab API token. If None, the API is accessed without authentication. target_jobs_regex (re.Pattern): A regex pattern to match the names of the target jobs. @@ -561,7 +570,10 @@ def find_dependencies( Raises: SystemExit: If no target jobs are found in the pipeline. """ - gql_instance = GitlabGQL(token=token) + gql_instance = GitlabGQL( + url=f"{server}/api/graphql", + token=token + ) dag = create_job_needs_dag( gql_instance, {"projectPath": project_path.path_with_namespace, "iid": iid} ) @@ -624,7 +636,7 @@ def main() -> None: token = read_token(args.token) - gl = gitlab.Gitlab(url=GITLAB_URL, + gl = gitlab.Gitlab(url=args.server, private_token=token, retry_transient_errors=True) @@ -700,6 +712,7 @@ def main() -> None: exclude_stage_regex = re.compile(exclude_stage) deps = find_dependencies( + server=args.server, token=token, target_jobs_regex=target_jobs_regex, include_stage_regex=include_stage_regex,