KAFKA-20362: Auto-fill PR reviewers in PR description#21928
KAFKA-20362: Auto-fill PR reviewers in PR description#21928chia7712 merged 2 commits intoapache:trunkfrom
Conversation
| return email.lower() in [e.lower() for e in existing_emails] | ||
|
|
||
|
|
||
| def update_reviewers_trailer(body: str, trailer: str) -> str: |
There was a problem hiding this comment.
what happens if there are two reviewers adding the comment concurrently?
There was a problem hiding this comment.
Each review comment triggers an independent pr-reviewed workflow run with its own workflow_run.id, so pr-format.py correctly receives each reviewer's login separately via its own artifact. The only possible race condition is if two pr-format.py runs read and update the PR body at the same time — the second write could overwrite the first, losing a reviewer. The race window is only between reading the PR body and writing it back in pr-format.py, which is a short window. Even if it does happen, the lost reviewer will be re-added on their next review comment. If we want to eliminate this entirely, we can add a concurrency group to pr-linter.yml to serialize runs per PR.
There was a problem hiding this comment.
I guess the worst that happens is an unlucky reviewer gets dropped?
|
I've tested in my fork. It works well |
When a pull request **submit review** event is triggered (comment,
request changes, or approval), this change automatically adds the
reviewer to the Reviewers trailer in the PR body.
Note that **comment** will **NOT** trigger the auto-fill process.
This eliminates the need to manually run committer-tools/reviewers.py
before merging. The reviewer's name and email are resolved from their
most recent commit in the repo, falling back to their GitHub profile.
Changes:
- pr-reviewed.yml: save reviewer login to artifact on review events
- pr-linter.yml: pass reviewer login to pr-format.py
- pr-format.py: resolve reviewer identity via GitHub API and append
to the Reviewers trailer using git interpret-trailers
Testing:
```
$ python -c "
from importlib.machinery import SourceFileLoader
m = SourceFileLoader('pr_format',
'.github/scripts/pr-format.py').load_module()
print(m.resolve_reviewer('mingyen066'))
print(m.resolve_reviewer('antirez'))
print(m.resolve_reviewer('torvalds'))
"
# Tier 1 hit: found name and email from repo commit history
('Ming-Yen Chung', 'mingyen066@gmail.com')
# Tier 1 miss, Tier 2 hit: found email from GitHub profile
('Salvatore Sanfilippo', 'antirez@gmail.com')
# Both miss email: placeholder used for committer to fix manually
('Linus Torvalds', 'torvalds-email-not-found')
$ python -c " from importlib.machinery import SourceFileLoader m =
SourceFileLoader('pr_format',
'.github/scripts/pr-format.py').load_module() existing = ['Chia-Ping
Tsai <chia7712@gmail.com>, Ming-Yen Chung <mingyen066@gmail.com>']
print(m.already_exists('chia7712@gmail.com', existing))
print(m.already_exists('someone@gmail.com', existing))
print(m.already_exists('Chia7712@Gmail.com', existing)) " True False
True
$ python -c " from importlib.machinery import SourceFileLoader m =
SourceFileLoader('pr_format',
'.github/scripts/pr-format.py').load_module() body = 'This is a PR
description.\n' result = m.update_reviewers_trailer(body, 'Reviewers:
Alice <alice@test.com>') print(result) " This is a PR description.
Reviewers: Alice <alice@test.com>
```
Reviewers: TaiJuWu <tjwu1217@gmail.com>, Chia-Ping Tsai
<chia7712@gmail.com>
|
I just notice that we get This is not helpful at all. I need to update this manually anyway. |
|
@mjsax Sorry for the noise. I'll fix it right away. |
|
@UladzislauBlok Out of curiosity—since your email is hidden on your GitHub profile, are you okay with using your real email for the commit message? I know we can find it in your commit history anyway, but I wanted to check if you'd prefer to keep it private |

When a pull request submit review event is triggered (comment,
request changes, or approval), this change automatically adds the
reviewer to the Reviewers trailer in the PR body.
Note that comment will NOT trigger the auto-fill process.
This eliminates the need to manually run committer-tools/reviewers.py
before merging. The reviewer's name and email are resolved from their
most recent commit in the repo, falling back to their GitHub profile.
Changes:
to the Reviewers trailer using git interpret-trailers
Testing:
Reviewers: TaiJuWu tjwu1217@gmail.com, Chia-Ping Tsai
chia7712@gmail.com