ci/ci_run_n_monitor: print job duration time

If the job is running, it prints the elapsed time so far, if it finished
already, it prints the time it took.

Signed-off-by: Helen Koike <helen.koike@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25822>
This commit is contained in:
Helen Koike
2023-10-03 11:28:26 -03:00
committed by Marge Bot
parent 69012e355e
commit 663ad191ca

View File

@@ -25,7 +25,12 @@ from typing import Literal, Optional
import gitlab
from colorama import Fore, Style
from gitlab_common import get_gitlab_project, read_token, wait_for_pipeline
from gitlab_common import (
get_gitlab_project,
read_token,
wait_for_pipeline,
pretty_duration,
)
from gitlab_gql import GitlabGQL, create_job_needs_dag, filter_dag, print_dag
GITLAB_URL = "https://gitlab.freedesktop.org"
@@ -55,6 +60,11 @@ def print_job_status(job, new_status=False) -> None:
if job.status == "canceled":
return
if job.duration:
duration = job.duration
elif job.started_at:
duration = time.perf_counter() - time.mktime(job.started_at.timetuple())
print(
STATUS_COLORS[job.status]
+ "🞋 job "
@@ -62,6 +72,7 @@ def print_job_status(job, new_status=False) -> None:
+ f"{job.web_url}\a{job.name}"
+ URL_END
+ (f" has new status: {job.status}" if new_status else f" :: {job.status}")
+ (f" ({pretty_duration(duration)})" if job.started_at else "")
+ Style.RESET_ALL
)