Skip to content

Commit

Permalink
Use upstream conversation subject for CI emails
Browse files Browse the repository at this point in the history
Summary:
We have had requests to use the subject of the upstream discussion when sending
BPF CI email messages. The reason being that Gmail doesn't thread emails
properly once the subject changes [0] -- and so our indication of
failure/success and other goodies in the subject cause it to keep any CI emails
separate from the main discussion.
With this change we switch over to using the upstream subject, similar to what
bots such as kernel test robot do [1].

[0] https://support.google.com/mail/answer/5900
[1] https://lore.kernel.org/all/ZRkI4j2+dXZ9sjQ4@f61ccfac960a/

Reviewed By: chantra

Differential Revision: D51139610

fbshipit-source-id: 63aa1bc27bfc5493ded14f7c1498822186b1490a
  • Loading branch information
danielocfb-test authored and facebook-github-bot committed Nov 9, 2023
1 parent 4babf15 commit 6e15985
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions kernel_patches_daemon/branch_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

import asyncio
import copy
import email
import email.parser
import email.policy
import hashlib
import logging
import os
Expand Down Expand Up @@ -173,6 +176,15 @@ def get_github_actions_url(repo: Repository, pr: PullRequest, status: Status) ->
return github_actions_url


async def get_ci_email_subject(series: Series) -> str:
"""Get the subject to use for a CI email pertaining the given series."""
obj = get_ci_base(series)
patch = await series.pw_client.get_blob(obj["mbox"])
parser = email.parser.BytesParser(policy=email.policy.default)
msg = parser.parsebytes(patch, headersonly=True)
return f"Re: {msg.get('subject', series.name)}"


def furnish_ci_email_body(
repo: Repository, pr: PullRequest, status: Status, series: Series
) -> str:
Expand Down Expand Up @@ -1001,13 +1013,12 @@ async def evaluate_ci_result(
if status == Status.SUCCESS:
new_label = StatusLabelSuffixes.PASS.to_label(series.version)
not_label = StatusLabelSuffixes.FAIL.to_label(series.version)
subject = f"BPF CI -- success ({series.name})"
else:
assert status in (Status.FAILURE, Status.CONFLICT), status
new_label = StatusLabelSuffixes.FAIL.to_label(series.version)
not_label = StatusLabelSuffixes.PASS.to_label(series.version)
subject = f"BPF CI -- failure ({series.name})"

subject = await get_ci_email_subject(series)
body = furnish_ci_email_body(self.repo, pr, status, series)

labels = {label.name for label in pr.labels}
Expand Down

0 comments on commit 6e15985

Please sign in to comment.