Skip to content

Commit ceb8d15

Browse files
BigCat20196msyycRAY-316
authored
[Script] Release helper (Azure#25122)
* 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 * urldecode * format * add python * fix * add package name * update package name * update package name * fix bug * update get edit_content * auto-close * record release * debug * debug * debug * override run * init readme link * fix * fix * fix * update assignee_token and auto-close * fix * debug * fix * auto-reply * fix * debug * fix * debug * debug * fix * debugg * update yaml * change to add_label * format * add attention policy and remind policy * add duplicated policy * delete uesless code * Update scripts/release_helper/utils.py Co-authored-by: Yuchao Yan <yuchaoyan@microsoft.com> * update * fix dependence version * fix dependence version * fix env * update js assignee * update js assignee * fix find pr number bug * update assignee logic * debug * debug * update python assignee * Update python.py * debug * debug * delete useless code * Update scripts/release_helper/python.py Co-authored-by: Yuchao Yan <yuchaoyan@microsoft.com> * add multi api policy * add tag inconsystency * add specified tag * Update scripts/release_helper/python.py Co-authored-by: Yuchao Yan <yuchaoyan@microsoft.com> * update * update multiapi policy Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> Co-authored-by: Zed <601306339@qq.com> Co-authored-by: Yiming Lei <59104634+RAY-316@users.noreply.github.com> Co-authored-by: Yuchao Yan <yuchaoyan@microsoft.com>
1 parent da9039e commit ceb8d15

File tree

3 files changed

+34
-6
lines changed

3 files changed

+34
-6
lines changed

scripts/release_helper/common.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from github.Repository import Repository
1212

1313
from utils import IssuePackage, REQUEST_REPO, AUTO_ASSIGN_LABEL, AUTO_PARSE_LABEL, get_origin_link_and_tag,\
14-
MULTI_LINK_LABEL
14+
MULTI_LINK_LABEL, INCONSISTENT_TAG
1515

1616
_LOG = logging.getLogger(__name__)
1717

@@ -159,7 +159,9 @@ def edit_issue_body(self) -> None:
159159
self.issue_package.issue.edit(body=issue_body_up)
160160

161161
def check_tag_consistency(self) -> None:
162+
self.target_readme_tag = self.target_readme_tag.replace('tag-', '')
162163
if self.default_readme_tag != self.target_readme_tag:
164+
self.add_label(INCONSISTENT_TAG)
163165
self.comment(f'Hi, @{self.owner}, according to [rule](https://github.com/Azure/azure-rest-api-specs/blob/'
164166
f'main/documentation/release-request/rules-for-release-request.md#3-readme-tag-to-be-released),'
165167
f' your **Readme Tag** is `{self.target_readme_tag}`, but in [readme.md]({self.readme_link}#basic-information) '
@@ -174,7 +176,8 @@ def auto_parse(self) -> None:
174176
issue_body_list = self.get_issue_body()
175177

176178
# Get the origin link and readme tag in issue body
177-
origin_link, self.target_readme_tag = get_origin_link_and_tag(issue_body_list)
179+
origin_link, target_readme_tag = get_origin_link_and_tag(issue_body_list)
180+
self.target_readme_tag = target_readme_tag if not self.target_readme_tag else self.target_readme_tag
178181

179182
# get readme_link
180183
self.get_readme_link(origin_link)
@@ -252,6 +255,10 @@ def multi_link_policy(self):
252255
if MULTI_LINK_LABEL in self.issue_package.labels_name:
253256
self.bot_advice.append('multi readme link!')
254257

258+
def inconsistent_tag_policy(self):
259+
if INCONSISTENT_TAG in self.issue_package.labels_name:
260+
self.bot_advice.append('Attention to inconsistent tag')
261+
255262
def remind_logic(self) -> bool:
256263
return abs(self.date_from_target) <= 2
257264

@@ -267,6 +274,7 @@ def auto_bot_advice(self):
267274
self.new_comment_policy()
268275
self.multi_link_policy()
269276
self.date_remind_policy()
277+
self.inconsistent_tag_policy()
270278

271279
def get_target_date(self):
272280
body = self.get_issue_body()

scripts/release_helper/python.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
_AUTO_ASK_FOR_CHECK = 'auto-ask-check'
1717
_BRANCH_ATTENTION = 'base-branch-attention'
1818
_7_DAY_ATTENTION = '7days attention'
19+
_MultiAPI = 'MultiAPI'
1920
# record published issues
2021
_FILE_OUT = 'published_issues_python.csv'
2122

@@ -29,6 +30,7 @@ def __init__(self, issue_package: IssuePackage, request_repo_dict: Dict[str, Rep
2930
self.is_multiapi = False
3031
self.pattern_resource_manager = re.compile(r'/specification/([\w-]+/)+resource-manager')
3132
self.delay_time = self.get_delay_time()
33+
self.is_specified_tag = False
3234

3335
def get_delay_time(self):
3436
q = [comment.updated_at
@@ -41,10 +43,18 @@ def init_readme_link(self) -> None:
4143

4244
# Get the origin link and readme tag in issue body
4345
origin_link, self.target_readme_tag = get_origin_link_and_tag(issue_body_list)
46+
self.is_specified_tag = any('->Readme Tag:' in line for line in issue_body_list)
4447

4548
# get readme_link
4649
self.get_readme_link(origin_link)
4750

51+
def multi_api_policy(self) -> None:
52+
if self.is_multiapi:
53+
if _AUTO_ASK_FOR_CHECK not in self.issue_package.labels_name:
54+
self.bot_advice.append(_MultiAPI)
55+
if _MultiAPI not in self.issue_package.labels_name:
56+
self.add_label(_MultiAPI)
57+
4858
def get_package_and_output(self) -> None:
4959
self.init_readme_link()
5060
readme_python_path = self.pattern_resource_manager.search(self.readme_link).group() + '/readme.python.md'
@@ -53,10 +63,11 @@ def get_package_and_output(self) -> None:
5363
pattern_output = re.compile(r'\$\(python-sdks-folder\)/(.*?)/azure-')
5464
self.package_name = pattern_package.search(contents).group().split(':')[-1].strip()
5565
self.output_folder = pattern_output.search(contents).group().split('/')[1]
56-
self.is_multiapi = ('MultiAPI' in self.issue_package.labels_name) or ('multi-api' in contents)
66+
self.is_multiapi = (_MultiAPI in self.issue_package.labels_name) or ('multi-api' in contents)
5767

5868
def get_edit_content(self) -> None:
59-
self.edit_content = f'\n{self.readme_link.replace("/readme.md", "")}\n{self.package_name}'
69+
self.edit_content = f'\n{self.readme_link.replace("/readme.md", "")}\n{self.package_name}' \
70+
f'\nReadme Tag: {self.target_readme_tag}'
6071

6172
@property
6273
def readme_comparison(self) -> bool:
@@ -79,9 +90,11 @@ def auto_reply(self) -> None:
7990
if not self.readme_comparison:
8091
issue_link = self.issue_package.issue.html_url
8192
release_pipeline_url = get_python_release_pipeline(self.output_folder)
93+
python_tag = self.target_readme_tag if self.is_specified_tag else ""
8294
res_run = run_pipeline(issue_link=issue_link,
8395
pipeline_url=release_pipeline_url,
84-
spec_readme=self.readme_link + '/readme.md'
96+
spec_readme=self.readme_link + '/readme.md',
97+
python_tag=python_tag
8598
)
8699
if res_run:
87100
self.log(f'{issue_number} run pipeline successfully')
@@ -111,9 +124,11 @@ def remind_policy(self):
111124

112125
def auto_bot_advice(self):
113126
super().auto_bot_advice()
127+
self.multi_api_policy()
114128
self.attention_policy()
115129
self.remind_policy()
116130

131+
117132
def auto_close(self) -> None:
118133
if AUTO_CLOSE_LABEL in self.issue_package.labels_name:
119134
return

scripts/release_helper/utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
AUTO_PARSE_LABEL = 'auto-link'
1919
AUTO_CLOSE_LABEL = 'auto-close'
2020
MULTI_LINK_LABEL = 'MultiLink'
21+
INCONSISTENT_TAG = 'Inconsistent tag'
2122

2223
_LOG = logging.getLogger(__name__)
2324

@@ -71,7 +72,7 @@ def get_python_release_pipeline(output_folder):
7172

7273

7374
# Run sdk-auto-release(main) to generate SDK
74-
def run_pipeline(issue_link, pipeline_url, spec_readme):
75+
def run_pipeline(issue_link, pipeline_url, spec_readme, python_tag=""):
7576
paramaters = {
7677
"stages_to_skip": [],
7778
"resources": {
@@ -97,6 +98,10 @@ def run_pipeline(issue_link, pipeline_url, spec_readme):
9798
"SPEC_README": {
9899
"value": spec_readme,
99100
"isSecret": False
101+
},
102+
"PYTHON_TAG": {
103+
"value": python_tag,
104+
"isSecret": False
100105
}
101106
}
102107
}

0 commit comments

Comments
 (0)