bin/ci: crnm: Reduce trace cluttering

Some recurrent messages are only cluttering the ci_run_n_monitor's logs,
so let's use the easily provided @cache decorator to print stuff that
the user will only needs to see once.

Also removes some junk that can happen during the pipeline monitoring
loop, like the "----" line break, and newlines.

Signed-off-by: Guilherme Gallo <guilherme.gallo@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30361>
This commit is contained in:
Guilherme Gallo 2024-07-26 12:48:32 -03:00 committed by Marge Bot
parent ff18d1ec23
commit 0acc31a001
2 changed files with 15 additions and 7 deletions

View File

@ -33,6 +33,7 @@ from gitlab_common import (
get_gitlab_project,
get_token_from_default_dir,
pretty_duration,
print_once,
read_token,
wait_for_pipeline,
)
@ -79,9 +80,9 @@ def print_job_status(
duration = job_duration(job)
print(
print_once(
STATUS_COLORS[job.status]
+ "🞋 target job " # U+1F78B Round target
+ "🞋 job " # U+1F78B Round target
+ link2print(job.web_url, job.name, job_name_field_pad)
+ (f"has new status: {job.status}" if new_status else f"{job.status}")
+ (f" ({pretty_duration(duration)})" if job.started_at else "")
@ -206,10 +207,8 @@ def monitor_pipeline(
pretty_wait(REFRESH_WAIT_JOBS)
continue
print("---------------------------------", flush=False)
if jobs_waiting:
print(
print_once(
f"{Fore.YELLOW}Waiting for jobs to update status:",
", ".join(jobs_waiting),
Fore.RESET,
@ -321,7 +320,9 @@ def cancel_jobs(
with ThreadPoolExecutor(max_workers=6) as exe:
part = partial(cancel_job, project)
exe.map(part, to_cancel)
print()
# The cancelled jobs are printed without a newline
print_once()
def print_log(

View File

@ -12,6 +12,7 @@ import logging
import os
import re
import time
from functools import cache
from pathlib import Path
GITLAB_URL = "https://gitlab.freedesktop.org"
@ -28,10 +29,16 @@ TOKEN_PREFIXES: dict[str, str] = {
"Feed token": "glft-",
"Incoming mail token": "glimt-",
"GitLab Agent for Kubernetes token": "glagent-",
"SCIM Tokens": "glsoat-"
"SCIM Tokens": "glsoat-",
}
@cache
def print_once(*args, **kwargs):
"""Print without spamming the output"""
print(*args, **kwargs)
def pretty_duration(seconds):
"""Pretty print duration"""
hours, rem = divmod(seconds, 3600)