Skip to content

Commit 4a2176f

Browse files
BigCat20196msyycRAY-316
authored
[Release helper] add assign policy (Azure#23723)
* update for Go * check tag consistency and optize reply * add write.md * update go js readme * update * Update common.py * Update common.py * update assignee for JS * update * update * Update common.py * Update common.py * Update release_helper.yml for Azure Pipelines * Update common.py * update * Update common.py * Update common.py * Update main.py * update * update bot advice * update * update * update excel * update output function * add exception handle for bad credential * fix static varaible in class * update auto_assignee algorithm * update bot token to have a try * update bot token * force to single process * test * test * test * test * fix bug * fix * update release_helper/js * update release_helper/js * fix bug * update release helper * Update js.py * Update js.py * Update js.py Co-authored-by: msyyc <[email protected]> Co-authored-by: Zed <[email protected]> Co-authored-by: Yiming Lei <[email protected]> Co-authored-by: Yuchao Yan <[email protected]>
1 parent 46f67e3 commit 4a2176f

File tree

3 files changed

+19
-24
lines changed

3 files changed

+19
-24
lines changed

scripts/release_helper/common.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,17 @@ def request_repo(self) -> Repository:
194194
def update_issue_instance(self) -> None:
195195
self.issue_package.issue = self.request_repo().get_issue(self.issue_package.issue.number)
196196

197+
def auto_assign_policy(self) -> str:
198+
assignees = list(self.assignee_candidates)
199+
random_idx = randint(0, len(assignees) - 1) if len(assignees) > 1 else 0
200+
return assignees[random_idx]
201+
197202
def auto_assign(self) -> None:
198203
if AUTO_ASSIGN_LABEL in self.issue_package.labels_name:
199204
self.update_issue_instance()
200205
return
201206
# assign averagely
202-
assignees = list(self.assignee_candidates)
203-
random_idx = randint(0, len(assignees) - 1) if len(assignees) > 1 else 0
204-
assignee = assignees[random_idx]
207+
assignee = self.auto_assign_policy()
205208

206209
# update assignee
207210
if self.assignee != assignee:
@@ -292,6 +295,7 @@ def __init__(self, issues_package: List[IssuePackage], assignee_token: Dict[str,
292295
self.package_name = ''
293296
self.result = []
294297
self.request_repo_dict = {}
298+
self.issue_process_function = IssueProcess
295299

296300
for assignee in assignee_token:
297301
self.request_repo_dict[assignee] = Github(assignee_token[assignee]).get_repo(REQUEST_REPO)
@@ -330,7 +334,7 @@ def output_md(item: IssueProcess):
330334
def run(self):
331335
items = []
332336
for item in self.issues_package:
333-
issue = IssueProcess(item, self.request_repo_dict, self.assignee_candidates, self.language_owner)
337+
issue = self.issue_process_function(item, self.request_repo_dict, self.assignee_candidates, self.language_owner)
334338
try:
335339
issue.run()
336340
self.result.append(issue)

scripts/release_helper/java.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,7 @@
1515

1616

1717
class IssueProcessJava(IssueProcess):
18-
19-
def auto_parse(self) -> None:
20-
if AUTO_PARSE_LABEL in self.issue_package.labels_name:
21-
return
22-
23-
self.add_label(AUTO_PARSE_LABEL)
24-
issue_body_list = self.get_issue_body()
25-
26-
# Get the origin link and readme tag in issue body
27-
origin_link, self.target_readme_tag = get_origin_link_and_tag(issue_body_list)
28-
29-
# get readme_link
30-
self.get_readme_link(origin_link)
31-
32-
self.edit_issue_body()
33-
18+
pass
3419

3520
class Java(Common):
3621
def __init__(self, issues, assignee_token, language_owner):

scripts/release_helper/js.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
1+
import datetime
12
from common import IssueProcess, Common
23
from typing import Any, List
34
import os
45

56
# assignee dict which will be assigned to handle issues
6-
_JS_OWNER = {'qiaozha', 'lirenhe'}
7+
_JS_OWNER = {'qiaozha', 'lirenhe', 'MaryGao'}
78

89
# 'github assignee': 'token'
9-
_ASSIGNEE_TOKEN_JS = {'qiaozha': os.getenv('AZURESDK_BOT_TOKEN')}
10+
_ASSIGNEE_TOKEN_JS = {'qiaozha': os.getenv('AZURESDK_BOT_TOKEN'), 'MaryGao': os.getenv('AZURESDK_BOT_TOKEN')}
1011

1112

1213
class IssueProcessJs(IssueProcess):
13-
pass
14+
def auto_assign_policy(self) -> str:
15+
weeks = datetime.datetime.now().isocalendar()[1]
16+
assignees = list(self.assignee_candidates)
17+
assignees.sort()
18+
random_idx = weeks % len(assignees)
19+
return assignees[random_idx]
1420

1521

1622
class Js(Common):
1723
def __init__(self, issues, assignee_token, language_owner):
1824
super(Js, self).__init__(issues, assignee_token, language_owner)
1925
self.file_out_name = 'release_js_status.md'
20-
26+
self.issue_process_function = IssueProcessJs
2127

2228
def js_process(issues: List[Any]):
2329
instance = Js(issues, _ASSIGNEE_TOKEN_JS, _JS_OWNER)

0 commit comments

Comments
 (0)