mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
ci: Remove reviewer assignment in the PR triaging agent
PiperOrigin-RevId: 823255296
This commit is contained in:
committed by
Copybara-Service
parent
0660779ff0
commit
0d0fb4d034
@@ -27,18 +27,18 @@ from adk_pr_triaging_agent.utils import run_graphql_query
|
||||
from google.adk import Agent
|
||||
import requests
|
||||
|
||||
LABEL_TO_OWNER = {
|
||||
"documentation": "polong-lin",
|
||||
"services": "DeanChensj",
|
||||
"tools": "seanzhou1023",
|
||||
"mcp": "seanzhou1023",
|
||||
"eval": "ankursharmas",
|
||||
"live": "hangfei",
|
||||
"models": "genquan9",
|
||||
"tracing": "Jacksunwei",
|
||||
"core": "Jacksunwei",
|
||||
"web": "wyf7107",
|
||||
}
|
||||
ALLOWED_LABELS = [
|
||||
"documentation",
|
||||
"services",
|
||||
"tools",
|
||||
"mcp",
|
||||
"eval",
|
||||
"live",
|
||||
"models",
|
||||
"tracing",
|
||||
"core",
|
||||
"web",
|
||||
]
|
||||
|
||||
CONTRIBUTING_MD = read_file(
|
||||
Path(__file__).resolve().parents[3] / "CONTRIBUTING.md"
|
||||
@@ -158,19 +158,19 @@ def get_pull_request_details(pr_number: int) -> str:
|
||||
return error_response(str(e))
|
||||
|
||||
|
||||
def add_label_and_reviewer_to_pr(pr_number: int, label: str) -> dict[str, Any]:
|
||||
"""Adds a specified label and requests a review from a mapped reviewer on a PR.
|
||||
def add_label_to_pr(pr_number: int, label: str) -> dict[str, Any]:
|
||||
"""Adds a specified label on a pull request.
|
||||
|
||||
Args:
|
||||
pr_number: the number of the Github pull request
|
||||
label: the label to add
|
||||
|
||||
Returns:
|
||||
The the status of this request, with the applied label and assigned
|
||||
reviewer when successful.
|
||||
The the status of this request, with the applied label and response when
|
||||
successful.
|
||||
"""
|
||||
print(f"Attempting to add label '{label}' and a reviewer to PR #{pr_number}")
|
||||
if label not in LABEL_TO_OWNER:
|
||||
print(f"Attempting to add label '{label}' to PR #{pr_number}")
|
||||
if label not in ALLOWED_LABELS:
|
||||
return error_response(
|
||||
f"Error: Label '{label}' is not an allowed label. Will not apply."
|
||||
)
|
||||
@@ -186,31 +186,10 @@ def add_label_and_reviewer_to_pr(pr_number: int, label: str) -> dict[str, Any]:
|
||||
except requests.exceptions.RequestException as e:
|
||||
return error_response(f"Error: {e}")
|
||||
|
||||
owner = LABEL_TO_OWNER.get(label, None)
|
||||
if not owner:
|
||||
return {
|
||||
"status": "warning",
|
||||
"message": (
|
||||
f"{response}\n\nLabel '{label}' does not have an owner. Will not"
|
||||
" assign."
|
||||
),
|
||||
"applied_label": label,
|
||||
}
|
||||
reviewer_url = f"{GITHUB_BASE_URL}/repos/{OWNER}/{REPO}/pulls/{pr_number}/requested_reviewers"
|
||||
reviewer_payload = {"reviewers": [owner]}
|
||||
try:
|
||||
post_request(reviewer_url, reviewer_payload)
|
||||
except requests.exceptions.RequestException as e:
|
||||
return {
|
||||
"status": "warning",
|
||||
"message": f"Reviewer not assigned: {e}",
|
||||
"applied_label": label,
|
||||
}
|
||||
|
||||
return {
|
||||
"status": "success",
|
||||
"applied_label": label,
|
||||
"assigned_reviewer": owner,
|
||||
"response": response,
|
||||
}
|
||||
|
||||
|
||||
@@ -252,7 +231,6 @@ root_agent = Agent(
|
||||
Your core responsibility includes:
|
||||
- Get the pull request details.
|
||||
- Add a label to the pull request.
|
||||
- Assign a reviewer to the pull request.
|
||||
- Check if the pull request is following the contribution guidelines.
|
||||
- Add a comment to the pull request if it's not following the guidelines.
|
||||
|
||||
@@ -303,7 +281,7 @@ root_agent = Agent(
|
||||
- Skip the PR (i.e. do not label or comment) if any of the following is true:
|
||||
- the PR is closed
|
||||
- the PR is labeled with "google-contributior"
|
||||
- the PR is already labelled with the above labels (e.g. "documentation", "services", "tools", etc.) and has a reviewer assigned.
|
||||
- the PR is already labelled with the above labels (e.g. "documentation", "services", "tools", etc.).
|
||||
- Check if the PR is following the contribution guidelines.
|
||||
- If it's not following the guidelines, recommend or add a comment to the PR that points to the contribution guidelines (https://github.com/google/adk-python/blob/main/CONTRIBUTING.md).
|
||||
- If it's following the guidelines, recommend or add a label to the PR.
|
||||
@@ -312,12 +290,11 @@ root_agent = Agent(
|
||||
Present the followings in an easy to read format highlighting PR number and your label.
|
||||
- The PR summary in a few sentence
|
||||
- The label you recommended or added with the justification
|
||||
- The owner of the label if you assigned a reviewer to the PR
|
||||
- The comment you recommended or added to the PR with the justification
|
||||
""",
|
||||
tools=[
|
||||
get_pull_request_details,
|
||||
add_label_and_reviewer_to_pr,
|
||||
add_label_to_pr,
|
||||
add_comment_to_pr,
|
||||
],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user