mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-05 00:20:11 +01:00
ci: add --ci-timeout option for gantt scripts
The gantt charts have a vertical line indicating the time when marge-bot stops waiting for CI to finish. Currently the ci-timeout is hard-coded at 60 minutes. But marge-bot's timeout is configurable, so allow this value to be configured as well. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32637>
This commit is contained in:
parent
55f452530a
commit
fd7423b38e
2 changed files with 30 additions and 7 deletions
|
|
@ -87,6 +87,10 @@ def add_gantt_bar(
|
|||
}
|
||||
)
|
||||
|
||||
|
||||
def generate_gantt_chart(
|
||||
pipeline: ProjectPipeline, ci_timeout: float = 60
|
||||
) -> go.Figure:
|
||||
if pipeline.yaml_errors:
|
||||
raise ValueError("Pipeline YAML errors detected")
|
||||
|
||||
|
|
@ -132,11 +136,11 @@ def add_gantt_bar(
|
|||
|
||||
# Add a deadline line to the chart
|
||||
created_at = datetime.fromisoformat(pipeline.created_at.replace("Z", "+00:00"))
|
||||
timeout_at = created_at + timedelta(hours=1)
|
||||
timeout_at = created_at + timedelta(minutes=ci_timeout)
|
||||
fig.add_vrect(
|
||||
x0=timeout_at,
|
||||
x1=timeout_at,
|
||||
annotation_text="1h Timeout",
|
||||
annotation_text=f"{int(ci_timeout)} min Timeout",
|
||||
fillcolor="gray",
|
||||
line_width=2,
|
||||
line_color="gray",
|
||||
|
|
@ -152,12 +156,13 @@ def main(
|
|||
token: str | None,
|
||||
pipeline_url: str,
|
||||
output: str | None,
|
||||
ci_timeout: float = 60,
|
||||
):
|
||||
token = read_token(token)
|
||||
gl = gitlab.Gitlab(url=GITLAB_URL, private_token=token, retry_transient_errors=True)
|
||||
|
||||
pipeline, _ = get_gitlab_pipeline_from_url(gl, pipeline_url)
|
||||
fig = generate_gantt_chart(pipeline)
|
||||
fig: go.Figure = generate_gantt_chart(pipeline, ci_timeout)
|
||||
if output and "htm" in output:
|
||||
fig.write_html(output)
|
||||
elif output:
|
||||
|
|
@ -183,5 +188,12 @@ if __name__ == "__main__":
|
|||
metavar="token",
|
||||
help="force GitLab token, otherwise it's read from ~/.config/gitlab-token",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--ci-timeout",
|
||||
metavar="ci_timeout",
|
||||
type=float,
|
||||
default=60,
|
||||
help="Time that marge-bot will wait for ci to finish. Defaults to one hour.",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
main(args.token, args.pipeline_url, args.output)
|
||||
main(args.token, args.pipeline_url, args.output, args.ci_timeout)
|
||||
|
|
|
|||
|
|
@ -103,7 +103,11 @@ def gitlab_post_reply_to_note(gl: Gitlab, event: RESTObject, reply_message: str)
|
|||
|
||||
|
||||
def main(
|
||||
token: str | None, since: str | None, marge_user_id: int = 9716, project_ids: list[int] = [176]
|
||||
token: str | None,
|
||||
since: str | None,
|
||||
marge_user_id: int = 9716,
|
||||
project_ids: list[int] = [176],
|
||||
ci_timeout: float = 60,
|
||||
):
|
||||
log.basicConfig(level=log.INFO)
|
||||
|
||||
|
|
@ -148,7 +152,7 @@ def main(
|
|||
pipeline: ProjectPipeline
|
||||
pipeline, _ = get_gitlab_pipeline_from_url(gl, pipeline_url)
|
||||
log.info("Generating gantt chart...")
|
||||
fig = generate_gantt_chart(pipeline)
|
||||
fig = generate_gantt_chart(pipeline, ci_timeout)
|
||||
file_name = f"{str(pipeline.id)}-Gantt.html"
|
||||
fig.write_html(file_name)
|
||||
log.info("Uploading gantt file...")
|
||||
|
|
@ -199,5 +203,12 @@ if __name__ == "__main__":
|
|||
default=[176], # default is the mesa/mesa project id
|
||||
help="GitLab project id(s) to analyze. Defaults to 176 i.e. mesa/mesa.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--ci-timeout",
|
||||
metavar="ci_timeout",
|
||||
type=float,
|
||||
default=60,
|
||||
help="Time that marge-bot will wait for ci to finish. Defaults to one hour.",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
main(args.token, args.since, args.marge_user_id, args.project_id)
|
||||
main(args.token, args.since, args.marge_user_id, args.project_id, args.ci_timeout)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue