Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ask-review): Add the requester to the ask-review message #32616

Merged
merged 2 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/label-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ jobs:
run: inv -e github.agenttelemetry-list-change-ack-check --pr-id=${{ github.event.pull_request.number }}

ask-reviews:
if: github.triggering_actor != 'dd-devflow[bot]' && github.event.action != 'synchronize'
if: github.triggering_actor != 'dd-devflow[bot]' && github.event.action == 'labeled' && github.event.label.name == 'ask-review'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand Down
7 changes: 4 additions & 3 deletions tasks/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from invoke import task

from tasks.libs.ciproviders.github_api import GithubAPI
from tasks.libs.ciproviders.github_api import GithubAPI, ask_review_actor
from tasks.libs.issue.assign import assign_with_model, assign_with_rules
from tasks.libs.issue.model.actions import fetch_data_and_train_model
from tasks.libs.pipeline.notifications import GITHUB_SLACK_MAP, GITHUB_SLACK_REVIEW_MAP
Expand Down Expand Up @@ -82,6 +82,7 @@ def ask_reviews(_, pr_id):
gh = GithubAPI()
pr = gh.repo.get_pull(int(pr_id))
if any(label.name == 'ask-review' for label in pr.get_labels()):
actor = ask_review_actor(pr)
reviewers = [f"@datadog/{team.slug}" for team in pr.requested_teams]

from slack_sdk import WebClient
Expand All @@ -92,11 +93,11 @@ def ask_reviews(_, pr_id):
(chan for team, chan in GITHUB_SLACK_REVIEW_MAP.items() if team.casefold() == reviewer.casefold()),
'#agent-devx-help',
)
message = f'Hello :{random.choice(WAVES)}:! Can you please review <{pr.html_url}/s|{pr.title}>?\n Thanks in advance!'
message = f'Hello :{random.choice(WAVES)}:!\n*{actor}* would like you to review <{pr.html_url}/s|{pr.title}>?\nThanks in advance!'
if channel == '#agent-devx-help':
message = f'Hello :{random.choice(WAVES)}:!\nA review channel is missing for {reviewer}, can you please ask them to update `github_slack_review_map.yaml` and transfer them this review <{pr.html_url}/s|{pr.title}>?\n Thanks in advance!'
try:
client.chat_postMessage(channel=channel, text=message)
except Exception as e:
message = f"An error occurred while sending a review message for PR <{pr.html_url}/s|{pr.title}> to channel {channel}. Error: {e}"
message = f"An error occurred while sending a review message from {actor} for PR <{pr.html_url}/s|{pr.title}> to channel {channel}. Error: {e}"
client.chat_postMessage(channel='#agent-devx-ops', text=message)
6 changes: 6 additions & 0 deletions tasks/libs/ciproviders/github_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,3 +654,9 @@ def create_release_pr(title, base_branch, target_branch, version, changelog_pr=F
print(color_message(f"Done creating new PR. Link: {updated_pr.html_url}", "bold"))

return updated_pr.html_url


def ask_review_actor(pr):
for event in pr.get_issue_events():
if event.event == "labeled" and event.label.name == "ask-review":
return event.actor.name or event.actor.login
Loading