Skip to content

Commit 8cedff5

Browse files
committed
GH-48623: [CI][Archery][Dev] Add missing headers to email reports
1 parent 42043c8 commit 8cedff5

File tree

8 files changed

+53
-25
lines changed

8 files changed

+53
-25
lines changed

dev/archery/archery/ci/cli.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# under the License.
1717

1818
import click
19+
import email.utils
1920

2021
from .core import Workflow
2122
from ..crossbow.reports import ChatReport, EmailReport, ReportUtils
@@ -105,12 +106,15 @@ def report_email(obj, workflow_id, sender_name, sender_email, recipient_email,
105106
"""
106107
output = obj['output']
107108

109+
workflow = Workflow(workflow_id, repository,
110+
ignore_job=ignore, gh_token=obj['github_token'])
108111
email_report = EmailReport(
109-
report=Workflow(workflow_id, repository,
110-
ignore_job=ignore, gh_token=obj['github_token']),
111-
sender_name=sender_name,
112+
date=email.utils.formatdate(workflow.datetime),
113+
message_id=email.utils.make_msgid(),
114+
recipient_email=recipient_email,
115+
report=workflow,
112116
sender_email=sender_email,
113-
recipient_email=recipient_email
117+
sender_name=sender_name,
114118
)
115119

116120
if send:

dev/archery/archery/crossbow/cli.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# under the License.
1717

1818
from datetime import date
19+
import email.utils
1920
from pathlib import Path
2021
import time
2122
import sys
@@ -382,11 +383,14 @@ def report(obj, job_name, sender_name, sender_email, recipient_email,
382383
queue.fetch()
383384

384385
job = queue.get(job_name)
386+
report = Report(job)
385387
email_report = EmailReport(
386-
report=Report(job),
387-
sender_name=sender_name,
388+
date=email.utils.formatdate(),
389+
message_id=email.utils.make_msgid(),
390+
recipient_email=recipient_email,
391+
report=report,
388392
sender_email=sender_email,
389-
recipient_email=recipient_email
393+
sender_name=sender_name,
390394
)
391395

392396
if poll:
@@ -645,15 +649,18 @@ def __init__(self, token_expiration_date, days_left):
645649
self.token_expiration_date = token_expiration_date
646650
self.days_left = days_left
647651

652+
report = TokenExpirationReport(
653+
token_expiration_date or "ALREADY_EXPIRED", days_left)
648654
email_report = EmailReport(
649-
report=TokenExpirationReport(
650-
token_expiration_date or "ALREADY_EXPIRED", days_left),
651-
sender_name=sender_name,
655+
date=email.utils.formatdate(),
656+
message_id=email.utils.make_msgid(),
657+
recipient_email=recipient_email,
658+
report=report,
652659
sender_email=sender_email,
653-
recipient_email=recipient_email
660+
sender_name=sender_name,
654661
)
655662

656-
message = email_report.render("token_expiration").strip()
663+
message = email_report.render("token_expiration")
657664
if send:
658665
ReportUtils.send_email(
659666
smtp_user=smtp_user,

dev/archery/archery/crossbow/reports.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,12 @@ class EmailReport(JinjaReport):
277277
'workflow_report': 'email_workflow_report.txt.j2',
278278
}
279279
fields = [
280+
'date',
281+
'message_id',
282+
'recipient_email',
280283
'report',
281-
'sender_name',
282284
'sender_email',
283-
'recipient_email',
285+
'sender_name',
284286
]
285287

286288

dev/archery/archery/crossbow/tests/fixtures/email-report.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
MIME-Version: 1.0
2+
Content-Type: text/plain; charset="utf-8"
3+
Message-Id: <[email protected]>
4+
Date: Mon, 22 Dec 2025 22:12:00 -0000
15
From: Sender Reporter <[email protected]>
26
37
Subject: [NIGHTLY] Arrow Build Report for Job ursabot-1: 2 failed, 1 pending

dev/archery/archery/crossbow/tests/test_reports.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,12 @@ def test_crossbow_email_report(load_fixture):
7676
job = load_fixture('crossbow-job.yaml', decoder=yaml.load)
7777
report = Report(job)
7878
assert report.tasks_by_state is not None
79-
email_report = EmailReport(report=report, sender_name="Sender Reporter",
79+
email_report = EmailReport(date="Mon, 22 Dec 2025 22:12:00 -0000",
80+
message_id="<[email protected]>",
81+
recipient_email="[email protected]",
82+
report=report,
8083
sender_email="[email protected]",
81-
recipient_email="[email protected]")
84+
sender_name="Sender Reporter")
8285

8386
assert (
8487
email_report.render("nightly_report") == textwrap.dedent(expected_msg)

dev/archery/archery/templates/email_nightly_report.txt.j2

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
# KIND, either express or implied. See the License for the
1616
# specific language governing permissions and limitations
1717
# under the License.
18-
#}
19-
{%- if True -%}
20-
{%- endif -%}
18+
-#}
19+
MIME-Version: 1.0
20+
Content-Type: text/plain; charset="utf-8"
21+
Message-Id: {{ message_id }}
22+
Date: {{ date }}
2123
From: {{ sender_name }} <{{ sender_email }}>
2224
To: {{ recipient_email }}
2325
Subject: [NIGHTLY] Arrow Build Report for Job {{report.job.branch}}: {{ (report.tasks_by_state["error"] | length) + (report.tasks_by_state["failure"] | length) }} failed, {{ report.tasks_by_state["pending"] | length }} pending
@@ -58,4 +60,4 @@ Succeeded Tasks:
5860
- {{ task_name }}
5961
{{ report.task_url(task) }}
6062
{% endfor %}
61-
{%- endif -%}
63+
{%- endif -%}

dev/archery/archery/templates/email_token_expiration.txt.j2

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
# KIND, either express or implied. See the License for the
1616
# specific language governing permissions and limitations
1717
# under the License.
18-
#}
18+
-#}
19+
MIME-Version: 1.0
20+
Content-Type: text/plain; charset="utf-8"
21+
Message-Id: {{ message_id }}
22+
Date: {{ date }}
1923
From: {{ sender_name }} <{{ sender_email }}>
2024
To: {{ recipient_email }}
2125
Subject: [CI] Arrow Crossbow Token Expiration in {{ report.token_expiration_date }}

dev/archery/archery/templates/email_workflow_report.txt.j2

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
# KIND, either express or implied. See the License for the
1616
# specific language governing permissions and limitations
1717
# under the License.
18-
#}
19-
{%- if True -%}
20-
{%- endif -%}
18+
-#}
19+
MIME-Version: 1.0
20+
Content-Type: text/plain; charset="utf-8"
21+
Message-Id: {{ message_id }}
22+
Date: {{ date }}
2123
From: {{ sender_name }} <{{ sender_email }}>
2224
To: {{ recipient_email }}
2325
Subject: [{{ report.datetime.strftime('%Y-%m-%d') }}] Arrow Build Report for {{ report.name }}: {{ report.failed_jobs() | length }} failed
@@ -42,4 +44,4 @@ Succeeded Jobs:
4244
- {{ job.name }}
4345
{{ job.url }}
4446
{% endfor %}
45-
{%- endif -%}
47+
{%- endif -%}

0 commit comments

Comments
 (0)