diff options
author | Guilherme Gallo <guilherme.gallo@collabora.com> | 2024-01-22 20:13:54 -0300 |
---|---|---|
committer | Guilherme Gallo <guilherme.gallo@collabora.com> | 2024-01-26 00:37:03 -0300 |
commit | 50fcea9c34b17e391bb8c5adc021bb13d03a20e2 (patch) | |
tree | 5c54c796ffe8e7288143e759b96fce4ed9421a6b /bin | |
parent | 7cc6140cc87e5459f1b9bdf8923e5ae534ad49ab (diff) |
bin/ci: Propagate the token to GitlabGQL
Fix an issue in `ci_run_n_monitor.py` where the token was not
being correctly propagated to the GitlabGQL abstraction. This addresses
misbehavior in scenarios like running pipelines in a private fork,
ensuring proper functionality.
Also document `find_dependencies` function.
Signed-off-by: Guilherme Gallo <guilherme.gallo@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27206>
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/ci/ci_run_n_monitor.py | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/bin/ci/ci_run_n_monitor.py b/bin/ci/ci_run_n_monitor.py index 3b5462b4287..293b5c515f2 100755 --- a/bin/ci/ci_run_n_monitor.py +++ b/bin/ci/ci_run_n_monitor.py @@ -335,8 +335,31 @@ def print_detected_jobs( print_job_set(Fore.BLUE, "target", target_jobs) -def find_dependencies(target_jobs_regex: re.Pattern, project_path: str, iid: int) -> set[str]: - gql_instance = GitlabGQL() +def find_dependencies(token: str | None, + target_jobs_regex: re.Pattern, + project_path: str, + iid: int) -> set[str]: + """ + Find the dependencies of the target jobs in a GitLab pipeline. + + This function uses the GitLab GraphQL API to fetch the job dependency graph + of a pipeline, filters the graph to only include the target jobs and their + dependencies, and returns the names of these jobs. + + Args: + 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. + project_path (str): The path of the GitLab project. + iid (int): The internal ID of the pipeline. + + Returns: + set[str]: A set of the names of the target jobs and their dependencies. + + Raises: + SystemExit: If no target jobs are found in the pipeline. + """ + gql_instance = GitlabGQL(token=token) dag = create_job_needs_dag( gql_instance, {"projectPath": project_path.path_with_namespace, "iid": iid} ) @@ -388,7 +411,10 @@ if __name__ == "__main__": deps = set() print("🞋 job: " + Fore.BLUE + target + Style.RESET_ALL) deps = find_dependencies( - target_jobs_regex=target_jobs_regex, iid=pipe.iid, project_path=cur_project + token=token, + target_jobs_regex=target_jobs_regex, + iid=pipe.iid, + project_path=cur_project ) target_job_id, ret = monitor_pipeline( cur_project, pipe, target_jobs_regex, deps, args.force_manual, args.stress |