bin/ci: crnm: Sanitize n_colums value
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

The number of columns should never be less than 1, otherwise we can
break the script such as:

```
Traceback (most recent call last):
  File "/var/home/guilherme/projects/mesa/bin/ci/ci_run_n_monitor.py", line 734, in <module>
    main()
  File "/var/home/guilherme/projects/mesa/bin/ci/ci_run_n_monitor.py", line 713, in main
    target_job_id, ret, exec_t = monitor_pipeline(
                                 ^^^^^^^^^^^^^^^^^
  File "/var/home/guilherme/projects/mesa/bin/ci/ci_run_n_monitor.py", line 221, in monitor_pipeline
    cancel_jobs(project, to_cancel)
  File "/var/home/guilherme/projects/mesa/bin/ci/ci_run_n_monitor.py", line 400, in cancel_jobs
    print_formatted_list(cancelled_jobs, indentation=8)
  File "/var/home/guilherme/projects/mesa/bin/ci/gitlab_gql.py", line 373, in print_formatted_list
    step = (len(elements) // n_columns) + 1
            ~~~~~~~~~~~~~~^^~~~~~~~~~~
ZeroDivisionError: integer division or modulo by zero
```

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35250>
This commit is contained in:
Guilherme Gallo 2025-05-30 02:41:08 -03:00 committed by Marge Bot
parent b1d81a7df1
commit e942d1e9e4

View file

@ -369,7 +369,7 @@ def print_formatted_list(elements: list[str], indentation: int = 0) -> None:
return
column_separator_size = 2
column_width: int = len(max(elements, key=len)) + column_separator_size
n_columns: int = (h_size - indentation) // column_width
n_columns: int = max((h_size - indentation) // column_width, 1)
step = (len(elements) // n_columns) + 1
rows = [elements[i::step] for i in range(step)]
for line in rows: