From 9406e996a6302ec0b75bad9055f937558f21ac76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Wed, 10 Sep 2025 12:28:51 +0200 Subject: [PATCH 01/22] Initial attempt to automate notifications for CI: Extra --- .github/workflows/cpp_extra.yml | 25 +++++ dev/archery/archery/arrowci/cli.py | 78 +++++++++++++++ dev/archery/archery/arrowci/core.py | 95 +++++++++++++++++++ dev/archery/archery/arrowci/reports.py | 37 ++++++++ dev/archery/archery/cli.py | 2 + .../chat_nightly_report_workflow.txt.j2 | 38 ++++++++ 6 files changed, 275 insertions(+) create mode 100644 dev/archery/archery/arrowci/cli.py create mode 100644 dev/archery/archery/arrowci/core.py create mode 100644 dev/archery/archery/arrowci/reports.py create mode 100644 dev/archery/archery/templates/chat_nightly_report_workflow.txt.j2 diff --git a/.github/workflows/cpp_extra.yml b/.github/workflows/cpp_extra.yml index 52560ed692af..03c2ca9afc71 100644 --- a/.github/workflows/cpp_extra.yml +++ b/.github/workflows/cpp_extra.yml @@ -278,3 +278,28 @@ jobs: cmake --build cpp/examples/minimal_build.build cd cpp/examples/minimal_build ../minimal_build.build/arrow-example + report: + runs-on: ubuntu-latest + needs: + - docker + - jni-macos + name: Report + if: github.event_name == 'schedule' && always() + steps: + - name: Checkout Arrow + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + fetch-depth: 0 + - name: Setup Python + uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 + with: + python-version: 3 + - name: Setup Archery + run: python3 -m pip install -e dev/archery[crossbow] + - name: Notify + run: | + archery arrowci report-chat \ + --dry-run \ + --no-fetch \ + --webhook ${{ secrets.ARROW_ZULIP_WEBHOOK }} \ + ${{ github.run_id }} diff --git a/dev/archery/archery/arrowci/cli.py b/dev/archery/archery/arrowci/cli.py new file mode 100644 index 000000000000..abbee95f1921 --- /dev/null +++ b/dev/archery/archery/arrowci/cli.py @@ -0,0 +1,78 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +import click + +from ..utils.source import ArrowSources + + +from .reports import WorkflowReport, ChatReport +from ..crossbow.reports import ReportUtils + +_default_arrow_path = ArrowSources.find().path + + +@click.group() +@click.option('--github-token', '-t', default=None, + envvar=['CROSSBOW_GITHUB_TOKEN', 'GH_TOKEN'], + help='OAuth token for GitHub authentication') +@click.option('--arrow-path', '-a', + type=click.Path(), default=_default_arrow_path, + help='Arrow\'s repository path. Defaults to the repository of ' + 'this script') +@click.option('--output-file', metavar='', + type=click.File('w', encoding='utf8'), default='-', + help='Capture output result into file.') +@click.pass_context +def arrowci(ctx, github_token, arrow_path, output_file): + """ + Tools for CI Extra jobs on GitHub actions. + """ + ctx.ensure_object(dict) + ctx.obj['github_token'] = github_token + ctx.obj['arrow_path'] = arrow_path + ctx.obj['output'] = output_file + + +@arrowci.command() +@click.argument('workflow_id', required=True) +@click.option('--send/--dry-run', default=False, + help='Just display the report, don\'t send it') +@click.option('--webhook', '-w', + help='Zulip/Slack Webhook address to send the report to') +@click.option('--extra-message-success', '-s', default=None, + help='Extra message, will be appended if no failures.') +@click.option('--extra-message-failure', '-f', default=None, + help='Extra message, will be appended if there are failures.') +@click.option('--fetch/--no-fetch', default=True, + help='Fetch references (branches and tags) from the remote') +@click.pass_obj +def report_chat(obj, workflow_id, send, webhook, extra_message_success, + extra_message_failure, fetch): + """ + Send a chat report to a webhook showing success/failure + of tasks in a Crossbow run. + """ + output = obj['output'] + + report_chat = ChatReport(report=WorkflowReport(workflow_id), + extra_message_success=extra_message_success, + extra_message_failure=extra_message_failure) + if send: + ReportUtils.send_message(webhook, report_chat.render("text")) + else: + output.write(report_chat.render("text")) diff --git a/dev/archery/archery/arrowci/core.py b/dev/archery/archery/arrowci/core.py new file mode 100644 index 000000000000..07a64f0530c1 --- /dev/null +++ b/dev/archery/archery/arrowci/core.py @@ -0,0 +1,95 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +from functools import cached_property + +import requests + + +class Workflow: + def __init__(self, workflow_id, gh_token=None): + self.workflow_id = workflow_id + self.gh_token = gh_token + self.headers = { + 'Accept': 'application/vnd.github.v3+json', + } + if self.gh_token: + self.headers["Authorization"] = f"Bearer {self.gh_token}" + workflow_resp = requests.get( + f'https://api.github.com/repos/apache/arrow/actions/runs/{workflow_id}', + headers=self.headers + ) + if workflow_resp.status_code == 200: + self.workflow_data = workflow_resp.json() + + else: + # TODO: We could send an error report instead + raise Exception( + f'Failed to fetch workflow data: {workflow_resp.status_code}') + + @property + def conclusion(self): + return self.workflow_data.get('conclusion') + + @property + def jobs_url(self): + return self.workflow_data.get('jobs_url') + + @property + def name(self): + return self.workflow_data.get('name') + + @property + def url(self): + return self.workflow_data.get('html_url') + + @cached_property + def jobs(self): + jobs = [] + jobs_resp = requests.get(self.jobs_url, headers=self.headers) + if jobs_resp.status_code == 200: + jobs_data = jobs_resp.json() + for job_data in jobs_data.get('jobs', []): + job = Job(job_data) + jobs.append(job) + return jobs + + def failed_jobs(self): + return [job for job in self.jobs if not job.is_successful()] + + def successful_jobs(self): + return [job for job in self.jobs if job.is_successful()] + + +class Job: + def __init__(self, job_data): + self.job_data = job_data + + @property + def conclusion(self): + return self.job_data.get('conclusion') + + @property + def name(self): + return self.job_data.get('name') + + @property + def url(self): + return self.job_data.get('html_url') + + def is_successful(self): + return self.conclusion == 'success' diff --git a/dev/archery/archery/arrowci/reports.py b/dev/archery/archery/arrowci/reports.py new file mode 100644 index 000000000000..5823c9360e0c --- /dev/null +++ b/dev/archery/archery/arrowci/reports.py @@ -0,0 +1,37 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + +from ..crossbow.reports import JinjaReport +from .core import Workflow + + +class WorkflowReport: + def __init__(self, workflow_id): + self.workflow_id = workflow_id + self.workflow = Workflow(workflow_id) + + +class ChatReport(JinjaReport): + templates = { + 'text': 'chat_nightly_report_workflow.txt.j2', + } + fields = [ + 'report', + 'extra_message_success', + 'extra_message_failure', + ] diff --git a/dev/archery/archery/cli.py b/dev/archery/archery/cli.py index 927dcb730acd..e8a595f9590c 100644 --- a/dev/archery/archery/cli.py +++ b/dev/archery/archery/cli.py @@ -874,6 +874,8 @@ def linking_check_dependencies(obj, allowed, disallowed, paths): parent=archery) add_optional_command("crossbow", module=".crossbow.cli", function="crossbow", parent=archery) +add_optional_command("arrowci", module=".arrowci.cli", function="arrowci", + parent=archery) if __name__ == "__main__": diff --git a/dev/archery/archery/templates/chat_nightly_report_workflow.txt.j2 b/dev/archery/archery/templates/chat_nightly_report_workflow.txt.j2 new file mode 100644 index 000000000000..cfd2a118819c --- /dev/null +++ b/dev/archery/archery/templates/chat_nightly_report_workflow.txt.j2 @@ -0,0 +1,38 @@ +{# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +#} +* for <{{ report.workflow.url }}|{{ report.workflow.name }}>* +{% if report.workflow.failed_jobs() %} +:x: *{{ report.workflow.failed_jobs() | length }} failed jobs* +{% for job in report.workflow.failed_jobs() -%} +- <{{ job.url }}|{{ job.name }}> +{% endfor %} +{%- endif -%} +{% if report.workflow.successful_jobs() %} + +:tada: *{{ report.workflow.successful_jobs() | length }} successful jobs* +{%- endif -%} + +{% if extra_message_success and not report.workflow.failed_jobs() %} + +{{ extra_message_success }} +{%- endif -%} +{% if extra_message_failure and report.workflow.failed_jobs() %} + +{{ extra_message_failure }} +{% endif %} \ No newline at end of file From f35b0c43042e61472adef5b835829ad8d978943e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Wed, 10 Sep 2025 12:29:42 +0200 Subject: [PATCH 02/22] Temporarily remove the scheduled time --- .github/workflows/cpp_extra.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cpp_extra.yml b/.github/workflows/cpp_extra.yml index 03c2ca9afc71..630f5e189270 100644 --- a/.github/workflows/cpp_extra.yml +++ b/.github/workflows/cpp_extra.yml @@ -284,7 +284,7 @@ jobs: - docker - jni-macos name: Report - if: github.event_name == 'schedule' && always() + if: always() steps: - name: Checkout Arrow uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 From f52ecc84c7d712250125997ee03316b81f2fb1e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Wed, 10 Sep 2025 14:26:30 +0200 Subject: [PATCH 03/22] Make it work with fork --- .github/workflows/cpp_extra.yml | 1 + dev/archery/archery/arrowci/cli.py | 10 +++++----- dev/archery/archery/arrowci/core.py | 5 +++-- dev/archery/archery/arrowci/reports.py | 5 ++--- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/cpp_extra.yml b/.github/workflows/cpp_extra.yml index 630f5e189270..ca79f165a388 100644 --- a/.github/workflows/cpp_extra.yml +++ b/.github/workflows/cpp_extra.yml @@ -299,6 +299,7 @@ jobs: - name: Notify run: | archery arrowci report-chat \ + --repository ${{ github.repository }} \ --dry-run \ --no-fetch \ --webhook ${{ secrets.ARROW_ZULIP_WEBHOOK }} \ diff --git a/dev/archery/archery/arrowci/cli.py b/dev/archery/archery/arrowci/cli.py index abbee95f1921..dfc9c5f40c8c 100644 --- a/dev/archery/archery/arrowci/cli.py +++ b/dev/archery/archery/arrowci/cli.py @@ -52,24 +52,24 @@ def arrowci(ctx, github_token, arrow_path, output_file): @click.argument('workflow_id', required=True) @click.option('--send/--dry-run', default=False, help='Just display the report, don\'t send it') +@click.option('--repository', '-r', default='apache/arrow', + help='The organization where the workflow is located') @click.option('--webhook', '-w', help='Zulip/Slack Webhook address to send the report to') @click.option('--extra-message-success', '-s', default=None, help='Extra message, will be appended if no failures.') @click.option('--extra-message-failure', '-f', default=None, help='Extra message, will be appended if there are failures.') -@click.option('--fetch/--no-fetch', default=True, - help='Fetch references (branches and tags) from the remote') @click.pass_obj -def report_chat(obj, workflow_id, send, webhook, extra_message_success, - extra_message_failure, fetch): +def report_chat(obj, workflow_id, send, repository, webhook, extra_message_success, + extra_message_failure): """ Send a chat report to a webhook showing success/failure of tasks in a Crossbow run. """ output = obj['output'] - report_chat = ChatReport(report=WorkflowReport(workflow_id), + report_chat = ChatReport(report=WorkflowReport(workflow_id, repository), extra_message_success=extra_message_success, extra_message_failure=extra_message_failure) if send: diff --git a/dev/archery/archery/arrowci/core.py b/dev/archery/archery/arrowci/core.py index 07a64f0530c1..2129d34b12f8 100644 --- a/dev/archery/archery/arrowci/core.py +++ b/dev/archery/archery/arrowci/core.py @@ -21,16 +21,17 @@ class Workflow: - def __init__(self, workflow_id, gh_token=None): + def __init__(self, workflow_id, repository, gh_token=None): self.workflow_id = workflow_id self.gh_token = gh_token + self.repository = repository self.headers = { 'Accept': 'application/vnd.github.v3+json', } if self.gh_token: self.headers["Authorization"] = f"Bearer {self.gh_token}" workflow_resp = requests.get( - f'https://api.github.com/repos/apache/arrow/actions/runs/{workflow_id}', + f'https://api.github.com/repos/{repository}/actions/runs/{workflow_id}', headers=self.headers ) if workflow_resp.status_code == 200: diff --git a/dev/archery/archery/arrowci/reports.py b/dev/archery/archery/arrowci/reports.py index 5823c9360e0c..4bbbeafd7d4f 100644 --- a/dev/archery/archery/arrowci/reports.py +++ b/dev/archery/archery/arrowci/reports.py @@ -21,9 +21,8 @@ class WorkflowReport: - def __init__(self, workflow_id): - self.workflow_id = workflow_id - self.workflow = Workflow(workflow_id) + def __init__(self, workflow_id, repository): + self.workflow = Workflow(workflow_id, repository=repository) class ChatReport(JinjaReport): From 47604328fe52b6392ae627d0876eb90ccd5325f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Wed, 10 Sep 2025 14:46:03 +0200 Subject: [PATCH 04/22] Remove unexistent option --- .github/workflows/cpp_extra.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/cpp_extra.yml b/.github/workflows/cpp_extra.yml index ca79f165a388..6f1566f8e3d2 100644 --- a/.github/workflows/cpp_extra.yml +++ b/.github/workflows/cpp_extra.yml @@ -301,6 +301,5 @@ jobs: archery arrowci report-chat \ --repository ${{ github.repository }} \ --dry-run \ - --no-fetch \ --webhook ${{ secrets.ARROW_ZULIP_WEBHOOK }} \ ${{ github.run_id }} From 9257ac15131426e8a03250678a9d61785c4e5236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Wed, 10 Sep 2025 15:17:28 +0200 Subject: [PATCH 05/22] Add job to ignore --- .github/workflows/cpp_extra.yml | 3 +++ dev/archery/archery/arrowci/cli.py | 23 ++++++++++++++--------- dev/archery/archery/arrowci/core.py | 8 +++++--- dev/archery/archery/arrowci/reports.py | 5 +++-- 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/.github/workflows/cpp_extra.yml b/.github/workflows/cpp_extra.yml index 6f1566f8e3d2..8c89bad1b8e4 100644 --- a/.github/workflows/cpp_extra.yml +++ b/.github/workflows/cpp_extra.yml @@ -297,8 +297,11 @@ jobs: - name: Setup Archery run: python3 -m pip install -e dev/archery[crossbow] - name: Notify + env: + GH_TOKEN: ${{ github.token }} run: | archery arrowci report-chat \ + --ignore ${{ github.job }} \ --repository ${{ github.repository }} \ --dry-run \ --webhook ${{ secrets.ARROW_ZULIP_WEBHOOK }} \ diff --git a/dev/archery/archery/arrowci/cli.py b/dev/archery/archery/arrowci/cli.py index dfc9c5f40c8c..9cfef397d47b 100644 --- a/dev/archery/archery/arrowci/cli.py +++ b/dev/archery/archery/arrowci/cli.py @@ -28,7 +28,7 @@ @click.group() @click.option('--github-token', '-t', default=None, - envvar=['CROSSBOW_GITHUB_TOKEN', 'GH_TOKEN'], + envvar=['GH_TOKEN'], help='OAuth token for GitHub authentication') @click.option('--arrow-path', '-a', type=click.Path(), default=_default_arrow_path, @@ -51,27 +51,32 @@ def arrowci(ctx, github_token, arrow_path, output_file): @arrowci.command() @click.argument('workflow_id', required=True) @click.option('--send/--dry-run', default=False, - help='Just display the report, don\'t send it') + help='Just display the report, don\'t send it.') @click.option('--repository', '-r', default='apache/arrow', - help='The organization where the workflow is located') + help='The repository where the workflow is located.') +@click.option('--ignore', '-i', type=int, default=None, + help='Job id to ignore from the list of jobs.') @click.option('--webhook', '-w', - help='Zulip/Slack Webhook address to send the report to') + help='Zulip/Slack Webhook address to send the report to.') @click.option('--extra-message-success', '-s', default=None, help='Extra message, will be appended if no failures.') @click.option('--extra-message-failure', '-f', default=None, help='Extra message, will be appended if there are failures.') @click.pass_obj -def report_chat(obj, workflow_id, send, repository, webhook, extra_message_success, - extra_message_failure): +def report_chat(obj, workflow_id, send, repository, ignore, webhook, + extra_message_success, extra_message_failure): """ Send a chat report to a webhook showing success/failure of tasks in a Crossbow run. """ output = obj['output'] - report_chat = ChatReport(report=WorkflowReport(workflow_id, repository), - extra_message_success=extra_message_success, - extra_message_failure=extra_message_failure) + report_chat = ChatReport( + report=WorkflowReport(workflow_id, repository, + ignore_job_id=ignore, gh_token=obj['github_token']), + extra_message_success=extra_message_success, + extra_message_failure=extra_message_failure + ) if send: ReportUtils.send_message(webhook, report_chat.render("text")) else: diff --git a/dev/archery/archery/arrowci/core.py b/dev/archery/archery/arrowci/core.py index 2129d34b12f8..28203096f45e 100644 --- a/dev/archery/archery/arrowci/core.py +++ b/dev/archery/archery/arrowci/core.py @@ -21,10 +21,11 @@ class Workflow: - def __init__(self, workflow_id, repository, gh_token=None): + def __init__(self, workflow_id, repository, ignore_job_id, gh_token=None): self.workflow_id = workflow_id self.gh_token = gh_token self.repository = repository + self.ignore_job_id = ignore_job_id self.headers = { 'Accept': 'application/vnd.github.v3+json', } @@ -65,8 +66,9 @@ def jobs(self): if jobs_resp.status_code == 200: jobs_data = jobs_resp.json() for job_data in jobs_data.get('jobs', []): - job = Job(job_data) - jobs.append(job) + if job_data.get('id') != self.ignore_job_id: + job = Job(job_data) + jobs.append(job) return jobs def failed_jobs(self): diff --git a/dev/archery/archery/arrowci/reports.py b/dev/archery/archery/arrowci/reports.py index 4bbbeafd7d4f..15cba1022298 100644 --- a/dev/archery/archery/arrowci/reports.py +++ b/dev/archery/archery/arrowci/reports.py @@ -21,8 +21,9 @@ class WorkflowReport: - def __init__(self, workflow_id, repository): - self.workflow = Workflow(workflow_id, repository=repository) + def __init__(self, workflow_id, repository, ignore_job_id, gh_token=None): + self.workflow = Workflow(workflow_id, repository=repository, + ignore_job_id=ignore_job_id, gh_token=gh_token) class ChatReport(JinjaReport): From 9644f8d8a9eee8392c6cb2195161a78b228eb411 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Wed, 10 Sep 2025 15:34:15 +0200 Subject: [PATCH 06/22] Use job name instead of Job id --- dev/archery/archery/arrowci/cli.py | 6 +++--- dev/archery/archery/arrowci/core.py | 6 +++--- dev/archery/archery/arrowci/reports.py | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dev/archery/archery/arrowci/cli.py b/dev/archery/archery/arrowci/cli.py index 9cfef397d47b..483e5ad818fa 100644 --- a/dev/archery/archery/arrowci/cli.py +++ b/dev/archery/archery/arrowci/cli.py @@ -54,8 +54,8 @@ def arrowci(ctx, github_token, arrow_path, output_file): help='Just display the report, don\'t send it.') @click.option('--repository', '-r', default='apache/arrow', help='The repository where the workflow is located.') -@click.option('--ignore', '-i', type=int, default=None, - help='Job id to ignore from the list of jobs.') +@click.option('--ignore', '-i', default="", + help='Job name to ignore from the list of jobs.') @click.option('--webhook', '-w', help='Zulip/Slack Webhook address to send the report to.') @click.option('--extra-message-success', '-s', default=None, @@ -73,7 +73,7 @@ def report_chat(obj, workflow_id, send, repository, ignore, webhook, report_chat = ChatReport( report=WorkflowReport(workflow_id, repository, - ignore_job_id=ignore, gh_token=obj['github_token']), + ignore_job=ignore, gh_token=obj['github_token']), extra_message_success=extra_message_success, extra_message_failure=extra_message_failure ) diff --git a/dev/archery/archery/arrowci/core.py b/dev/archery/archery/arrowci/core.py index 28203096f45e..6cb4fa847ef4 100644 --- a/dev/archery/archery/arrowci/core.py +++ b/dev/archery/archery/arrowci/core.py @@ -21,11 +21,11 @@ class Workflow: - def __init__(self, workflow_id, repository, ignore_job_id, gh_token=None): + def __init__(self, workflow_id, repository, ignore_job, gh_token=None): self.workflow_id = workflow_id self.gh_token = gh_token self.repository = repository - self.ignore_job_id = ignore_job_id + self.ignore_job = ignore_job self.headers = { 'Accept': 'application/vnd.github.v3+json', } @@ -66,7 +66,7 @@ def jobs(self): if jobs_resp.status_code == 200: jobs_data = jobs_resp.json() for job_data in jobs_data.get('jobs', []): - if job_data.get('id') != self.ignore_job_id: + if job_data.get('name') != self.ignore_job: job = Job(job_data) jobs.append(job) return jobs diff --git a/dev/archery/archery/arrowci/reports.py b/dev/archery/archery/arrowci/reports.py index 15cba1022298..a10ee4541b8f 100644 --- a/dev/archery/archery/arrowci/reports.py +++ b/dev/archery/archery/arrowci/reports.py @@ -21,9 +21,9 @@ class WorkflowReport: - def __init__(self, workflow_id, repository, ignore_job_id, gh_token=None): + def __init__(self, workflow_id, repository, ignore_job, gh_token=None): self.workflow = Workflow(workflow_id, repository=repository, - ignore_job_id=ignore_job_id, gh_token=gh_token) + ignore_job=ignore_job, gh_token=gh_token) class ChatReport(JinjaReport): From 2e273566433b01fd005139b599c4b8f39c41f2fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Wed, 10 Sep 2025 16:09:07 +0200 Subject: [PATCH 07/22] Match name and job 'id' --- .github/workflows/cpp_extra.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cpp_extra.yml b/.github/workflows/cpp_extra.yml index 8c89bad1b8e4..bbc14c60b1fe 100644 --- a/.github/workflows/cpp_extra.yml +++ b/.github/workflows/cpp_extra.yml @@ -278,12 +278,17 @@ jobs: cmake --build cpp/examples/minimal_build.build cd cpp/examples/minimal_build ../minimal_build.build/arrow-example - report: + + report-extra-cpp: runs-on: ubuntu-latest needs: - docker - jni-macos - name: Report + # We don't have the job id as part of the context neither the job name. + # The GitHub API exposes numeric id or job name but not the github.job (report-extra-cpp). + # We match github.job to the name so we can pass it via context in order to be ignored on the report. + # The job is still running. + name: ${{ github.job }} if: always() steps: - name: Checkout Arrow From e4184e670f4e25c206c4eaa1ed8e1b9c5e68b46a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Wed, 10 Sep 2025 16:10:28 +0200 Subject: [PATCH 08/22] Intentionally break a job --- .github/workflows/cpp_extra.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cpp_extra.yml b/.github/workflows/cpp_extra.yml index bbc14c60b1fe..569f5865075a 100644 --- a/.github/workflows/cpp_extra.yml +++ b/.github/workflows/cpp_extra.yml @@ -227,6 +227,7 @@ jobs: # Homebrew's Protobuf is installed, its library file may be # used on test We uninstall Homebrew's Protobuf to ensure using # bundled Protobuf. + let's break the job intentionally to see the report brew uninstall protobuf - name: Prepare ccache run: | From 34ed415d2efbf2334b112249acb898419a879a0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Wed, 10 Sep 2025 16:19:06 +0200 Subject: [PATCH 09/22] Fix --- .github/workflows/cpp_extra.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/cpp_extra.yml b/.github/workflows/cpp_extra.yml index 569f5865075a..bbc14c60b1fe 100644 --- a/.github/workflows/cpp_extra.yml +++ b/.github/workflows/cpp_extra.yml @@ -227,7 +227,6 @@ jobs: # Homebrew's Protobuf is installed, its library file may be # used on test We uninstall Homebrew's Protobuf to ensure using # bundled Protobuf. - let's break the job intentionally to see the report brew uninstall protobuf - name: Prepare ccache run: | From 355dcd9dfaee72f6567a23d5c956469f10a9f3e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Wed, 10 Sep 2025 16:32:35 +0200 Subject: [PATCH 10/22] Remove some unnecessary things --- dev/archery/archery/arrowci/cli.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/dev/archery/archery/arrowci/cli.py b/dev/archery/archery/arrowci/cli.py index 483e5ad818fa..8430ba7421b5 100644 --- a/dev/archery/archery/arrowci/cli.py +++ b/dev/archery/archery/arrowci/cli.py @@ -17,34 +17,24 @@ import click -from ..utils.source import ArrowSources - - from .reports import WorkflowReport, ChatReport from ..crossbow.reports import ReportUtils -_default_arrow_path = ArrowSources.find().path - @click.group() @click.option('--github-token', '-t', default=None, envvar=['GH_TOKEN'], help='OAuth token for GitHub authentication') -@click.option('--arrow-path', '-a', - type=click.Path(), default=_default_arrow_path, - help='Arrow\'s repository path. Defaults to the repository of ' - 'this script') @click.option('--output-file', metavar='', type=click.File('w', encoding='utf8'), default='-', help='Capture output result into file.') @click.pass_context -def arrowci(ctx, github_token, arrow_path, output_file): +def arrowci(ctx, github_token, output_file): """ Tools for CI Extra jobs on GitHub actions. """ ctx.ensure_object(dict) ctx.obj['github_token'] = github_token - ctx.obj['arrow_path'] = arrow_path ctx.obj['output'] = output_file From fa02d63dd03d712506941523396acb52fb9d532f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Fri, 12 Sep 2025 09:52:33 +0200 Subject: [PATCH 11/22] Move from arrowci to ci --- dev/archery/archery/{arrowci => ci}/cli.py | 4 ++-- dev/archery/archery/{arrowci => ci}/core.py | 0 dev/archery/archery/{arrowci => ci}/reports.py | 0 dev/archery/archery/cli.py | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename dev/archery/archery/{arrowci => ci}/cli.py (97%) rename dev/archery/archery/{arrowci => ci}/core.py (100%) rename dev/archery/archery/{arrowci => ci}/reports.py (100%) diff --git a/dev/archery/archery/arrowci/cli.py b/dev/archery/archery/ci/cli.py similarity index 97% rename from dev/archery/archery/arrowci/cli.py rename to dev/archery/archery/ci/cli.py index 8430ba7421b5..b4c1c9737e87 100644 --- a/dev/archery/archery/arrowci/cli.py +++ b/dev/archery/archery/ci/cli.py @@ -29,7 +29,7 @@ type=click.File('w', encoding='utf8'), default='-', help='Capture output result into file.') @click.pass_context -def arrowci(ctx, github_token, output_file): +def ci(ctx, github_token, output_file): """ Tools for CI Extra jobs on GitHub actions. """ @@ -38,7 +38,7 @@ def arrowci(ctx, github_token, output_file): ctx.obj['output'] = output_file -@arrowci.command() +@ci.command() @click.argument('workflow_id', required=True) @click.option('--send/--dry-run', default=False, help='Just display the report, don\'t send it.') diff --git a/dev/archery/archery/arrowci/core.py b/dev/archery/archery/ci/core.py similarity index 100% rename from dev/archery/archery/arrowci/core.py rename to dev/archery/archery/ci/core.py diff --git a/dev/archery/archery/arrowci/reports.py b/dev/archery/archery/ci/reports.py similarity index 100% rename from dev/archery/archery/arrowci/reports.py rename to dev/archery/archery/ci/reports.py diff --git a/dev/archery/archery/cli.py b/dev/archery/archery/cli.py index e8a595f9590c..48ad466977c9 100644 --- a/dev/archery/archery/cli.py +++ b/dev/archery/archery/cli.py @@ -874,7 +874,7 @@ def linking_check_dependencies(obj, allowed, disallowed, paths): parent=archery) add_optional_command("crossbow", module=".crossbow.cli", function="crossbow", parent=archery) -add_optional_command("arrowci", module=".arrowci.cli", function="arrowci", +add_optional_command("ci", module=".ci.cli", function="ci", parent=archery) From 911e5d4cd61d649537f6f8a4ed14481854b36a4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Fri, 12 Sep 2025 10:00:03 +0200 Subject: [PATCH 12/22] Add webhook as env var --- .github/workflows/cpp_extra.yml | 4 ++-- dev/archery/archery/ci/cli.py | 2 +- .../archery/templates/chat_nightly_report_workflow.txt.j2 | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cpp_extra.yml b/.github/workflows/cpp_extra.yml index bbc14c60b1fe..912f088e47ae 100644 --- a/.github/workflows/cpp_extra.yml +++ b/.github/workflows/cpp_extra.yml @@ -304,10 +304,10 @@ jobs: - name: Notify env: GH_TOKEN: ${{ github.token }} + CHAT_WEBHOOK: ${{ secrets.ARROW_ZULIP_WEBHOOK }} run: | - archery arrowci report-chat \ + archery ci report-chat \ --ignore ${{ github.job }} \ --repository ${{ github.repository }} \ --dry-run \ - --webhook ${{ secrets.ARROW_ZULIP_WEBHOOK }} \ ${{ github.run_id }} diff --git a/dev/archery/archery/ci/cli.py b/dev/archery/archery/ci/cli.py index b4c1c9737e87..ead3fb7c91e7 100644 --- a/dev/archery/archery/ci/cli.py +++ b/dev/archery/archery/ci/cli.py @@ -46,7 +46,7 @@ def ci(ctx, github_token, output_file): help='The repository where the workflow is located.') @click.option('--ignore', '-i', default="", help='Job name to ignore from the list of jobs.') -@click.option('--webhook', '-w', +@click.option('--webhook', '-w', envvar=['CHAT_WEBHOOK'], help='Zulip/Slack Webhook address to send the report to.') @click.option('--extra-message-success', '-s', default=None, help='Extra message, will be appended if no failures.') diff --git a/dev/archery/archery/templates/chat_nightly_report_workflow.txt.j2 b/dev/archery/archery/templates/chat_nightly_report_workflow.txt.j2 index cfd2a118819c..8332f2c28d3f 100644 --- a/dev/archery/archery/templates/chat_nightly_report_workflow.txt.j2 +++ b/dev/archery/archery/templates/chat_nightly_report_workflow.txt.j2 @@ -16,7 +16,7 @@ # specific language governing permissions and limitations # under the License. #} -* for <{{ report.workflow.url }}|{{ report.workflow.name }}>* +*Extra CI GitHub report for <{{ report.workflow.url }}|{{ report.workflow.name }}>* {% if report.workflow.failed_jobs() %} :x: *{{ report.workflow.failed_jobs() | length }} failed jobs* {% for job in report.workflow.failed_jobs() -%} From 16308c1e7afc13a6a1d7cbc84ce650dba0a5f923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Fri, 12 Sep 2025 10:35:36 +0200 Subject: [PATCH 13/22] Add email report and refactor reports to reuse current reporting infrastructure --- .github/workflows/cpp_extra.yml | 20 ++++++ dev/archery/archery/ci/cli.py | 67 +++++++++++++++++-- dev/archery/archery/crossbow/reports.py | 2 + ...j2 => chat_nightly_workflow_report.txt.j2} | 16 ++--- .../email_workflow_report.txt.j2} | 38 ++++++----- 5 files changed, 113 insertions(+), 30 deletions(-) rename dev/archery/archery/templates/{chat_nightly_report_workflow.txt.j2 => chat_nightly_workflow_report.txt.j2} (66%) rename dev/archery/archery/{ci/reports.py => templates/email_workflow_report.txt.j2} (57%) diff --git a/.github/workflows/cpp_extra.yml b/.github/workflows/cpp_extra.yml index 912f088e47ae..89c18719cfbc 100644 --- a/.github/workflows/cpp_extra.yml +++ b/.github/workflows/cpp_extra.yml @@ -305,7 +305,27 @@ jobs: env: GH_TOKEN: ${{ github.token }} CHAT_WEBHOOK: ${{ secrets.ARROW_ZULIP_WEBHOOK }} + SMTP_PASSWORD: ${{ secrets.ARROW_SMTP_PASSWORD }} run: | + # Continue even if email sending fails + set +e + archery ci report-email \ + --dry-run \ + --smtp-server 'commit-email.info' \ + --sender-name Arrow \ + --sender-email 'arrow@commit-email.info' \ + --recipient-email 'builds@arrow.apache.org' \ + --smtp-user arrow \ + --ignore ${{ github.job }} \ + --repository ${{ github.repository }} \ + ${{ github.run_id }} + email_exit_code=$? + set -e + + if [ $email_exit_code -ne 0 ]; then + echo "::warning::Email sending failed but continuing with workflow" + fi + archery ci report-chat \ --ignore ${{ github.job }} \ --repository ${{ github.repository }} \ diff --git a/dev/archery/archery/ci/cli.py b/dev/archery/archery/ci/cli.py index ead3fb7c91e7..a874658d5442 100644 --- a/dev/archery/archery/ci/cli.py +++ b/dev/archery/archery/ci/cli.py @@ -17,8 +17,8 @@ import click -from .reports import WorkflowReport, ChatReport -from ..crossbow.reports import ReportUtils +from .core import Workflow +from ..crossbow.reports import ChatReport, EmailReport, ReportUtils @click.group() @@ -57,17 +57,70 @@ def report_chat(obj, workflow_id, send, repository, ignore, webhook, extra_message_success, extra_message_failure): """ Send a chat report to a webhook showing success/failure - of tasks in a Crossbow run. + of jobs in a workflow run. """ output = obj['output'] report_chat = ChatReport( - report=WorkflowReport(workflow_id, repository, - ignore_job=ignore, gh_token=obj['github_token']), + report=Workflow(workflow_id, repository, + ignore_job=ignore, gh_token=obj['github_token']), extra_message_success=extra_message_success, extra_message_failure=extra_message_failure ) if send: - ReportUtils.send_message(webhook, report_chat.render("text")) + ReportUtils.send_message(webhook, report_chat.render("workflow_report")) else: - output.write(report_chat.render("text")) + output.write(report_chat.render("workflow_report")) + + +@ci.command() +@click.argument('workflow_id', required=True) +@click.option('--sender-name', '-n', + help='Name to use for report e-mail.') +@click.option('--sender-email', '-e', + help='E-mail to use for report e-mail.') +@click.option('--recipient-email', '-r', + help='Where to send the e-mail report') +@click.option('--smtp-user', '-u', + help='E-mail address to use for SMTP login') +@click.option('--smtp-password', '-P', + help='SMTP password to use for report e-mail.') +@click.option('--smtp-server', '-s', default='smtp.gmail.com', + help='SMTP server to use for report e-mail.') +@click.option('--smtp-port', '-p', default=465, + help='SMTP port to use for report e-mail.') +@click.option('--send/--dry-run', default=False, + help='Just display the report, don\'t send it.') +@click.option('--repository', '-r', default='apache/arrow', + help='The repository where the workflow is located.') +@click.option('--ignore', '-i', default="", + help='Job name to ignore from the list of jobs.') +@click.pass_obj +def report_email(obj, workflow_id, sender_name, sender_email, recipient_email, + smtp_user, smtp_password, smtp_server, smtp_port, send, + repository, ignore): + """ + Send an email report showing success/failure of jobs in + a Workflow run + """ + output = obj['output'] + + email_report = EmailReport( + report=Workflow(workflow_id, repository, + ignore_job=ignore, gh_token=obj['github_token']), + sender_name=sender_name, + sender_email=sender_email, + recipient_email=recipient_email + ) + + if send: + ReportUtils.send_email( + smtp_user=smtp_user, + smtp_password=smtp_password, + smtp_server=smtp_server, + smtp_port=smtp_port, + recipient_email=recipient_email, + message=email_report.render("workflow_report") + ) + else: + output.write(email_report.render("workflow_report")) diff --git a/dev/archery/archery/crossbow/reports.py b/dev/archery/archery/crossbow/reports.py index 9f73845b9ac5..7a41afc272b6 100644 --- a/dev/archery/archery/crossbow/reports.py +++ b/dev/archery/archery/crossbow/reports.py @@ -217,6 +217,7 @@ def show(self, outstream, asset_callback=None, validate_patterns=True): class ChatReport(JinjaReport): templates = { 'text': 'chat_nightly_report.txt.j2', + 'workflow_report': 'chat_nightly_workflow_report.txt.j2', } fields = [ 'report', @@ -267,6 +268,7 @@ class EmailReport(JinjaReport): templates = { 'nightly_report': 'email_nightly_report.txt.j2', 'token_expiration': 'email_token_expiration.txt.j2', + 'workflow_report': 'email_workflow_report.txt.j2', } fields = [ 'report', diff --git a/dev/archery/archery/templates/chat_nightly_report_workflow.txt.j2 b/dev/archery/archery/templates/chat_nightly_workflow_report.txt.j2 similarity index 66% rename from dev/archery/archery/templates/chat_nightly_report_workflow.txt.j2 rename to dev/archery/archery/templates/chat_nightly_workflow_report.txt.j2 index 8332f2c28d3f..794b2f9060fe 100644 --- a/dev/archery/archery/templates/chat_nightly_report_workflow.txt.j2 +++ b/dev/archery/archery/templates/chat_nightly_workflow_report.txt.j2 @@ -16,23 +16,23 @@ # specific language governing permissions and limitations # under the License. #} -*Extra CI GitHub report for <{{ report.workflow.url }}|{{ report.workflow.name }}>* -{% if report.workflow.failed_jobs() %} -:x: *{{ report.workflow.failed_jobs() | length }} failed jobs* -{% for job in report.workflow.failed_jobs() -%} +*Extra CI GitHub report for <{{ report.url }}|{{ report.name }}>* +{% if report.failed_jobs() %} +:x: *{{ report.failed_jobs() | length }} failed jobs* +{% for job in report.failed_jobs() -%} - <{{ job.url }}|{{ job.name }}> {% endfor %} {%- endif -%} -{% if report.workflow.successful_jobs() %} +{% if report.successful_jobs() %} -:tada: *{{ report.workflow.successful_jobs() | length }} successful jobs* +:tada: *{{ report.successful_jobs() | length }} successful jobs* {%- endif -%} -{% if extra_message_success and not report.workflow.failed_jobs() %} +{% if extra_message_success and not report.failed_jobs() %} {{ extra_message_success }} {%- endif -%} -{% if extra_message_failure and report.workflow.failed_jobs() %} +{% if extra_message_failure and report.failed_jobs() %} {{ extra_message_failure }} {% endif %} \ No newline at end of file diff --git a/dev/archery/archery/ci/reports.py b/dev/archery/archery/templates/email_workflow_report.txt.j2 similarity index 57% rename from dev/archery/archery/ci/reports.py rename to dev/archery/archery/templates/email_workflow_report.txt.j2 index a10ee4541b8f..c77953cbb404 100644 --- a/dev/archery/archery/ci/reports.py +++ b/dev/archery/archery/templates/email_workflow_report.txt.j2 @@ -1,3 +1,4 @@ +{# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information @@ -14,24 +15,31 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +#} +{%- if True -%} +{%- endif -%} +From: {{ sender_name }} <{{ sender_email }}> +To: {{ recipient_email }} +Subject: [NIGHTLY] Arrow Build Report for {{ report.name }}: {{ report.failed_jobs() | length }} failed +Arrow Build Report for {{ report.name }} -from ..crossbow.reports import JinjaReport -from .core import Workflow +Workflow URL: {{ report.url }} +{% if report.failed_jobs() %} +Failed Jobs: -class WorkflowReport: - def __init__(self, workflow_id, repository, ignore_job, gh_token=None): - self.workflow = Workflow(workflow_id, repository=repository, - ignore_job=ignore_job, gh_token=gh_token) +{% for job in report.failed_jobs() -%} +- {{ job.name }} + {{ job.url }} +{% endfor %} +{% endif %} +{% if report.successful_jobs() %} +Succeeded Tasks: -class ChatReport(JinjaReport): - templates = { - 'text': 'chat_nightly_report_workflow.txt.j2', - } - fields = [ - 'report', - 'extra_message_success', - 'extra_message_failure', - ] +{% for job in report.successful_jobs() -%} +- {{ job.name }} + {{ job.url }} +{% endfor %} +{%- endif -%} \ No newline at end of file From fb20a16ffffb634973188e27b278a6fb4ec37267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Fri, 12 Sep 2025 10:51:39 +0200 Subject: [PATCH 14/22] add a couple comments and fix working by changing flag to -t instead of double -r --- .github/workflows/cpp_extra.yml | 2 ++ dev/archery/archery/ci/cli.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cpp_extra.yml b/.github/workflows/cpp_extra.yml index 89c18719cfbc..fce7c3d3c23a 100644 --- a/.github/workflows/cpp_extra.yml +++ b/.github/workflows/cpp_extra.yml @@ -308,6 +308,7 @@ jobs: SMTP_PASSWORD: ${{ secrets.ARROW_SMTP_PASSWORD }} run: | # Continue even if email sending fails + echo "Sending email report." set +e archery ci report-email \ --dry-run \ @@ -326,6 +327,7 @@ jobs: echo "::warning::Email sending failed but continuing with workflow" fi + echo "Sending Chat report." archery ci report-chat \ --ignore ${{ github.job }} \ --repository ${{ github.repository }} \ diff --git a/dev/archery/archery/ci/cli.py b/dev/archery/archery/ci/cli.py index a874658d5442..a6b1156647ab 100644 --- a/dev/archery/archery/ci/cli.py +++ b/dev/archery/archery/ci/cli.py @@ -79,7 +79,7 @@ def report_chat(obj, workflow_id, send, repository, ignore, webhook, help='Name to use for report e-mail.') @click.option('--sender-email', '-e', help='E-mail to use for report e-mail.') -@click.option('--recipient-email', '-r', +@click.option('--recipient-email', '-t', help='Where to send the e-mail report') @click.option('--smtp-user', '-u', help='E-mail address to use for SMTP login') From 77ff3c56badc07490addaf08341929330a47f001 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Fri, 12 Sep 2025 11:46:02 +0200 Subject: [PATCH 15/22] Fix SMTP server --- dev/archery/archery/ci/cli.py | 2 +- dev/archery/archery/crossbow/reports.py | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/dev/archery/archery/ci/cli.py b/dev/archery/archery/ci/cli.py index a6b1156647ab..bf7b68d5327a 100644 --- a/dev/archery/archery/ci/cli.py +++ b/dev/archery/archery/ci/cli.py @@ -83,7 +83,7 @@ def report_chat(obj, workflow_id, send, repository, ignore, webhook, help='Where to send the e-mail report') @click.option('--smtp-user', '-u', help='E-mail address to use for SMTP login') -@click.option('--smtp-password', '-P', +@click.option('--smtp-password', '-P', envvar=['SMTP_PASSWORD'], help='SMTP password to use for report e-mail.') @click.option('--smtp-server', '-s', default='smtp.gmail.com', help='SMTP server to use for report e-mail.') diff --git a/dev/archery/archery/crossbow/reports.py b/dev/archery/archery/crossbow/reports.py index 7a41afc272b6..ea2bce817086 100644 --- a/dev/archery/archery/crossbow/reports.py +++ b/dev/archery/archery/crossbow/reports.py @@ -247,13 +247,12 @@ def send_message(cls, webhook, message): @classmethod def send_email(cls, smtp_user, smtp_password, smtp_server, smtp_port, recipient_email, message): - import smtplib + from smtplib import SMTP - server = smtplib.SMTP_SSL(smtp_server, smtp_port) - server.ehlo() - server.login(smtp_user, smtp_password) - server.sendmail(smtp_user, recipient_email, message) - server.close() + with SMTP(smtp_server, smtp_port) as smtp: + smtp.starttls() + smtp.login(smtp_user, smtp_password) + smtp.sendmail(smtp_user, recipient_email, message) @classmethod def write_csv(cls, report, add_headers=True): From 04a0abd081741f003d0f75bc179bafc40fdbf787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Fri, 12 Sep 2025 11:54:57 +0200 Subject: [PATCH 16/22] Fix being able to end emails to port 587 --- .github/workflows/cpp_extra.yml | 1 + dev/archery/archery/crossbow/reports.py | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cpp_extra.yml b/.github/workflows/cpp_extra.yml index fce7c3d3c23a..093124e41ab4 100644 --- a/.github/workflows/cpp_extra.yml +++ b/.github/workflows/cpp_extra.yml @@ -317,6 +317,7 @@ jobs: --sender-email 'arrow@commit-email.info' \ --recipient-email 'builds@arrow.apache.org' \ --smtp-user arrow \ + --smtp-port 587 \ --ignore ${{ github.job }} \ --repository ${{ github.repository }} \ ${{ github.run_id }} diff --git a/dev/archery/archery/crossbow/reports.py b/dev/archery/archery/crossbow/reports.py index ea2bce817086..32962410d6e7 100644 --- a/dev/archery/archery/crossbow/reports.py +++ b/dev/archery/archery/crossbow/reports.py @@ -247,10 +247,17 @@ def send_message(cls, webhook, message): @classmethod def send_email(cls, smtp_user, smtp_password, smtp_server, smtp_port, recipient_email, message): - from smtplib import SMTP + from smtplib import SMTP, SMTP_SSL - with SMTP(smtp_server, smtp_port) as smtp: - smtp.starttls() + if smtp_port == 465: + smtp_cls = SMTP_SSL + else: + smtp_cls = SMTP + with smtp_cls(smtp_server, smtp_port) as smtp: + if smtp_port == 465: + smtp.ehlo() + else: + smtp.starttls() smtp.login(smtp_user, smtp_password) smtp.sendmail(smtp_user, recipient_email, message) From 08c643df4e72fcc1d6e03de75a5567dea7e9dc0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Fri, 12 Sep 2025 11:56:46 +0200 Subject: [PATCH 17/22] Minor template fix --- dev/archery/archery/templates/email_workflow_report.txt.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/archery/archery/templates/email_workflow_report.txt.j2 b/dev/archery/archery/templates/email_workflow_report.txt.j2 index c77953cbb404..b08b4d3ffc71 100644 --- a/dev/archery/archery/templates/email_workflow_report.txt.j2 +++ b/dev/archery/archery/templates/email_workflow_report.txt.j2 @@ -36,7 +36,7 @@ Failed Jobs: {% endif %} {% if report.successful_jobs() %} -Succeeded Tasks: +Succeeded Jobs: {% for job in report.successful_jobs() -%} - {{ job.name }} From bdb577de1c55d62b978e25178a0d415ce425a07c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Fri, 12 Sep 2025 16:07:08 +0200 Subject: [PATCH 18/22] Try sending email + zulip notification --- .github/workflows/cpp_extra.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cpp_extra.yml b/.github/workflows/cpp_extra.yml index 093124e41ab4..ffeb0cfada09 100644 --- a/.github/workflows/cpp_extra.yml +++ b/.github/workflows/cpp_extra.yml @@ -311,7 +311,7 @@ jobs: echo "Sending email report." set +e archery ci report-email \ - --dry-run \ + --send \ --smtp-server 'commit-email.info' \ --sender-name Arrow \ --sender-email 'arrow@commit-email.info' \ @@ -332,5 +332,5 @@ jobs: archery ci report-chat \ --ignore ${{ github.job }} \ --repository ${{ github.repository }} \ - --dry-run \ + --send \ ${{ github.run_id }} From 97c0d8556c01cee7cf1f2c9af51bfb666f4842d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Fri, 12 Sep 2025 16:27:18 +0200 Subject: [PATCH 19/22] Add schedule check --- .github/workflows/cpp_extra.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cpp_extra.yml b/.github/workflows/cpp_extra.yml index ffeb0cfada09..3f03f6b66f45 100644 --- a/.github/workflows/cpp_extra.yml +++ b/.github/workflows/cpp_extra.yml @@ -289,7 +289,7 @@ jobs: # We match github.job to the name so we can pass it via context in order to be ignored on the report. # The job is still running. name: ${{ github.job }} - if: always() + if: github.event_name == 'schedule' && always() steps: - name: Checkout Arrow uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 From e3f8b9c690a619da4f76122198e13d8adb8a6bd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Mon, 15 Sep 2025 09:44:45 +0200 Subject: [PATCH 20/22] Split email and chat steps and order arguments alphabetically --- .github/workflows/cpp_extra.yml | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/.github/workflows/cpp_extra.yml b/.github/workflows/cpp_extra.yml index 3f03f6b66f45..001db5e78f6f 100644 --- a/.github/workflows/cpp_extra.yml +++ b/.github/workflows/cpp_extra.yml @@ -301,34 +301,28 @@ jobs: python-version: 3 - name: Setup Archery run: python3 -m pip install -e dev/archery[crossbow] - - name: Notify + - name: Send email env: GH_TOKEN: ${{ github.token }} - CHAT_WEBHOOK: ${{ secrets.ARROW_ZULIP_WEBHOOK }} SMTP_PASSWORD: ${{ secrets.ARROW_SMTP_PASSWORD }} run: | - # Continue even if email sending fails - echo "Sending email report." - set +e archery ci report-email \ + --ignore ${{ github.job }} \ + --recipient-email 'builds@arrow.apache.org' \ + --repository ${{ github.repository }} \ --send \ - --smtp-server 'commit-email.info' \ - --sender-name Arrow \ --sender-email 'arrow@commit-email.info' \ - --recipient-email 'builds@arrow.apache.org' \ - --smtp-user arrow \ + --sender-name Arrow \ --smtp-port 587 \ - --ignore ${{ github.job }} \ - --repository ${{ github.repository }} \ + --smtp-server 'commit-email.info' \ + --smtp-user arrow \ ${{ github.run_id }} - email_exit_code=$? - set -e - - if [ $email_exit_code -ne 0 ]; then - echo "::warning::Email sending failed but continuing with workflow" - fi - - echo "Sending Chat report." + - name: Send chat message + if: always() + env: + GH_TOKEN: ${{ github.token }} + CHAT_WEBHOOK: ${{ secrets.ARROW_ZULIP_WEBHOOK }} + run: | archery ci report-chat \ --ignore ${{ github.job }} \ --repository ${{ github.repository }} \ From edfaab4637150e0ba262ce793b7e03e0dd7cba87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Mon, 15 Sep 2025 10:05:31 +0200 Subject: [PATCH 21/22] Temporarily remove check for event_name to validate chat report step is executed even if email fails --- .github/workflows/cpp_extra.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cpp_extra.yml b/.github/workflows/cpp_extra.yml index 001db5e78f6f..32822f1470e9 100644 --- a/.github/workflows/cpp_extra.yml +++ b/.github/workflows/cpp_extra.yml @@ -289,7 +289,7 @@ jobs: # We match github.job to the name so we can pass it via context in order to be ignored on the report. # The job is still running. name: ${{ github.job }} - if: github.event_name == 'schedule' && always() + if: always() steps: - name: Checkout Arrow uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 From 44cd0dc272542defe1c944b904005027017c08d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Mon, 15 Sep 2025 10:16:00 +0200 Subject: [PATCH 22/22] Add schedule check again --- .github/workflows/cpp_extra.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cpp_extra.yml b/.github/workflows/cpp_extra.yml index 32822f1470e9..001db5e78f6f 100644 --- a/.github/workflows/cpp_extra.yml +++ b/.github/workflows/cpp_extra.yml @@ -289,7 +289,7 @@ jobs: # We match github.job to the name so we can pass it via context in order to be ignored on the report. # The job is still running. name: ${{ github.job }} - if: always() + if: github.event_name == 'schedule' && always() steps: - name: Checkout Arrow uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0