ci_run_n_monitor: be coherent about using sets for element in group checks

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29917>
This commit is contained in:
Eric Engestrom
2024-06-26 17:37:02 +02:00
committed by Marge Bot
parent fa3d529f55
commit fb2adbeeb7

View File

@@ -59,7 +59,7 @@ STATUS_COLORS = {
"skipped": "",
}
COMPLETED_STATUSES = ["success", "failed"]
COMPLETED_STATUSES = {"success", "failed"}
def print_job_status(job, new_status=False) -> None:
@@ -121,7 +121,7 @@ def monitor_pipeline(
if stress:
# When stress test, it is necessary to collect this information before start.
for job in pipeline.jobs.list(all=True, include_retried=True):
if target_jobs_regex.fullmatch(job.name) and job.status in ["success", "failed"]:
if target_jobs_regex.fullmatch(job.name) and job.status in {"success", "failed"}:
stress_status_counter[job.name][job.status] += 1
execution_times[job.name][job.id] = (job_duration(job), job.status, job.web_url)
@@ -134,7 +134,7 @@ def monitor_pipeline(
target_id = job.id
target_status = job.status
if stress and target_status in ["success", "failed"]:
if stress and target_status in {"success", "failed"}:
if (
stress < 0
or sum(stress_status_counter[job.name].values()) < stress
@@ -190,7 +190,7 @@ def monitor_pipeline(
if (
{"failed"}.intersection(target_statuses.values())
and not set(["running", "pending"]).intersection(target_statuses.values())
and not {"running", "pending"}.intersection(target_statuses.values())
):
return None, 1, execution_times
@@ -229,15 +229,15 @@ def enable_job(
) -> gitlab.v4.objects.ProjectPipelineJob:
"""enable job"""
if (
(job.status in ["success", "failed"] and action_type != "retry")
(job.status in {"success", "failed"} and action_type != "retry")
or (job.status == "manual" and not force_manual)
or job.status in ["skipped", "running", "created", "pending"]
or job.status in {"skipped", "running", "created", "pending"}
):
return job
pjob = project.jobs.get(job.id, lazy=True)
if job.status in ["success", "failed", "canceled", "canceling"]:
if job.status in {"success", "failed", "canceled", "canceling"}:
new_job = pjob.retry()
job = get_pipeline_job(pipeline, new_job["id"])
else: