From fb2adbeeb7d22bbd805e050151a90b94c7e2d0fe Mon Sep 17 00:00:00 2001 From: Eric Engestrom Date: Wed, 26 Jun 2024 17:37:02 +0200 Subject: [PATCH] ci_run_n_monitor: be coherent about using sets for `element in group` checks Part-of: --- bin/ci/ci_run_n_monitor.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bin/ci/ci_run_n_monitor.py b/bin/ci/ci_run_n_monitor.py index a3d6c951383..5237b51de35 100755 --- a/bin/ci/ci_run_n_monitor.py +++ b/bin/ci/ci_run_n_monitor.py @@ -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: