Skip to content
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/cc_bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -eux
python tests/scripts/github_cc_reviewers.py
python tests/scripts/github_cc_reviewers.py || echo step failed
6 changes: 3 additions & 3 deletions tests/scripts/git_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def graphql(self, query: str) -> Dict[str, Any]:
return self._post("https://api.github.com/graphql", {"query": query})

def _post(self, full_url: str, body: Dict[str, Any]) -> Dict[str, Any]:
print("Requesting", full_url)
print("Requesting POST to", full_url, "with", body)
req = request.Request(full_url, headers=self.headers(), method="POST")
req.add_header("Content-Type", "application/json; charset=utf-8")
data = json.dumps(body)
Expand All @@ -55,15 +55,15 @@ def post(self, url: str, data: Dict[str, Any]) -> Dict[str, Any]:

def get(self, url: str) -> Dict[str, Any]:
url = self.base + url
print("Requesting", url)
print("Requesting GET to", url)
req = request.Request(url, headers=self.headers())
with request.urlopen(req) as response:
response = json.loads(response.read())
return response

def delete(self, url: str) -> Dict[str, Any]:
url = self.base + url
print("Requesting", url)
print("Requesting DELETE to", url)
req = request.Request(url, headers=self.headers(), method="DELETE")
with request.urlopen(req) as response:
response = json.loads(response.read())
Expand Down
10 changes: 9 additions & 1 deletion tests/scripts/github_cc_reviewers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import json
import argparse
import re
from urllib import error
from typing import Dict, Any, List


Expand Down Expand Up @@ -70,4 +71,11 @@ def find_reviewers(body: str) -> List[str]:

if not args.dry_run:
github = GitHubRepo(token=os.environ["GITHUB_TOKEN"], user=user, repo=repo)
github.post(f"pulls/{number}/requested_reviewers", {"reviewers": to_add})

# Add reviewers 1 by 1 since GitHub will error out if any of the
# requested reviewers aren't members / contributors
for reviewer in to_add:
try:
github.post(f"pulls/{number}/requested_reviewers", {"reviewers": [reviewer]})
except error.HTTPError as e:
print(f"Failed to add reviewer {reviewer}: {e}")