From 1e209ec210069a676849f3b2cc5c0a9b3ad18c4a Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Fri, 14 Oct 2022 17:05:08 +0900 Subject: [PATCH 1/2] ARROW-18048: [Dev][Archery][Crossbow] Comment bot waits for a while before generate a report If we generate a report immediately after we submit CI tasks, the generated report doesn't have suitable task CI task URL. Because CI tasks aren't started. We need to wait for a while before we generate a report to collect suitable CI task URLs. Before: https://github.com/apache/arrow/pull/14409#issuecomment-1278396923 https://github.com/ursacomputing/crossbow/tree/actions-1e49219a52-github-r-binary-packages is used. After: https://github.com/apache/arrow/pull/14409#issuecomment-1278625825 https://github.com/ursacomputing/crossbow/actions/runs/3248297802/jobs/5329340988 is used. --- dev/archery/archery/bot.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dev/archery/archery/bot.py b/dev/archery/archery/bot.py index c548e9a2a47..f2dada7bcc6 100644 --- a/dev/archery/archery/bot.py +++ b/dev/archery/archery/bot.py @@ -20,6 +20,7 @@ from pathlib import Path from functools import partial import tempfile +import time import click import github @@ -232,8 +233,10 @@ def _clone_arrow_and_crossbow(dest, crossbow_repo, pull_request): help='Additional task parameters for rendering the CI templates') @click.option('--arrow-version', '-v', default=None, help='Set target version explicitly.') +@click.option('--wait', default=60, + help='Wait the specified seconds before generating a report.') @click.pass_obj -def submit(obj, tasks, groups, params, arrow_version): +def submit(obj, tasks, groups, params, arrow_version, wait): """ Submit crossbow testing tasks. @@ -269,6 +272,10 @@ def submit(obj, tasks, groups, params, arrow_version): queue.put(job, prefix="actions", increment_job_id=False) queue.push() + # # wait for tasks of the job are triggered to collect more + # # suitable task URLs + time.sleep(wait) + # render the response comment's content report = CommentReport(job, crossbow_repo=crossbow_repo) From 907871042632639504b19c1a585a639fa3fdf680 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Fri, 14 Oct 2022 21:41:01 +0900 Subject: [PATCH 2/2] Sleep in Report --- dev/archery/archery/bot.py | 8 ++------ dev/archery/archery/crossbow/reports.py | 10 +++++++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dev/archery/archery/bot.py b/dev/archery/archery/bot.py index f2dada7bcc6..468b6246577 100644 --- a/dev/archery/archery/bot.py +++ b/dev/archery/archery/bot.py @@ -20,7 +20,6 @@ from pathlib import Path from functools import partial import tempfile -import time import click import github @@ -272,12 +271,9 @@ def submit(obj, tasks, groups, params, arrow_version, wait): queue.put(job, prefix="actions", increment_job_id=False) queue.push() - # # wait for tasks of the job are triggered to collect more - # # suitable task URLs - time.sleep(wait) - # render the response comment's content - report = CommentReport(job, crossbow_repo=crossbow_repo) + report = CommentReport(job, crossbow_repo=crossbow_repo, + wait_for_task=wait) # send the response pull_request.create_issue_comment(report.show()) diff --git a/dev/archery/archery/crossbow/reports.py b/dev/archery/archery/crossbow/reports.py index a3958d8ccf2..2c8a0f0375c 100644 --- a/dev/archery/archery/crossbow/reports.py +++ b/dev/archery/archery/crossbow/reports.py @@ -20,6 +20,7 @@ import operator import fnmatch import functools +import time import click import requests @@ -41,7 +42,7 @@ class Report: "arrow_commit", ] - def __init__(self, job, task_filters=None): + def __init__(self, job, task_filters=None, wait_for_task=None): self.job = job tasks = sorted(job.tasks.items()) @@ -53,6 +54,7 @@ def __init__(self, job, task_filters=None): tasks = [(name, task) for name, task in tasks if name in filtered] self._tasks = dict(tasks) + self._wait_for_task = wait_for_task @property def repo_url(self): @@ -66,6 +68,8 @@ def branch_url(self, branch): return '{}/tree/{}'.format(self.repo_url, branch) def task_url(self, task): + if self._wait_for_task: + time.sleep(self._wait_for_task) if task.status().build_links: # show link to the actual build, some CI providers implement # the statuses API others implement the checks API, retrieve any. @@ -307,9 +311,9 @@ class CommentReport(Report): ), } - def __init__(self, job, crossbow_repo): + def __init__(self, job, crossbow_repo, wait_for_task=None): self.crossbow_repo = crossbow_repo - super().__init__(job) + super().__init__(job, wait_for_task=wait_for_task) def show(self): url = 'https://github.com/{repo}/branches/all?query={branch}'