From 2c563ff9f30ae51cc6699894143480e13c0aef6a Mon Sep 17 00:00:00 2001
From: Zed <601306339@qq.com>
Date: Mon, 23 Aug 2021 16:04:40 +0800
Subject: [PATCH 01/65] release_iseus_status_auto_reply
---
scripts/release_issue_status/main.py | 48 +++++---
.../release_issue_status/reply_generator.py | 110 ++++++++++++++++++
.../release_issue_status/update_issue_body.py | 97 +++++++++++++++
3 files changed, 241 insertions(+), 14 deletions(-)
create mode 100644 scripts/release_issue_status/reply_generator.py
create mode 100644 scripts/release_issue_status/update_issue_body.py
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index 9f9e5a35145d..b0549a3ba305 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -5,10 +5,13 @@
from datetime import date, datetime
import subprocess as sp
from azure.storage.blob import BlobClient
+import reply_generator as rg
+from update_issue_body import update_issue_body
+import traceback
_NULL = ' '
_FILE_OUT = 'release_issue_status.csv'
-_PYTHON_SDK_ADMINISTRATORS = {'msyyc', 'RAY-316', 'BigCat20196'}
+_PYTHON_SDK_ADMINISTRATORS = ['msyyc', 'RAY-316', 'BigCat20196']
def my_print(cmd):
@@ -85,9 +88,11 @@ def _extract_author_latest_comment(comments):
def _whether_author_comment(comments):
q = set(comment.user.login for comment in comments)
- diff = q.difference(_PYTHON_SDK_ADMINISTRATORS)
+ for administrators in _PYTHON_SDK_ADMINISTRATORS:
+ q.discard(administrators)
+
+ return True if len(q) > 0 else False
- return len(diff) > 0
def _latest_comment_time(comments, delay_from_create_date):
q = [(comment.updated_at.timestamp(), comment.user.login)
@@ -96,6 +101,7 @@ def _latest_comment_time(comments, delay_from_create_date):
return delay_from_create_date if not q else int((time.time() - q[-1][0]) / 3600 / 24)
+
def main():
# get latest issue status
g = Github(os.getenv('TOKEN')) # please fill user_token
@@ -135,30 +141,44 @@ def main():
# rule2: if latest comment is from author, need response asap
# rule3: if comment num is 0, it is new issue, better to deal with it asap
# rule4: if delay from latest update is over 7 days, better to deal with it soon.
- # rule5: if delay from created date is over 30 days and owner never reply, close it.
- # rule6: if delay from created date is over 15 days and owner never reply, remind owner to handle it.
+ # rule5: if delay from created date is over 30 days, better to close.
+ # rule6: if delay from created date is over 30 days and owner never reply, close it.
+ # rule7: if delay from created date is over 15 days and owner never reply, remind owner to handle it.
for item in issue_status:
if item.status == 'release':
item.bot_advice = 'better to release asap.'
elif item.author == item.author_latest_comment:
item.bot_advice = 'new comment for author.'
- elif item.comment_num == 0:
+ elif item.comment_num == 0 and 'Python' in item.labels:
item.bot_advice = 'new issue and better to confirm quickly.'
+ if 'auto-link' not in item.labels:
+ if not update_issue_body(item.link):
+ item.bot_advice = 'failed to modify the body of the new issue. Please modify manually'
+ item.labels.append('attention')
+ item.labels.append('auto-link')
+ item.issue_object.set_labels(*item.labels)
+ try:
+ time.sleep(3)
+ reply = rg.ReplyGenerator(issue_object=item.issue_object)
+ reply.run()
+ except Exception as e:
+ print('Error from auto reply ========================')
+ print('Issue:{}'.format(item.issue_object.number))
+ print(traceback.format_exc())
+ print('==============================================')
elif item.delay_from_latest_update >= 7:
item.bot_advice = 'delay for a long time and better to handle now.'
-
+
if item.days_from_latest_commit >= 30 and item.language == 'Python' and '30days attention' not in item.labels:
item.labels.append('30days attention')
item.issue_object.set_labels(*item.labels)
- item.issue_object.create_comment(f'hi @{item.author}, the issue is closed since there is no reply for a long time. Please reopen it if necessary or create new one.')
- item.issue_object.edit(state='close')
+ issue.issue_object.edit(state='close')
elif item.days_from_latest_commit >= 15 and item.language == 'Python' and '15days attention' not in item.labels:
- item.issue_object.create_comment(f'hi @{item.author}, this release-request has been delayed more than 15 days,'
- ' please deal with it ASAP. We will close the issue if there is still no response after 15 days!')
+ item.issue_object.create_comment('hi @{} ,this release-request has been delayed more than 15 days,'
+ ' please deal with it ASAP'.format(item.author))
item.labels.append('15days attention')
item.issue_object.set_labels(*item.labels)
-
-
+
# judge whether there is duplicated issue for same package
if item.package != _NULL and duplicated_issue.get((item.language, item.package)) > 1:
item.bot_advice = f'Warning:There is duplicated issue for {item.package}. ' + item.bot_advice
@@ -182,4 +202,4 @@ def main():
if __name__ == '__main__':
- main()
+ main()
\ No newline at end of file
diff --git a/scripts/release_issue_status/reply_generator.py b/scripts/release_issue_status/reply_generator.py
new file mode 100644
index 000000000000..123a4928368b
--- /dev/null
+++ b/scripts/release_issue_status/reply_generator.py
@@ -0,0 +1,110 @@
+from github import Github
+import re
+import os
+
+
+class ReplyGenerator(object):
+
+ def __init__(self, issue_object):
+ self.issue_object = issue_object
+ self.labels = [label.name for label in self.issue_object.labels]
+ self.comments = self.issue_object.get_comments()
+ self.body = self.issue_object.body
+ self.body_parse = {}
+ self._body_parse()
+ self.rest_specs_object = None
+ self.whether_change_readme = False
+ self._whether_change_readme()
+ self.whl_link = None
+ self.changelog_content = None
+ self.latest_pr_number = None
+
+ def _whether_change_readme(self):
+ g = Github(os.getenv('TOKEN'))
+ repo = g.get_repo('Azure/azure-rest-api-specs')
+ self.rest_specs_object = repo
+ contents = repo.get_contents(self.body_parse['readme_path'])
+ contents = str(contents.decoded_content)
+ pattern_tag = re.compile(r'tag: package-[\w+-.]+')
+ package_tag = pattern_tag.search(contents).group()
+ package_tag = package_tag.split(':')[1].strip()
+ readme_python_contents = str(repo.get_contents(self.body_parse['readme_python_path']).decoded_content)
+ whether_multi_api = 'multi-api' in readme_python_contents
+ whether_same_tag = package_tag == self.body_parse['readme_tag']
+ self.whether_change_readme = not (whether_same_tag and (not whether_multi_api or 'MultiAPI' in self.labels))
+
+ def _body_parse(self):
+ pattern_readme = re.compile(r'/specification/([\w-]+/)+readme.md')
+ pattern_resource_manager = re.compile(r'/specification/([\w-]+/)+resource-manager')
+ pattern_tag = re.compile(r'package-[\w+-.]+')
+ readme_path = pattern_readme.search(self.body).group()
+ readme_tag = pattern_tag.search(self.body).group()
+ resource_manager = pattern_resource_manager.search(self.body).group()
+ self.body_parse['readme_path'] = readme_path
+ self.body_parse['readme_python_path'] = readme_path[:readme_path.rfind('/')] + '/readme.python.md'
+ self.body_parse['readme_tag'] = readme_tag
+ self.body_parse['resource_manager'] = resource_manager
+
+ def _get_latest_pr_from_readme(self):
+ commits = self.rest_specs_object.get_commits(path=self.body_parse['resource_manager'])
+ latest_commit = [commit for commit in commits][0]
+ latest_pr_brief = latest_commit.commit.message
+ latest_pr_number = re.findall('\(\#[0-9]+\)', latest_pr_brief)
+ latest_pr_number_int = []
+ for number in latest_pr_number:
+ number = int(re.search('\d+', number).group())
+ latest_pr_number_int.append(number)
+ latest_pr_number_int.sort()
+
+ return latest_pr_number_int[-1]
+
+ def _latest_pr_parse(self):
+ latest_pr = self.rest_specs_object.get_issue(self.latest_pr_number)
+ latest_pr_comments = latest_pr.get_comments()
+ b = [i for i in latest_pr_comments]
+ for comment in latest_pr_comments:
+ if '
Swagger Generation Artifacts
' in comment.body:
+ return self._swagger_generator_parse(comment.body)
+
+ def _swagger_generator_parse(self, context):
+ track1_info_model = ''
+ try:
+ if ' azure-sdk-for-python' in context:
+ pattern_python_t1 = re.compile(' azure-sdk-for-python.+?', re.DOTALL)
+ python_t1 = re.search(pattern_python_t1, context).group()
+ prttern_python_track1 = re.compile('\s+?- \s+?', re.DOTALL)
+ python_track1_info = re.search(prttern_python_track1, python_t1).group()
+ track1_info_model = '
python-track1
{} '.format(
+ python_track1_info)
+ except Exception as e:
+ print('track1 generate error')
+ pattern_python = re.compile(' azure-sdk-for-python-track2.+?', re.DOTALL)
+ python = re.search(pattern_python, context).group()
+ prttern_python_track2 = re.compile('\s*?- \s*?', re.DOTALL)
+ python_track2_info = re.search(prttern_python_track2, python).group()
+ track2_info_model = '
python-track2
{} '.format(python_track2_info)
+ info_model = 'hi @{} Please check the package whether works well and the changelog info is as below:\n' \
+ '{}\n{}\n' \
+ '\n* (The version of the package is only a temporary version for testing)\n' \
+ '\nhttps://github.com/Azure/azure-rest-api-specs/pull/{}\n' \
+ .format(self.issue_object.user.login, track1_info_model, track2_info_model, str(self.latest_pr_number))
+
+ return info_model
+
+ def reply_owner(self, reply_content):
+ self.issue_object.create_comment(reply_content)
+
+ def add_label(self, label_name):
+ if label_name not in self.labels:
+ self.labels.append(label_name)
+ self.issue_object.set_labels(*self.labels)
+
+ def run(self):
+ if not self.whether_change_readme:
+ self.latest_pr_number = self._get_latest_pr_from_readme()
+ reply_content = self._latest_pr_parse()
+ self.reply_owner(reply_content)
+ self.add_label('P1')
+ else:
+ print('issue {} need config readme***********'.format(self.issue_object.number))
+
diff --git a/scripts/release_issue_status/update_issue_body.py b/scripts/release_issue_status/update_issue_body.py
new file mode 100644
index 000000000000..3a74fd735a73
--- /dev/null
+++ b/scripts/release_issue_status/update_issue_body.py
@@ -0,0 +1,97 @@
+import os
+import re
+
+from github import Github
+
+
+def update_issue_body(issue_link):
+ # Get Issue Number
+ issue_number = int(issue_link.replace("https://github.com/Azure/sdk-release-request/issues/", ""))
+ g = Github(os.getenv('TOKEN', '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'))
+ sdk_repo = g.get_repo('Azure/sdk-release-request')
+ rest_repo = g.get_repo('Azure/azure-rest-api-specs')
+ issue_info = sdk_repo.get_issue(number=issue_number)
+ issue_body = issue_info.body
+
+ issue_body_list = [i for i in issue_body.split("\n") if i]
+ # Get the link in issue body
+ for row in issue_body_list:
+ if 'link' in row or 'Link' in row:
+ link = row.split(":", 1)[-1].strip()
+ break
+
+ if link.count('https') > 1:
+ link = link.split(']')[0]
+ link = link.replace('[', "").replace(']', "").replace('(', "").replace(')', "")
+
+ package_name, readme_link = get_pkname_and_readme_link(rest_repo, link)
+ if not package_name and not readme_link:
+ return False
+
+ if not package_name:
+ if 'commit' in readme_link:
+ commit = rest_repo.get_commit()
+ pass
+ readme_link_part = '/specification' + readme_link.split('/specification')[-1]
+ readme_contents = str(rest_repo.get_contents(readme_link_part).decoded_content)
+ package_name = re.findall(r'package-name: (.*?)\\n', readme_contents)[0]
+
+ readme_link = readme_link.replace('python.', '')
+ issue_body_list.insert(0, f'\n{readme_link}')
+ issue_body_list.insert(1, package_name)
+ issue_body_up = ''
+ for raw in issue_body_list:
+ if raw == '---\r' or raw == '---':
+ issue_body_up += '\n'
+ issue_body_up += raw + '\n'
+ try:
+ issue_info.edit(body=issue_body_up)
+ return True
+ except Exception as e:
+ return False
+
+
+def get_pkname_and_readme_link(rest_repo, link):
+ if 'commit' in link:
+ commit_sha = link.split('commit/')[-1]
+ commit = rest_repo.get_commit(commit_sha)
+ link = commit.files[0].blob_url
+
+ if 'pull' in link:
+ pk_name, readme_link = get_pkname_and_readme_from_pull(rest_repo, link)
+ return pk_name, readme_link
+ elif '/resource-manager' not in link:
+ readme_link = link + '/resource-manager/readme.python.md'
+ else:
+ readme_link = link.split('/resource-manager')[0] + '/resource-manager/readme.python.md'
+
+ return '', readme_link
+
+
+def get_pkname_and_readme_from_pull(rest_repo, pr_link):
+ pr_number = int(pr_link.replace("https://github.com/Azure/azure-rest-api-specs/pull/", "").strip('/'))
+ pr_info = rest_repo.get_issue(number=pr_number)
+
+ # Get package name
+ pr_comments = pr_info.get_comments()
+ package_names = []
+ for comment in pr_comments:
+ if "Swagger Generation Artifacts" in comment.body:
+ package_names = re.findall(r"track\d_(.*?)", comment.body)
+ break
+
+ if len(package_names) != 1:
+ return '', ''
+ package_name = package_names[0]
+
+ # Get Readme link
+ pr_info1 = rest_repo.get_pull(number=pr_number)
+ for pr_changed_file in pr_info1.get_files():
+ contents_url = pr_changed_file.contents_url
+ if '/resource-manager' in contents_url:
+ pk_url_name = re.findall(r'/specification/(.*?)/resource-manager/', contents_url)[0]
+ break
+ readme_link = 'https://github.com/Azure/azure-rest-api-specs/blob/main/specification/{}/' \
+ 'resource-manager/readme.python.md'.format(pk_url_name)
+
+ return package_name, readme_link
\ No newline at end of file
From 9603d0f6f39ed6b5b3011187b8e60014fc744af5 Mon Sep 17 00:00:00 2001
From: Zed Lei <59104634+RAY-316@users.noreply.github.com>
Date: Mon, 23 Aug 2021 16:10:46 +0800
Subject: [PATCH 02/65] issue_aoto_close_revert
---
scripts/release_issue_status/main.py | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index b0549a3ba305..94ca5eeef549 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -172,10 +172,11 @@ def main():
if item.days_from_latest_commit >= 30 and item.language == 'Python' and '30days attention' not in item.labels:
item.labels.append('30days attention')
item.issue_object.set_labels(*item.labels)
- issue.issue_object.edit(state='close')
+ item.issue_object.create_comment(f'hi @{item.author}, the issue is closed since there is no reply for a long time. Please reopen it if necessary or create new one.')
+ item.issue_object.edit(state='close')
elif item.days_from_latest_commit >= 15 and item.language == 'Python' and '15days attention' not in item.labels:
- item.issue_object.create_comment('hi @{} ,this release-request has been delayed more than 15 days,'
- ' please deal with it ASAP'.format(item.author))
+ item.issue_object.create_comment(f'hi @{item.author}, this release-request has been delayed more than 15 days,'
+ ' please deal with it ASAP. We will close the issue if there is still no response after 15 days!')
item.labels.append('15days attention')
item.issue_object.set_labels(*item.labels)
@@ -202,4 +203,4 @@ def main():
if __name__ == '__main__':
- main()
\ No newline at end of file
+ main()
From 133a6a022408f9ac7d659eea6e54ff41c870f739 Mon Sep 17 00:00:00 2001
From: Zed Lei <59104634+RAY-316@users.noreply.github.com>
Date: Mon, 23 Aug 2021 16:31:42 +0800
Subject: [PATCH 03/65] Update main.py
---
scripts/release_issue_status/main.py | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index 94ca5eeef549..a4a21f9167d3 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -11,8 +11,7 @@
_NULL = ' '
_FILE_OUT = 'release_issue_status.csv'
-_PYTHON_SDK_ADMINISTRATORS = ['msyyc', 'RAY-316', 'BigCat20196']
-
+_PYTHON_SDK_ADMINISTRATORS = {'msyyc', 'RAY-316', 'BigCat20196'}
def my_print(cmd):
print('==' + cmd + ' ==\n')
@@ -87,11 +86,9 @@ def _extract_author_latest_comment(comments):
def _whether_author_comment(comments):
- q = set(comment.user.login for comment in comments)
- for administrators in _PYTHON_SDK_ADMINISTRATORS:
- q.discard(administrators)
+ diff = q.difference(_PYTHON_SDK_ADMINISTRATORS)
- return True if len(q) > 0 else False
+ return len(diff) > 0
def _latest_comment_time(comments, delay_from_create_date):
From d37ca66d4ac17d4be89a113f63a49e2a72a0a790 Mon Sep 17 00:00:00 2001
From: Zed Lei <59104634+RAY-316@users.noreply.github.com>
Date: Mon, 23 Aug 2021 16:32:38 +0800
Subject: [PATCH 04/65] Update main.py
---
scripts/release_issue_status/main.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index a4a21f9167d3..bd9eb3ce3c24 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -86,6 +86,7 @@ def _extract_author_latest_comment(comments):
def _whether_author_comment(comments):
+ q = set(comment.user.login for comment in comments)
diff = q.difference(_PYTHON_SDK_ADMINISTRATORS)
return len(diff) > 0
From f5a24c866a0d8d9e3ccb76d6ab9215eaf7f19bfd Mon Sep 17 00:00:00 2001
From: Zed Lei <59104634+RAY-316@users.noreply.github.com>
Date: Mon, 23 Aug 2021 16:38:48 +0800
Subject: [PATCH 05/65] Update update_issue_body.py
---
scripts/release_issue_status/update_issue_body.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/scripts/release_issue_status/update_issue_body.py b/scripts/release_issue_status/update_issue_body.py
index 3a74fd735a73..47f0377b18ad 100644
--- a/scripts/release_issue_status/update_issue_body.py
+++ b/scripts/release_issue_status/update_issue_body.py
@@ -7,7 +7,7 @@
def update_issue_body(issue_link):
# Get Issue Number
issue_number = int(issue_link.replace("https://github.com/Azure/sdk-release-request/issues/", ""))
- g = Github(os.getenv('TOKEN', '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'))
+ g = Github(os.getenv('TOKEN'))
sdk_repo = g.get_repo('Azure/sdk-release-request')
rest_repo = g.get_repo('Azure/azure-rest-api-specs')
issue_info = sdk_repo.get_issue(number=issue_number)
@@ -16,7 +16,7 @@ def update_issue_body(issue_link):
issue_body_list = [i for i in issue_body.split("\n") if i]
# Get the link in issue body
for row in issue_body_list:
- if 'link' in row or 'Link' in row:
+ if 'link' in row.lower():
link = row.split(":", 1)[-1].strip()
break
@@ -94,4 +94,4 @@ def get_pkname_and_readme_from_pull(rest_repo, pr_link):
readme_link = 'https://github.com/Azure/azure-rest-api-specs/blob/main/specification/{}/' \
'resource-manager/readme.python.md'.format(pk_url_name)
- return package_name, readme_link
\ No newline at end of file
+ return package_name, readme_link
From 590dc3d210e7418e5c31ab8365edf225a8af020a Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Mon, 23 Aug 2021 17:39:59 +0800
Subject: [PATCH 06/65] Update reply_generator.py
---
.../release_issue_status/reply_generator.py | 201 +++++++++---------
1 file changed, 95 insertions(+), 106 deletions(-)
diff --git a/scripts/release_issue_status/reply_generator.py b/scripts/release_issue_status/reply_generator.py
index 123a4928368b..89041d43d6c2 100644
--- a/scripts/release_issue_status/reply_generator.py
+++ b/scripts/release_issue_status/reply_generator.py
@@ -1,110 +1,99 @@
-from github import Github
-import re
import os
+import re
+
+from github import Github
+
+
+def update_issue_body(issue_link):
+ # Get Issue Number
+ issue_number = int(issue_link.replace("https://github.com/Azure/sdk-release-request/issues/", ""))
+ g = Github(os.getenv('TOKEN'))
+ sdk_repo = g.get_repo('Azure/sdk-release-request')
+ rest_repo = g.get_repo('Azure/azure-rest-api-specs')
+ issue_info = sdk_repo.get_issue(number=issue_number)
+ issue_body = issue_info.body
+
+ issue_body_list = [i for i in issue_body.split("\n") if i]
+ # Get the link in issue body
+ for row in issue_body_list:
+ if 'link' in row.lower():
+ link = row.split(":", 1)[-1].strip()
+ break
+
+ if link.count('https') > 1:
+ link = link.split(']')[0]
+ link = link.replace('[', "").replace(']', "").replace('(', "").replace(')', "")
+
+ try:
+ package_name, readme_link = get_pkname_and_readme_link(rest_repo, link)
+ except Exception as e:
+ print(e)
+ return False
+
+ readme_link = readme_link.replace('python.', '')
+ issue_body_list.insert(0, f'\n{readme_link}')
+ issue_body_list.insert(1, package_name)
+ issue_body_up = ''
+ for raw in issue_body_list:
+ if raw == '---\r' or raw == '---':
+ issue_body_up += '\n'
+ issue_body_up += raw + '\n'
+ try:
+ issue_info.edit(body=issue_body_up)
+ return True
+ except Exception as e:
+ print(e)
+ return False
+
+
+def get_pkname_and_readme_link(rest_repo, link):
+ # change commit link to pull json link
+ pk_name = ''
+ if 'commit' in link:
+ commit_sha = link.split('commit/')[-1]
+ commit = rest_repo.get_commit(commit_sha)
+ link = commit.files[0].blob_url
+
+ # if link is a pr, it can get both pakeage name and readme link.
+ if 'pull' in link:
+ pk_name, readme_link = get_pkname_and_readme_from_pull(rest_repo, link)
+ elif '/resource-manager' not in link:
+ readme_link = link + '/resource-manager/readme.python.md'
+ else:
+ readme_link = link.split('/resource-manager')[0] + '/resource-manager/readme.python.md'
+ # get the package name by readme link
+ if not pk_name:
+ readme_link_part = '/specification' + readme_link.split('/specification')[-1]
+ readme_contents = str(rest_repo.get_contents(readme_link_part).decoded_content)
+ pk_name = re.findall(r'package-name: (.*?)\\n', readme_contents)[0]
+
+ return pk_name, readme_link
+
+
+def get_pkname_and_readme_from_pull(rest_repo, pr_link):
+ pr_number = int(pr_link.replace("https://github.com/Azure/azure-rest-api-specs/pull/", "").strip('/'))
+ pr_info = rest_repo.get_issue(number=pr_number)
+
+ # Get package name
+ pr_comments = pr_info.get_comments()
+ package_names = []
+ for comment in pr_comments:
+ if "Swagger Generation Artifacts" in comment.body:
+ package_names = re.findall(r"track\d_(.*?)", comment.body)
+ break
+ if len(package_names) != 1:
+ return '', ''
+ package_name = package_names[0]
-class ReplyGenerator(object):
-
- def __init__(self, issue_object):
- self.issue_object = issue_object
- self.labels = [label.name for label in self.issue_object.labels]
- self.comments = self.issue_object.get_comments()
- self.body = self.issue_object.body
- self.body_parse = {}
- self._body_parse()
- self.rest_specs_object = None
- self.whether_change_readme = False
- self._whether_change_readme()
- self.whl_link = None
- self.changelog_content = None
- self.latest_pr_number = None
-
- def _whether_change_readme(self):
- g = Github(os.getenv('TOKEN'))
- repo = g.get_repo('Azure/azure-rest-api-specs')
- self.rest_specs_object = repo
- contents = repo.get_contents(self.body_parse['readme_path'])
- contents = str(contents.decoded_content)
- pattern_tag = re.compile(r'tag: package-[\w+-.]+')
- package_tag = pattern_tag.search(contents).group()
- package_tag = package_tag.split(':')[1].strip()
- readme_python_contents = str(repo.get_contents(self.body_parse['readme_python_path']).decoded_content)
- whether_multi_api = 'multi-api' in readme_python_contents
- whether_same_tag = package_tag == self.body_parse['readme_tag']
- self.whether_change_readme = not (whether_same_tag and (not whether_multi_api or 'MultiAPI' in self.labels))
-
- def _body_parse(self):
- pattern_readme = re.compile(r'/specification/([\w-]+/)+readme.md')
- pattern_resource_manager = re.compile(r'/specification/([\w-]+/)+resource-manager')
- pattern_tag = re.compile(r'package-[\w+-.]+')
- readme_path = pattern_readme.search(self.body).group()
- readme_tag = pattern_tag.search(self.body).group()
- resource_manager = pattern_resource_manager.search(self.body).group()
- self.body_parse['readme_path'] = readme_path
- self.body_parse['readme_python_path'] = readme_path[:readme_path.rfind('/')] + '/readme.python.md'
- self.body_parse['readme_tag'] = readme_tag
- self.body_parse['resource_manager'] = resource_manager
-
- def _get_latest_pr_from_readme(self):
- commits = self.rest_specs_object.get_commits(path=self.body_parse['resource_manager'])
- latest_commit = [commit for commit in commits][0]
- latest_pr_brief = latest_commit.commit.message
- latest_pr_number = re.findall('\(\#[0-9]+\)', latest_pr_brief)
- latest_pr_number_int = []
- for number in latest_pr_number:
- number = int(re.search('\d+', number).group())
- latest_pr_number_int.append(number)
- latest_pr_number_int.sort()
-
- return latest_pr_number_int[-1]
-
- def _latest_pr_parse(self):
- latest_pr = self.rest_specs_object.get_issue(self.latest_pr_number)
- latest_pr_comments = latest_pr.get_comments()
- b = [i for i in latest_pr_comments]
- for comment in latest_pr_comments:
- if 'Swagger Generation Artifacts
' in comment.body:
- return self._swagger_generator_parse(comment.body)
-
- def _swagger_generator_parse(self, context):
- track1_info_model = ''
- try:
- if ' azure-sdk-for-python' in context:
- pattern_python_t1 = re.compile(' azure-sdk-for-python.+?', re.DOTALL)
- python_t1 = re.search(pattern_python_t1, context).group()
- prttern_python_track1 = re.compile('\s+?- \s+?', re.DOTALL)
- python_track1_info = re.search(prttern_python_track1, python_t1).group()
- track1_info_model = '
python-track1
{} '.format(
- python_track1_info)
- except Exception as e:
- print('track1 generate error')
- pattern_python = re.compile(' azure-sdk-for-python-track2.+?', re.DOTALL)
- python = re.search(pattern_python, context).group()
- prttern_python_track2 = re.compile('\s*?- \s*?', re.DOTALL)
- python_track2_info = re.search(prttern_python_track2, python).group()
- track2_info_model = '
python-track2
{} '.format(python_track2_info)
- info_model = 'hi @{} Please check the package whether works well and the changelog info is as below:\n' \
- '{}\n{}\n' \
- '\n* (The version of the package is only a temporary version for testing)\n' \
- '\nhttps://github.com/Azure/azure-rest-api-specs/pull/{}\n' \
- .format(self.issue_object.user.login, track1_info_model, track2_info_model, str(self.latest_pr_number))
-
- return info_model
-
- def reply_owner(self, reply_content):
- self.issue_object.create_comment(reply_content)
-
- def add_label(self, label_name):
- if label_name not in self.labels:
- self.labels.append(label_name)
- self.issue_object.set_labels(*self.labels)
-
- def run(self):
- if not self.whether_change_readme:
- self.latest_pr_number = self._get_latest_pr_from_readme()
- reply_content = self._latest_pr_parse()
- self.reply_owner(reply_content)
- self.add_label('P1')
- else:
- print('issue {} need config readme***********'.format(self.issue_object.number))
+ # Get Readme link
+ pr_info1 = rest_repo.get_pull(number=pr_number)
+ for pr_changed_file in pr_info1.get_files():
+ contents_url = pr_changed_file.contents_url
+ if '/resource-manager' in contents_url:
+ pk_url_name = re.findall(r'/specification/(.*?)/resource-manager/', contents_url)[0]
+ break
+ readme_link = 'https://github.com/Azure/azure-rest-api-specs/blob/main/specification/{}/' \
+ 'resource-manager/readme.python.md'.format(pk_url_name)
+ return package_name, readme_link
From 0a20a20eae5cd0695fff397d9ba12ceca588800c Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Tue, 24 Aug 2021 09:56:20 +0800
Subject: [PATCH 07/65] Update reply_generator.py
---
.../release_issue_status/reply_generator.py | 202 +++++++++---------
1 file changed, 106 insertions(+), 96 deletions(-)
diff --git a/scripts/release_issue_status/reply_generator.py b/scripts/release_issue_status/reply_generator.py
index 89041d43d6c2..a69ba69abb47 100644
--- a/scripts/release_issue_status/reply_generator.py
+++ b/scripts/release_issue_status/reply_generator.py
@@ -1,99 +1,109 @@
-import os
-import re
-
from github import Github
+import re
+import os
-def update_issue_body(issue_link):
- # Get Issue Number
- issue_number = int(issue_link.replace("https://github.com/Azure/sdk-release-request/issues/", ""))
- g = Github(os.getenv('TOKEN'))
- sdk_repo = g.get_repo('Azure/sdk-release-request')
- rest_repo = g.get_repo('Azure/azure-rest-api-specs')
- issue_info = sdk_repo.get_issue(number=issue_number)
- issue_body = issue_info.body
-
- issue_body_list = [i for i in issue_body.split("\n") if i]
- # Get the link in issue body
- for row in issue_body_list:
- if 'link' in row.lower():
- link = row.split(":", 1)[-1].strip()
- break
-
- if link.count('https') > 1:
- link = link.split(']')[0]
- link = link.replace('[', "").replace(']', "").replace('(', "").replace(')', "")
-
- try:
- package_name, readme_link = get_pkname_and_readme_link(rest_repo, link)
- except Exception as e:
- print(e)
- return False
-
- readme_link = readme_link.replace('python.', '')
- issue_body_list.insert(0, f'\n{readme_link}')
- issue_body_list.insert(1, package_name)
- issue_body_up = ''
- for raw in issue_body_list:
- if raw == '---\r' or raw == '---':
- issue_body_up += '\n'
- issue_body_up += raw + '\n'
- try:
- issue_info.edit(body=issue_body_up)
- return True
- except Exception as e:
- print(e)
- return False
-
-
-def get_pkname_and_readme_link(rest_repo, link):
- # change commit link to pull json link
- pk_name = ''
- if 'commit' in link:
- commit_sha = link.split('commit/')[-1]
- commit = rest_repo.get_commit(commit_sha)
- link = commit.files[0].blob_url
-
- # if link is a pr, it can get both pakeage name and readme link.
- if 'pull' in link:
- pk_name, readme_link = get_pkname_and_readme_from_pull(rest_repo, link)
- elif '/resource-manager' not in link:
- readme_link = link + '/resource-manager/readme.python.md'
- else:
- readme_link = link.split('/resource-manager')[0] + '/resource-manager/readme.python.md'
- # get the package name by readme link
- if not pk_name:
- readme_link_part = '/specification' + readme_link.split('/specification')[-1]
- readme_contents = str(rest_repo.get_contents(readme_link_part).decoded_content)
- pk_name = re.findall(r'package-name: (.*?)\\n', readme_contents)[0]
-
- return pk_name, readme_link
-
-
-def get_pkname_and_readme_from_pull(rest_repo, pr_link):
- pr_number = int(pr_link.replace("https://github.com/Azure/azure-rest-api-specs/pull/", "").strip('/'))
- pr_info = rest_repo.get_issue(number=pr_number)
-
- # Get package name
- pr_comments = pr_info.get_comments()
- package_names = []
- for comment in pr_comments:
- if "Swagger Generation Artifacts" in comment.body:
- package_names = re.findall(r"track\d_(.*?)", comment.body)
- break
-
- if len(package_names) != 1:
- return '', ''
- package_name = package_names[0]
-
- # Get Readme link
- pr_info1 = rest_repo.get_pull(number=pr_number)
- for pr_changed_file in pr_info1.get_files():
- contents_url = pr_changed_file.contents_url
- if '/resource-manager' in contents_url:
- pk_url_name = re.findall(r'/specification/(.*?)/resource-manager/', contents_url)[0]
- break
- readme_link = 'https://github.com/Azure/azure-rest-api-specs/blob/main/specification/{}/' \
- 'resource-manager/readme.python.md'.format(pk_url_name)
-
- return package_name, readme_link
+class ReplyGenerator(object):
+
+ def __init__(self, issue_object):
+ self.issue_object = issue_object
+ self.labels = [label.name for label in self.issue_object.labels]
+ self.comments = self.issue_object.get_comments()
+ self.body = self.issue_object.body
+ self.body_parse = {}
+ self._body_parse()
+ self.rest_specs_object = None
+ self.whether_change_readme = False
+ self._whether_change_readme()
+ self.whl_link = None
+ self.changelog_content = None
+ self.latest_pr_number = None
+
+ def _whether_change_readme(self):
+ g = Github(os.getenv('TOKEN'))
+ repo = g.get_repo('Azure/azure-rest-api-specs')
+ self.rest_specs_object = repo
+ contents = repo.get_contents(self.body_parse['readme_path'])
+ contents = str(contents.decoded_content)
+ pattern_tag = re.compile(r'tag: package-[\w+-.]+')
+ package_tag = pattern_tag.search(contents).group()
+ package_tag = package_tag.split(':')[1].strip()
+ readme_python_contents = str(repo.get_contents(self.body_parse['readme_python_path']).decoded_content)
+ whether_multi_api = 'multi-api' in readme_python_contents
+ whether_same_tag = package_tag == self.body_parse['readme_tag']
+ self.whether_change_readme = not (whether_same_tag and (not whether_multi_api or 'MultiAPI' in self.labels))
+
+ def _body_parse(self):
+ pattern_readme = re.compile(r'/specification/([\w-]+/)+readme.md')
+ pattern_resource_manager = re.compile(r'/specification/([\w-]+/)+resource-manager')
+ pattern_tag = re.compile(r'package-[\w+-.]+')
+ readme_path = pattern_readme.search(self.body).group()
+ readme_tag = pattern_tag.search(self.body).group()
+ resource_manager = pattern_resource_manager.search(self.body).group()
+ self.body_parse['readme_path'] = readme_path
+ self.body_parse['readme_python_path'] = readme_path[:readme_path.rfind('/')] + '/readme.python.md'
+ self.body_parse['readme_tag'] = readme_tag
+ self.body_parse['resource_manager'] = resource_manager
+
+ def _get_latest_pr_from_readme(self):
+ commits = self.rest_specs_object.get_commits(path=self.body_parse['resource_manager'])
+ latest_commit = [commit for commit in commits][0]
+ latest_pr_brief = latest_commit.commit.message
+ latest_pr_number = re.findall('\(\#[0-9]+\)', latest_pr_brief)
+ latest_pr_number_int = []
+ for number in latest_pr_number:
+ number = int(re.search('\d+', number).group())
+ latest_pr_number_int.append(number)
+ latest_pr_number_int.sort()
+
+ return latest_pr_number_int[-1]
+
+ def _latest_pr_parse(self):
+ latest_pr = self.rest_specs_object.get_issue(self.latest_pr_number)
+ latest_pr_comments = latest_pr.get_comments()
+ b = [i for i in latest_pr_comments]
+ for comment in latest_pr_comments:
+ if 'Swagger Generation Artifacts
' in comment.body:
+ return self._swagger_generator_parse(comment.body)
+
+ def _swagger_generator_parse(self, context):
+ track1_info_model = ''
+ try:
+ if ' azure-sdk-for-python' in context:
+ pattern_python_t1 = re.compile(' azure-sdk-for-python.+?', re.DOTALL)
+ python_t1 = re.search(pattern_python_t1, context).group()
+ prttern_python_track1 = re.compile('\s+?- \s+?', re.DOTALL)
+ python_track1_info = re.search(prttern_python_track1, python_t1).group()
+ track1_info_model = '
python-track1
{} '.format(
+ python_track1_info)
+ except Exception as e:
+ print('track1 generate error')
+ pattern_python = re.compile(' azure-sdk-for-python-track2.+?', re.DOTALL)
+ python = re.search(pattern_python, context).group()
+ prttern_python_track2 = re.compile('\s*?- \s*?', re.DOTALL)
+ python_track2_info = re.search(prttern_python_track2, python).group()
+ track2_info_model = '
python-track2
{} '.format(python_track2_info)
+ info_model = 'hi @{} Please check the package whether works well and the changelog info is as below:\n' \
+ '{}\n{}\n' \
+ '\n* (The version of the package is only a temporary version for testing)\n' \
+ '\nhttps://github.com/Azure/azure-rest-api-specs/pull/{}\n' \
+ .format(self.issue_object.user.login, track1_info_model, track2_info_model, str(self.latest_pr_number))
+
+ return info_model
+
+ def reply_owner(self, reply_content):
+ self.issue_object.create_comment(reply_content)
+
+ def add_label(self, label_name):
+ if label_name not in self.labels:
+ self.labels.append(label_name)
+ self.issue_object.set_labels(*self.labels)
+
+ def run(self):
+ if not self.whether_change_readme:
+ self.latest_pr_number = self._get_latest_pr_from_readme()
+ reply_content = self._latest_pr_parse()
+ self.reply_owner(reply_content)
+ self.add_label('P1')
+ else:
+ print('issue {} need config readme***********'.format(self.issue_object.number))
From 1644cf105359444d77c2af9def5000a62092c541 Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Tue, 24 Aug 2021 09:57:52 +0800
Subject: [PATCH 08/65] Update update_issue_body.py
---
.../release_issue_status/update_issue_body.py | 28 +++++++++----------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/scripts/release_issue_status/update_issue_body.py b/scripts/release_issue_status/update_issue_body.py
index 47f0377b18ad..0831a6dbc60d 100644
--- a/scripts/release_issue_status/update_issue_body.py
+++ b/scripts/release_issue_status/update_issue_body.py
@@ -24,18 +24,12 @@ def update_issue_body(issue_link):
link = link.split(']')[0]
link = link.replace('[', "").replace(']', "").replace('(', "").replace(')', "")
- package_name, readme_link = get_pkname_and_readme_link(rest_repo, link)
- if not package_name and not readme_link:
+ try:
+ package_name, readme_link = get_pkname_and_readme_link(rest_repo, link)
+ except Exception as e:
+ print(e)
return False
- if not package_name:
- if 'commit' in readme_link:
- commit = rest_repo.get_commit()
- pass
- readme_link_part = '/specification' + readme_link.split('/specification')[-1]
- readme_contents = str(rest_repo.get_contents(readme_link_part).decoded_content)
- package_name = re.findall(r'package-name: (.*?)\\n', readme_contents)[0]
-
readme_link = readme_link.replace('python.', '')
issue_body_list.insert(0, f'\n{readme_link}')
issue_body_list.insert(1, package_name)
@@ -48,24 +42,32 @@ def update_issue_body(issue_link):
issue_info.edit(body=issue_body_up)
return True
except Exception as e:
+ print(e)
return False
def get_pkname_and_readme_link(rest_repo, link):
+ # change commit link to pull json link
+ pk_name = ''
if 'commit' in link:
commit_sha = link.split('commit/')[-1]
commit = rest_repo.get_commit(commit_sha)
link = commit.files[0].blob_url
+ # if link is a pr, it can get both pakeage name and readme link.
if 'pull' in link:
pk_name, readme_link = get_pkname_and_readme_from_pull(rest_repo, link)
- return pk_name, readme_link
elif '/resource-manager' not in link:
readme_link = link + '/resource-manager/readme.python.md'
else:
readme_link = link.split('/resource-manager')[0] + '/resource-manager/readme.python.md'
+ # get the package name by readme link
+ if not pk_name:
+ readme_link_part = '/specification' + readme_link.split('/specification')[-1]
+ readme_contents = str(rest_repo.get_contents(readme_link_part).decoded_content)
+ pk_name = re.findall(r'package-name: (.*?)\\n', readme_contents)[0]
- return '', readme_link
+ return pk_name, readme_link
def get_pkname_and_readme_from_pull(rest_repo, pr_link):
@@ -93,5 +95,3 @@ def get_pkname_and_readme_from_pull(rest_repo, pr_link):
break
readme_link = 'https://github.com/Azure/azure-rest-api-specs/blob/main/specification/{}/' \
'resource-manager/readme.python.md'.format(pk_url_name)
-
- return package_name, readme_link
From 6b1f482fd67e9c6923de445f146986f88954d834 Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Tue, 24 Aug 2021 10:21:18 +0800
Subject: [PATCH 09/65] Update main.py
---
scripts/release_issue_status/main.py | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index bd9eb3ce3c24..db8a341fa293 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -103,9 +103,10 @@ def _latest_comment_time(comments, delay_from_create_date):
def main():
# get latest issue status
g = Github(os.getenv('TOKEN')) # please fill user_token
- repo = g.get_repo('Azure/sdk-release-request')
- label1 = repo.get_label('ManagementPlane')
- open_issues = repo.get_issues(state='open', labels=[label1])
+ sdk_repo = g.get_repo('Azure/sdk-release-request')
+ rest_repo = g.get_repo('Azure/azure-rest-api-specs')
+ label1 = sdk_repo.get_label('ManagementPlane')
+ open_issues = sdk_repo.get_issues(state='open', labels=[label1])
issue_status = []
duplicated_issue = dict()
start_time = time.time()
@@ -150,7 +151,7 @@ def main():
elif item.comment_num == 0 and 'Python' in item.labels:
item.bot_advice = 'new issue and better to confirm quickly.'
if 'auto-link' not in item.labels:
- if not update_issue_body(item.link):
+ if not update_issue_body(sdk_repo, rest_repo, item.link):
item.bot_advice = 'failed to modify the body of the new issue. Please modify manually'
item.labels.append('attention')
item.labels.append('auto-link')
From fafae8e30cc8dbb36add670658438ce3a7458ca5 Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Tue, 24 Aug 2021 10:23:39 +0800
Subject: [PATCH 10/65] Update update_issue_body.py
---
scripts/release_issue_status/update_issue_body.py | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/scripts/release_issue_status/update_issue_body.py b/scripts/release_issue_status/update_issue_body.py
index 0831a6dbc60d..173eb2cf8894 100644
--- a/scripts/release_issue_status/update_issue_body.py
+++ b/scripts/release_issue_status/update_issue_body.py
@@ -4,12 +4,9 @@
from github import Github
-def update_issue_body(issue_link):
+def update_issue_body(sdk_repo, rest_repo, issue_link):
# Get Issue Number
issue_number = int(issue_link.replace("https://github.com/Azure/sdk-release-request/issues/", ""))
- g = Github(os.getenv('TOKEN'))
- sdk_repo = g.get_repo('Azure/sdk-release-request')
- rest_repo = g.get_repo('Azure/azure-rest-api-specs')
issue_info = sdk_repo.get_issue(number=issue_number)
issue_body = issue_info.body
From fba944dc5527c89443a598d5c8578ed13599ce21 Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Tue, 24 Aug 2021 10:53:43 +0800
Subject: [PATCH 11/65] Update update_issue_body.py
---
scripts/release_issue_status/update_issue_body.py | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/scripts/release_issue_status/update_issue_body.py b/scripts/release_issue_status/update_issue_body.py
index 173eb2cf8894..8e48e4665c25 100644
--- a/scripts/release_issue_status/update_issue_body.py
+++ b/scripts/release_issue_status/update_issue_body.py
@@ -1,9 +1,5 @@
-import os
import re
-from github import Github
-
-
def update_issue_body(sdk_repo, rest_repo, issue_link):
# Get Issue Number
issue_number = int(issue_link.replace("https://github.com/Azure/sdk-release-request/issues/", ""))
@@ -92,3 +88,5 @@ def get_pkname_and_readme_from_pull(rest_repo, pr_link):
break
readme_link = 'https://github.com/Azure/azure-rest-api-specs/blob/main/specification/{}/' \
'resource-manager/readme.python.md'.format(pk_url_name)
+
+ return package_name, readme_link
From 256fb625916a15333a5edd60cfe3081b47bc96e5 Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Tue, 24 Aug 2021 10:59:47 +0800
Subject: [PATCH 12/65] Update main.py
---
scripts/release_issue_status/main.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index db8a341fa293..c833662a1cca 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -158,7 +158,7 @@ def main():
item.issue_object.set_labels(*item.labels)
try:
time.sleep(3)
- reply = rg.ReplyGenerator(issue_object=item.issue_object)
+ reply = rg.ReplyGenerator(issue_object=item.issue_object, rest_repo)
reply.run()
except Exception as e:
print('Error from auto reply ========================')
From ff27a87f856f57b07948406c9f025c8030b83e4e Mon Sep 17 00:00:00 2001
From: Zed Lei <59104634+RAY-316@users.noreply.github.com>
Date: Tue, 24 Aug 2021 11:06:25 +0800
Subject: [PATCH 13/65] Update reply_generator.py
---
.../release_issue_status/reply_generator.py | 29 ++++++++++---------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/scripts/release_issue_status/reply_generator.py b/scripts/release_issue_status/reply_generator.py
index a69ba69abb47..12123842431f 100644
--- a/scripts/release_issue_status/reply_generator.py
+++ b/scripts/release_issue_status/reply_generator.py
@@ -1,34 +1,29 @@
-from github import Github
import re
-import os
class ReplyGenerator(object):
- def __init__(self, issue_object):
+ def __init__(self, issue_object, rest_repo):
+ self.repo = rest_repo
self.issue_object = issue_object
- self.labels = [label.name for label in self.issue_object.labels]
+ self.labels = []
self.comments = self.issue_object.get_comments()
self.body = self.issue_object.body
self.body_parse = {}
- self._body_parse()
self.rest_specs_object = None
self.whether_change_readme = False
- self._whether_change_readme()
self.whl_link = None
self.changelog_content = None
self.latest_pr_number = None
def _whether_change_readme(self):
- g = Github(os.getenv('TOKEN'))
- repo = g.get_repo('Azure/azure-rest-api-specs')
- self.rest_specs_object = repo
- contents = repo.get_contents(self.body_parse['readme_path'])
+ self.rest_specs_object = self.repo
+ contents = self.repo.get_contents(self.body_parse['readme_path'])
contents = str(contents.decoded_content)
pattern_tag = re.compile(r'tag: package-[\w+-.]+')
package_tag = pattern_tag.search(contents).group()
package_tag = package_tag.split(':')[1].strip()
- readme_python_contents = str(repo.get_contents(self.body_parse['readme_python_path']).decoded_content)
+ readme_python_contents = str(self.repo.get_contents(self.body_parse['readme_python_path']).decoded_content)
whether_multi_api = 'multi-api' in readme_python_contents
whether_same_tag = package_tag == self.body_parse['readme_tag']
self.whether_change_readme = not (whether_same_tag and (not whether_multi_api or 'MultiAPI' in self.labels))
@@ -80,9 +75,12 @@ def _swagger_generator_parse(self, context):
print('track1 generate error')
pattern_python = re.compile(' azure-sdk-for-python-track2.+?', re.DOTALL)
python = re.search(pattern_python, context).group()
- prttern_python_track2 = re.compile('\s*?- \s*?', re.DOTALL)
- python_track2_info = re.search(prttern_python_track2, python).group()
- track2_info_model = '
python-track2
{} '.format(python_track2_info)
+ # the way that reply not contains [Release SDK Changes]
+ # pattern_python_track2 = re.compile('\s*?- \s*?', re.DOTALL)
+ pattern_python_track2 = re.compile('track2_.*
', re.DOTALL)
+ python_track2_info = re.search(pattern_python_track2, python).group()
+ track2_info_model = ' python-track2
{} '.format(
+ python_track2_info)
info_model = 'hi @{} Please check the package whether works well and the changelog info is as below:\n' \
'{}\n{}\n' \
'\n* (The version of the package is only a temporary version for testing)\n' \
@@ -100,6 +98,9 @@ def add_label(self, label_name):
self.issue_object.set_labels(*self.labels)
def run(self):
+ self.labels = [label.name for label in self.issue_object.labels]
+ self._body_parse()
+ self._whether_change_readme()
if not self.whether_change_readme:
self.latest_pr_number = self._get_latest_pr_from_readme()
reply_content = self._latest_pr_parse()
From 9bbde53f445dc3f4e09ad2e4f0f9b01e26966d23 Mon Sep 17 00:00:00 2001
From: Zed Lei <59104634+RAY-316@users.noreply.github.com>
Date: Tue, 24 Aug 2021 11:07:22 +0800
Subject: [PATCH 14/65] Update main.py
---
scripts/release_issue_status/main.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index c833662a1cca..93a42238b65b 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -158,7 +158,7 @@ def main():
item.issue_object.set_labels(*item.labels)
try:
time.sleep(3)
- reply = rg.ReplyGenerator(issue_object=item.issue_object, rest_repo)
+ reply = rg.ReplyGenerator(issue_object=item.issue_object, rest_repo=rest_repo)
reply.run()
except Exception as e:
print('Error from auto reply ========================')
From c065cf70f8612adced6a40da72fc164a8c346319 Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Wed, 25 Aug 2021 15:45:25 +0800
Subject: [PATCH 15/65] Update update_issue_body.py
---
scripts/release_issue_status/update_issue_body.py | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/scripts/release_issue_status/update_issue_body.py b/scripts/release_issue_status/update_issue_body.py
index 8e48e4665c25..52389cd1c7a9 100644
--- a/scripts/release_issue_status/update_issue_body.py
+++ b/scripts/release_issue_status/update_issue_body.py
@@ -20,8 +20,7 @@ def update_issue_body(sdk_repo, rest_repo, issue_link):
try:
package_name, readme_link = get_pkname_and_readme_link(rest_repo, link)
except Exception as e:
- print(e)
- return False
+ raise e
readme_link = readme_link.replace('python.', '')
issue_body_list.insert(0, f'\n{readme_link}')
@@ -33,10 +32,8 @@ def update_issue_body(sdk_repo, rest_repo, issue_link):
issue_body_up += raw + '\n'
try:
issue_info.edit(body=issue_body_up)
- return True
except Exception as e:
- print(e)
- return False
+ raise e
def get_pkname_and_readme_link(rest_repo, link):
From 80007ac0a053084fe7b26d3252f3dfed3a60fdf1 Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Wed, 25 Aug 2021 15:47:03 +0800
Subject: [PATCH 16/65] Update main.py
---
scripts/release_issue_status/main.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index 93a42238b65b..6274f367111a 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -151,13 +151,15 @@ def main():
elif item.comment_num == 0 and 'Python' in item.labels:
item.bot_advice = 'new issue and better to confirm quickly.'
if 'auto-link' not in item.labels:
- if not update_issue_body(sdk_repo, rest_repo, item.link):
+ try:
+ update_issue_body(sdk_repo, rest_repo, item.link)
+ except Exception as e:
item.bot_advice = 'failed to modify the body of the new issue. Please modify manually'
item.labels.append('attention')
item.labels.append('auto-link')
item.issue_object.set_labels(*item.labels)
try:
- time.sleep(3)
+ time.sleep(5)
reply = rg.ReplyGenerator(issue_object=item.issue_object, rest_repo=rest_repo)
reply.run()
except Exception as e:
From bef41b175e426ad9549e6fe6cccc791121ac968f Mon Sep 17 00:00:00 2001
From: msyyc <70930885+msyyc@users.noreply.github.com>
Date: Wed, 25 Aug 2021 15:57:34 +0800
Subject: [PATCH 17/65] Update
scripts/release_issue_status/update_issue_body.py
---
scripts/release_issue_status/update_issue_body.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/release_issue_status/update_issue_body.py b/scripts/release_issue_status/update_issue_body.py
index 52389cd1c7a9..c40599edf99a 100644
--- a/scripts/release_issue_status/update_issue_body.py
+++ b/scripts/release_issue_status/update_issue_body.py
@@ -37,7 +37,7 @@ def update_issue_body(sdk_repo, rest_repo, issue_link):
def get_pkname_and_readme_link(rest_repo, link):
- # change commit link to pull json link
+ # change commit link to pull json link(i.e. https://github.com/Azure/azure-rest-api-specs/commit/77f5d3b5d2fbae17621ea124485788f496786758#diff-708c2fb843b022cac4af8c6f996a527440c1e0d328abb81f54670747bf14ab1a)
pk_name = ''
if 'commit' in link:
commit_sha = link.split('commit/')[-1]
From 2682c0e41a3f43a4b5896447f299a20777858b6f Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Wed, 25 Aug 2021 17:16:48 +0800
Subject: [PATCH 18/65] Update update_issue_body.py
---
.../release_issue_status/update_issue_body.py | 57 +++++++++----------
1 file changed, 27 insertions(+), 30 deletions(-)
diff --git a/scripts/release_issue_status/update_issue_body.py b/scripts/release_issue_status/update_issue_body.py
index c40599edf99a..d9101e432947 100644
--- a/scripts/release_issue_status/update_issue_body.py
+++ b/scripts/release_issue_status/update_issue_body.py
@@ -1,5 +1,6 @@
import re
+
def update_issue_body(sdk_repo, rest_repo, issue_link):
# Get Issue Number
issue_number = int(issue_link.replace("https://github.com/Azure/sdk-release-request/issues/", ""))
@@ -46,8 +47,33 @@ def get_pkname_and_readme_link(rest_repo, link):
# if link is a pr, it can get both pakeage name and readme link.
if 'pull' in link:
- pk_name, readme_link = get_pkname_and_readme_from_pull(rest_repo, link)
+ pr_number = int(link.replace("https://github.com/Azure/azure-rest-api-specs/pull/", "").strip('/'))
+ pr_info = rest_repo.get_issue(number=pr_number)
+ # Get package name
+ pr_comments = pr_info.get_comments()
+ pk_names = []
+ for comment in pr_comments:
+ if "Swagger Generation Artifacts" in comment.body:
+ pk_names = re.findall(r"track\d_(.*?)", comment.body)
+ break
+
+ if len(pk_names) != 1:
+ raise Exception('muliple package names exist')
+ pk_name = pk_names[0]
+
+ # Get Readme link
+ pr_info1 = rest_repo.get_pull(number=pr_number)
+ for pr_changed_file in pr_info1.get_files():
+ contents_url = pr_changed_file.contents_url
+ if '/resource-manager' in contents_url:
+ pk_url_name = re.findall(r'/specification/(.*?)/resource-manager/', contents_url)[0]
+ break
+ readme_link = 'https://github.com/Azure/azure-rest-api-specs/blob/main/specification/{}/' \
+ 'resource-manager/readme.python.md'.format(pk_url_name)
+
+ # if link is a rest url(i.e. https://github.com/Azure/azure-rest-api-specs/blob/main/specification/xxx/resource-manager/readme.python.md)
elif '/resource-manager' not in link:
+ # (i.e. https://github.com/Azure/azure-rest-api-specs/tree/main/specification/xxxx)
readme_link = link + '/resource-manager/readme.python.md'
else:
readme_link = link.split('/resource-manager')[0] + '/resource-manager/readme.python.md'
@@ -58,32 +84,3 @@ def get_pkname_and_readme_link(rest_repo, link):
pk_name = re.findall(r'package-name: (.*?)\\n', readme_contents)[0]
return pk_name, readme_link
-
-
-def get_pkname_and_readme_from_pull(rest_repo, pr_link):
- pr_number = int(pr_link.replace("https://github.com/Azure/azure-rest-api-specs/pull/", "").strip('/'))
- pr_info = rest_repo.get_issue(number=pr_number)
-
- # Get package name
- pr_comments = pr_info.get_comments()
- package_names = []
- for comment in pr_comments:
- if "Swagger Generation Artifacts" in comment.body:
- package_names = re.findall(r"track\d_(.*?)", comment.body)
- break
-
- if len(package_names) != 1:
- return '', ''
- package_name = package_names[0]
-
- # Get Readme link
- pr_info1 = rest_repo.get_pull(number=pr_number)
- for pr_changed_file in pr_info1.get_files():
- contents_url = pr_changed_file.contents_url
- if '/resource-manager' in contents_url:
- pk_url_name = re.findall(r'/specification/(.*?)/resource-manager/', contents_url)[0]
- break
- readme_link = 'https://github.com/Azure/azure-rest-api-specs/blob/main/specification/{}/' \
- 'resource-manager/readme.python.md'.format(pk_url_name)
-
- return package_name, readme_link
From af36ccc190abdfa5d455334a4193670afd80671b Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Fri, 27 Aug 2021 14:21:24 +0800
Subject: [PATCH 19/65] Update main.py
---
scripts/release_issue_status/main.py | 69 ++++++++++++++++++++++------
1 file changed, 54 insertions(+), 15 deletions(-)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index 6274f367111a..3dadb56ed126 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -6,11 +6,12 @@
import subprocess as sp
from azure.storage.blob import BlobClient
import reply_generator as rg
-from update_issue_body import update_issue_body
+from update_issue_body import update_issue_body, find_readme_link
import traceback
_NULL = ' '
_FILE_OUT = 'release_issue_status.csv'
+_FILE_OUT_PYTHON = 'release_python_status.md
_PYTHON_SDK_ADMINISTRATORS = {'msyyc', 'RAY-316', 'BigCat20196'}
def my_print(cmd):
@@ -22,6 +23,20 @@ def print_check(cmd):
sp.check_call(cmd, shell=True)
+def output_python_md(issue_status_python):
+ with open(_FILE_OUT_PYTHON, 'w') as file_out:
+ file_out.write('| issue | author | package | assignee | bot advice | created date of issue | delay from created date |\n')
+ file_out.write('| ------ | ------ | ------ | ------ | ------ | ------ | :-----: |\n')
+ file_out.writelines([item.output_python() for item in sorted(issue_status_python, key=_key_select)])
+
+
+def output_csv(issue_status):
+ with open(_FILE_OUT, 'w') as file_out:
+ file_out.write('language,issue,author,package,created date,delay from created date,latest update time,'
+ 'delay from latest update,status,bot advice\n')
+ file_out.writelines([item.output() for item in sorted(issue_status, key=_key_select)])
+
+
class IssueStatus:
link = _NULL
author = _NULL
@@ -38,6 +53,7 @@ class IssueStatus:
whether_author_comment = True
issue_object = _NULL
labels = _NULL
+ assignee = _NULL
def output(self):
return '{},{},{},{},{},{},{},{},{},{}\n'.format(self.language, self.link, self.author,
@@ -48,6 +64,13 @@ def output(self):
self.delay_from_latest_update,
self.status, self.bot_advice)
+
+ def output_python(self):
+ return '| [#{}]({}) | {} | {} | {} | {} | {} | {} |\n'.format(self.link.split('/')[-1], self.link, self.author,
+ self.package, self.assignee, self.bot_advice,
+ str(date.fromtimestamp(self.create_date)),
+ self.delay_from_create_date)
+
def _extract(str_list, key_word):
for item in str_list:
@@ -87,9 +110,10 @@ def _extract_author_latest_comment(comments):
def _whether_author_comment(comments):
q = set(comment.user.login for comment in comments)
- diff = q.difference(_PYTHON_SDK_ADMINISTRATORS)
+ for administrators in _PYTHON_SDK_ADMINISTRATORS:
+ q.discard(administrators)
- return len(diff) > 0
+ return True if len(q) > 0 else False
def _latest_comment_time(comments, delay_from_create_date):
@@ -108,6 +132,7 @@ def main():
label1 = sdk_repo.get_label('ManagementPlane')
open_issues = sdk_repo.get_issues(state='open', labels=[label1])
issue_status = []
+ issue_status_python = []
duplicated_issue = dict()
start_time = time.time()
for item in open_issues:
@@ -129,7 +154,9 @@ def main():
issue.issue_object = item
issue.labels = [label.name for label in item.labels]
issue.days_from_latest_commit = _latest_comment_time(item.get_comments(), issue.delay_from_create_date)
-
+ if item.assignee:
+ issue.assignee = item.assignee.login
+
issue_status.append(issue)
key = (issue.language, issue.package)
duplicated_issue[key] = duplicated_issue.get(key, 0) + 1
@@ -152,17 +179,24 @@ def main():
item.bot_advice = 'new issue and better to confirm quickly.'
if 'auto-link' not in item.labels:
try:
- update_issue_body(sdk_repo, rest_repo, item.link)
+ readme_link = update_issue_body(sdk_repo, rest_repo, item.link)
except Exception as e:
item.bot_advice = 'failed to modify the body of the new issue. Please modify manually'
item.labels.append('attention')
item.labels.append('auto-link')
item.issue_object.set_labels(*item.labels)
+ else:
+ try:
+ readme_link = find_readme_link(sdk_repo, item.issue_object.number)
+ except Exception as e:
+ print('Issue: {} updates body failed'.format(item.issue_object.number))
+ item.bot_advice = 'failed to find Readme link, Please check !!'
+ item.labels.append('attention')
+ continue
try:
- time.sleep(5)
- reply = rg.ReplyGenerator(issue_object=item.issue_object, rest_repo=rest_repo)
- reply.run()
+ reply = rg.begin_reply_generate(issue_object=item.issue_object, rest_repo=rest_repo, readme_link=readme_link)
except Exception as e:
+ item.bot_advice = 'auto reply failed, Please intervene manually !!'
print('Error from auto reply ========================')
print('Issue:{}'.format(item.issue_object.number))
print(traceback.format_exc())
@@ -173,10 +207,9 @@ def main():
if item.days_from_latest_commit >= 30 and item.language == 'Python' and '30days attention' not in item.labels:
item.labels.append('30days attention')
item.issue_object.set_labels(*item.labels)
- item.issue_object.create_comment(f'hi @{item.author}, the issue is closed since there is no reply for a long time. Please reopen it if necessary or create new one.')
- item.issue_object.edit(state='close')
+ issue.issue_object.edit(state='close')
elif item.days_from_latest_commit >= 15 and item.language == 'Python' and '15days attention' not in item.labels:
- item.issue_object.create_comment(f'hi @{item.author}, this release-request has been delayed more than 15 days,'
+ item.issue_object.create_comment('hi @{} ,this release-request has been delayed more than 15 days,'
' please deal with it ASAP. We will close the issue if there is still no response after 15 days!')
item.labels.append('15days attention')
item.issue_object.set_labels(*item.labels)
@@ -184,12 +217,13 @@ def main():
# judge whether there is duplicated issue for same package
if item.package != _NULL and duplicated_issue.get((item.language, item.package)) > 1:
item.bot_advice = f'Warning:There is duplicated issue for {item.package}. ' + item.bot_advice
+
+ if item.language == 'Python':
+ issue_status_python.append(item)
# output result
- with open(_FILE_OUT, 'w') as file_out:
- file_out.write('language,issue,author,package,created date,delay from created date,latest update time,'
- 'delay from latest update,status,bot advice\n')
- file_out.writelines([item.output() for item in sorted(issue_status, key=_key_select)])
+ output_python_md(issue_status_python)
+ output_csv(issue_status)
# commit to github
print_check('git add .')
@@ -201,6 +235,11 @@ def main():
blob_name=_FILE_OUT)
with open(_FILE_OUT, 'rb') as data:
blob.upload_blob(data, overwrite=True)
+
+ blob_1 = BlobClient.from_connection_string(conn_str=os.getenv('CONN_STR'), container_name=os.getenv('FILE'),
+ blob_name=_FILE_OUT_PYTHON)
+ with open(_FILE_OUT_PYTHON, 'rb') as data:
+ blob_1.upload_blob(data, overwrite=True)
if __name__ == '__main__':
From 922314665c01b7224651891151cefb7153a40fe0 Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Fri, 27 Aug 2021 14:22:19 +0800
Subject: [PATCH 20/65] Update reply_generator.py
---
.../release_issue_status/reply_generator.py | 98 +++++++++----------
1 file changed, 45 insertions(+), 53 deletions(-)
diff --git a/scripts/release_issue_status/reply_generator.py b/scripts/release_issue_status/reply_generator.py
index 12123842431f..84e83a786945 100644
--- a/scripts/release_issue_status/reply_generator.py
+++ b/scripts/release_issue_status/reply_generator.py
@@ -1,47 +1,37 @@
import re
+link_dict = {}
-class ReplyGenerator(object):
- def __init__(self, issue_object, rest_repo):
- self.repo = rest_repo
- self.issue_object = issue_object
- self.labels = []
- self.comments = self.issue_object.get_comments()
- self.body = self.issue_object.body
- self.body_parse = {}
- self.rest_specs_object = None
- self.whether_change_readme = False
- self.whl_link = None
- self.changelog_content = None
- self.latest_pr_number = None
-
- def _whether_change_readme(self):
- self.rest_specs_object = self.repo
- contents = self.repo.get_contents(self.body_parse['readme_path'])
- contents = str(contents.decoded_content)
+def begin_reply_generate(issue_object, rest_repo, readme_link):
+ def weather_change_readme():
+ # to see whether need change readme
+ contents = str(rest_repo.get_contents(link_dict['readme_path']).decoded_content)
pattern_tag = re.compile(r'tag: package-[\w+-.]+')
package_tag = pattern_tag.search(contents).group()
package_tag = package_tag.split(':')[1].strip()
- readme_python_contents = str(self.repo.get_contents(self.body_parse['readme_python_path']).decoded_content)
+ readme_python_contents = str(rest_repo.get_contents(link_dict['readme_python_path']).decoded_content)
whether_multi_api = 'multi-api' in readme_python_contents
- whether_same_tag = package_tag == self.body_parse['readme_tag']
- self.whether_change_readme = not (whether_same_tag and (not whether_multi_api or 'MultiAPI' in self.labels))
+ whether_same_tag = package_tag == link_dict['readme_tag']
+ whether_change_readme = not whether_same_tag or whether_multi_api and not 'MultiAPI' in labels
+ return whether_change_readme
- def _body_parse(self):
+ # parse owner's comment and get links
+ def get_links():
+ comment_body = issue_object.body
pattern_readme = re.compile(r'/specification/([\w-]+/)+readme.md')
pattern_resource_manager = re.compile(r'/specification/([\w-]+/)+resource-manager')
pattern_tag = re.compile(r'package-[\w+-.]+')
- readme_path = pattern_readme.search(self.body).group()
- readme_tag = pattern_tag.search(self.body).group()
- resource_manager = pattern_resource_manager.search(self.body).group()
- self.body_parse['readme_path'] = readme_path
- self.body_parse['readme_python_path'] = readme_path[:readme_path.rfind('/')] + '/readme.python.md'
- self.body_parse['readme_tag'] = readme_tag
- self.body_parse['resource_manager'] = resource_manager
+ readme_path = pattern_readme.search(readme_link).group()
+ readme_tag = pattern_tag.search(comment_body).group()
+ resource_manager = pattern_resource_manager.search(readme_link).group()
+ link_dict['readme_path'] = readme_path
+ link_dict['readme_python_path'] = readme_path[:readme_path.rfind('/')] + '/readme.python.md'
+ link_dict['readme_tag'] = readme_tag
+ link_dict['resource_manager'] = resource_manager
- def _get_latest_pr_from_readme(self):
- commits = self.rest_specs_object.get_commits(path=self.body_parse['resource_manager'])
+ def get_latest_pr_from_readme():
+ commits = rest_repo.get_commits(path=link_dict['resource_manager'])
latest_commit = [commit for commit in commits][0]
latest_pr_brief = latest_commit.commit.message
latest_pr_number = re.findall('\(\#[0-9]+\)', latest_pr_brief)
@@ -53,15 +43,15 @@ def _get_latest_pr_from_readme(self):
return latest_pr_number_int[-1]
- def _latest_pr_parse(self):
- latest_pr = self.rest_specs_object.get_issue(self.latest_pr_number)
+ def latest_pr_parse():
+ latest_pr = rest_repo.get_issue(latest_pr_number)
latest_pr_comments = latest_pr.get_comments()
b = [i for i in latest_pr_comments]
for comment in latest_pr_comments:
if 'Swagger Generation Artifacts
' in comment.body:
- return self._swagger_generator_parse(comment.body)
+ return swagger_generator_parse(comment.body, issue_object, latest_pr_number)
- def _swagger_generator_parse(self, context):
+ def swagger_generator_parse(context, issue_object, latest_pr_number):
track1_info_model = ''
try:
if ' azure-sdk-for-python' in context:
@@ -85,26 +75,28 @@ def _swagger_generator_parse(self, context):
'{}\n{}\n' \
'\n* (The version of the package is only a temporary version for testing)\n' \
'\nhttps://github.com/Azure/azure-rest-api-specs/pull/{}\n' \
- .format(self.issue_object.user.login, track1_info_model, track2_info_model, str(self.latest_pr_number))
+ .format(issue_object.user.login, track1_info_model, track2_info_model, str(latest_pr_number))
return info_model
- def reply_owner(self, reply_content):
- self.issue_object.create_comment(reply_content)
+ def reply_owner():
+ issue_object.create_comment(reply_content)
+
+ def add_label(label_name):
+ if label_name not in labels:
+ labels.append(label_name)
+ issue_object.set_labels(*labels)
- def add_label(self, label_name):
- if label_name not in self.labels:
- self.labels.append(label_name)
- self.issue_object.set_labels(*self.labels)
+ get_links()
+ whether_change_readme = weather_change_readme()
+ # get issue labels
+ labels = [label.name for label in issue_object.labels]
- def run(self):
- self.labels = [label.name for label in self.issue_object.labels]
- self._body_parse()
- self._whether_change_readme()
- if not self.whether_change_readme:
- self.latest_pr_number = self._get_latest_pr_from_readme()
- reply_content = self._latest_pr_parse()
- self.reply_owner(reply_content)
- self.add_label('P1')
- else:
- print('issue {} need config readme***********'.format(self.issue_object.number))
+ if not whether_change_readme:
+ # get the latest pr about service
+ latest_pr_number = get_latest_pr_from_readme()
+ reply_content = latest_pr_parse()
+ reply_owner()
+ add_label('P1')
+ else:
+ print('issue {} need config readme***********'.format(issue_object.number))
From 8ee91fe9a0058e9e97f92228ec75e934d1b3afcb Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Fri, 27 Aug 2021 14:28:50 +0800
Subject: [PATCH 21/65] Update update_issue_body.py
---
.../release_issue_status/update_issue_body.py | 66 ++++++++++---------
1 file changed, 34 insertions(+), 32 deletions(-)
diff --git a/scripts/release_issue_status/update_issue_body.py b/scripts/release_issue_status/update_issue_body.py
index d9101e432947..60deba92405c 100644
--- a/scripts/release_issue_status/update_issue_body.py
+++ b/scripts/release_issue_status/update_issue_body.py
@@ -1,9 +1,8 @@
import re
-def update_issue_body(sdk_repo, rest_repo, issue_link):
+def update_issue_body(sdk_repo, rest_repo, issue_number):
# Get Issue Number
- issue_number = int(issue_link.replace("https://github.com/Azure/sdk-release-request/issues/", ""))
issue_info = sdk_repo.get_issue(number=issue_number)
issue_body = issue_info.body
@@ -18,24 +17,19 @@ def update_issue_body(sdk_repo, rest_repo, issue_link):
link = link.split(']')[0]
link = link.replace('[', "").replace(']', "").replace('(', "").replace(')', "")
- try:
- package_name, readme_link = get_pkname_and_readme_link(rest_repo, link)
- except Exception as e:
- raise e
+ package_name, readme_link = get_pkname_and_readme_link(rest_repo, link)
- readme_link = readme_link.replace('python.', '')
- issue_body_list.insert(0, f'\n{readme_link}')
+ issue_body_list.insert(0, f'\n{readme_link.replace("/readme.md", "")}')
issue_body_list.insert(1, package_name)
issue_body_up = ''
for raw in issue_body_list:
if raw == '---\r' or raw == '---':
issue_body_up += '\n'
issue_body_up += raw + '\n'
- try:
- issue_info.edit(body=issue_body_up)
- except Exception as e:
- raise e
+ issue_info.edit(body=issue_body_up)
+ return readme_link
+
def get_pkname_and_readme_link(rest_repo, link):
# change commit link to pull json link(i.e. https://github.com/Azure/azure-rest-api-specs/commit/77f5d3b5d2fbae17621ea124485788f496786758#diff-708c2fb843b022cac4af8c6f996a527440c1e0d328abb81f54670747bf14ab1a)
@@ -48,29 +42,24 @@ def get_pkname_and_readme_link(rest_repo, link):
# if link is a pr, it can get both pakeage name and readme link.
if 'pull' in link:
pr_number = int(link.replace("https://github.com/Azure/azure-rest-api-specs/pull/", "").strip('/'))
- pr_info = rest_repo.get_issue(number=pr_number)
- # Get package name
- pr_comments = pr_info.get_comments()
- pk_names = []
- for comment in pr_comments:
- if "Swagger Generation Artifacts" in comment.body:
- pk_names = re.findall(r"track\d_(.*?)", comment.body)
- break
-
- if len(pk_names) != 1:
- raise Exception('muliple package names exist')
- pk_name = pk_names[0]
# Get Readme link
- pr_info1 = rest_repo.get_pull(number=pr_number)
- for pr_changed_file in pr_info1.get_files():
+ pr_info = rest_repo.get_pull(number=pr_number)
+ pk_url_name = ''
+ for pr_changed_file in pr_info.get_files():
contents_url = pr_changed_file.contents_url
if '/resource-manager' in contents_url:
- pk_url_name = re.findall(r'/specification/(.*?)/resource-manager/', contents_url)[0]
- break
+ pk_url_name1 = re.findall(r'/specification/(.*?)/resource-manager/', contents_url)[0]
+ if not pk_url_name:
+ pk_url_name = pk_url_name1
+ elif pk_url_name != pk_url_name1:
+ print("\nexists multiple package names: {}, {} \n".format(pk_url_name, pk_url_name1))
+ raise Exception('Not find readme link, because it exists multiple package names')
+
readme_link = 'https://github.com/Azure/azure-rest-api-specs/blob/main/specification/{}/' \
'resource-manager/readme.python.md'.format(pk_url_name)
+
# if link is a rest url(i.e. https://github.com/Azure/azure-rest-api-specs/blob/main/specification/xxx/resource-manager/readme.python.md)
elif '/resource-manager' not in link:
# (i.e. https://github.com/Azure/azure-rest-api-specs/tree/main/specification/xxxx)
@@ -78,9 +67,22 @@ def get_pkname_and_readme_link(rest_repo, link):
else:
readme_link = link.split('/resource-manager')[0] + '/resource-manager/readme.python.md'
# get the package name by readme link
- if not pk_name:
- readme_link_part = '/specification' + readme_link.split('/specification')[-1]
- readme_contents = str(rest_repo.get_contents(readme_link_part).decoded_content)
- pk_name = re.findall(r'package-name: (.*?)\\n', readme_contents)[0]
+ readme_link_part = '/specification' + readme_link.split('/specification')[-1]
+ readme_contents = str(rest_repo.get_contents(readme_link_part).decoded_content)
+ pk_name = re.findall(r'package-name: (.*?)\\n', readme_contents)[0]
+ readme_link = readme_link.replace('python.', '')
return pk_name, readme_link
+
+
+def find_readme_link(sdk_repo, issue_number):
+ # Get Issue Number
+ issue_info = sdk_repo.get_issue(number=issue_number)
+ issue_body = issue_info.body
+ issue_body_list = issue_body.split("\n")
+ for row in issue_body_list:
+ if 'resource-manager' in row:
+ readme_link = row + '/readme.md'
+ return readme_link
+ else:
+ raise Exception('Not find readme link,please check')
From bef133c3823ae21109c7d6190fec90ffa4ddf88d Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Fri, 27 Aug 2021 14:58:41 +0800
Subject: [PATCH 22/65] Update main.py
---
scripts/release_issue_status/main.py | 5 -----
1 file changed, 5 deletions(-)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index 3dadb56ed126..810aa8897dcc 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -236,11 +236,6 @@ def main():
with open(_FILE_OUT, 'rb') as data:
blob.upload_blob(data, overwrite=True)
- blob_1 = BlobClient.from_connection_string(conn_str=os.getenv('CONN_STR'), container_name=os.getenv('FILE'),
- blob_name=_FILE_OUT_PYTHON)
- with open(_FILE_OUT_PYTHON, 'rb') as data:
- blob_1.upload_blob(data, overwrite=True)
-
if __name__ == '__main__':
main()
From 9dfd084ab76026445e79ad4a71c68e89000bc399 Mon Sep 17 00:00:00 2001
From: msyyc <70930885+msyyc@users.noreply.github.com>
Date: Fri, 27 Aug 2021 15:33:29 +0800
Subject: [PATCH 23/65] Update scripts/release_issue_status/main.py
---
scripts/release_issue_status/main.py | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index 810aa8897dcc..48dad55c61a5 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -110,10 +110,7 @@ def _extract_author_latest_comment(comments):
def _whether_author_comment(comments):
q = set(comment.user.login for comment in comments)
- for administrators in _PYTHON_SDK_ADMINISTRATORS:
- q.discard(administrators)
-
- return True if len(q) > 0 else False
+ diff = q.difference(_PYTHON_SDK_ADMINISTRATORS)
def _latest_comment_time(comments, delay_from_create_date):
From 51f92fd7da007d97e104f621288e64005441573c Mon Sep 17 00:00:00 2001
From: msyyc <70930885+msyyc@users.noreply.github.com>
Date: Fri, 27 Aug 2021 15:34:30 +0800
Subject: [PATCH 24/65] Update main.py
---
scripts/release_issue_status/main.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index 48dad55c61a5..da8f83903223 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -111,7 +111,7 @@ def _extract_author_latest_comment(comments):
def _whether_author_comment(comments):
q = set(comment.user.login for comment in comments)
diff = q.difference(_PYTHON_SDK_ADMINISTRATORS)
-
+ return len(diff) > 0
def _latest_comment_time(comments, delay_from_create_date):
q = [(comment.updated_at.timestamp(), comment.user.login)
From 5259157abd9e4c22a63f7016defa12048c2ee399 Mon Sep 17 00:00:00 2001
From: msyyc <70930885+msyyc@users.noreply.github.com>
Date: Fri, 27 Aug 2021 15:35:19 +0800
Subject: [PATCH 25/65] Update scripts/release_issue_status/main.py
---
scripts/release_issue_status/main.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index da8f83903223..ffc6d83ffe03 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -206,7 +206,7 @@ def main():
item.issue_object.set_labels(*item.labels)
issue.issue_object.edit(state='close')
elif item.days_from_latest_commit >= 15 and item.language == 'Python' and '15days attention' not in item.labels:
- item.issue_object.create_comment('hi @{} ,this release-request has been delayed more than 15 days,'
+ item.issue_object.create_comment(f'hi @{item.author}, this release-request has been delayed more than 15 days,'
' please deal with it ASAP. We will close the issue if there is still no response after 15 days!')
item.labels.append('15days attention')
item.issue_object.set_labels(*item.labels)
From 6949bfbadb1338defd1d8453cc3eedc5c870e9c8 Mon Sep 17 00:00:00 2001
From: msyyc <70930885+msyyc@users.noreply.github.com>
Date: Fri, 27 Aug 2021 15:35:59 +0800
Subject: [PATCH 26/65] Update scripts/release_issue_status/main.py
---
scripts/release_issue_status/main.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index ffc6d83ffe03..5ae6e4af50ac 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -204,6 +204,7 @@ def main():
if item.days_from_latest_commit >= 30 and item.language == 'Python' and '30days attention' not in item.labels:
item.labels.append('30days attention')
item.issue_object.set_labels(*item.labels)
+ item.issue_object.create_comment(f'hi @{item.author}, the issue is closed since there is no reply for a long time. Please reopen it if necessary or create new one.')
issue.issue_object.edit(state='close')
elif item.days_from_latest_commit >= 15 and item.language == 'Python' and '15days attention' not in item.labels:
item.issue_object.create_comment(f'hi @{item.author}, this release-request has been delayed more than 15 days,'
From 7b14fd2a5e589b71f840374e60cb3ace52d14236 Mon Sep 17 00:00:00 2001
From: msyyc <70930885+msyyc@users.noreply.github.com>
Date: Fri, 27 Aug 2021 15:37:00 +0800
Subject: [PATCH 27/65] Update scripts/release_issue_status/main.py
---
scripts/release_issue_status/main.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index 5ae6e4af50ac..04abdbf5c712 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -205,7 +205,7 @@ def main():
item.labels.append('30days attention')
item.issue_object.set_labels(*item.labels)
item.issue_object.create_comment(f'hi @{item.author}, the issue is closed since there is no reply for a long time. Please reopen it if necessary or create new one.')
- issue.issue_object.edit(state='close')
+ item.issue_object.edit(state='close')
elif item.days_from_latest_commit >= 15 and item.language == 'Python' and '15days attention' not in item.labels:
item.issue_object.create_comment(f'hi @{item.author}, this release-request has been delayed more than 15 days,'
' please deal with it ASAP. We will close the issue if there is still no response after 15 days!')
From 7d3fab83a0fe23561dccd19581f99f5067032206 Mon Sep 17 00:00:00 2001
From: msyyc <70930885+msyyc@users.noreply.github.com>
Date: Fri, 27 Aug 2021 15:56:34 +0800
Subject: [PATCH 28/65] Update
scripts/release_issue_status/update_issue_body.py
---
scripts/release_issue_status/update_issue_body.py | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/scripts/release_issue_status/update_issue_body.py b/scripts/release_issue_status/update_issue_body.py
index 60deba92405c..8163835f8552 100644
--- a/scripts/release_issue_status/update_issue_body.py
+++ b/scripts/release_issue_status/update_issue_body.py
@@ -84,5 +84,4 @@ def find_readme_link(sdk_repo, issue_number):
if 'resource-manager' in row:
readme_link = row + '/readme.md'
return readme_link
- else:
- raise Exception('Not find readme link,please check')
+ raise Exception('Not find readme link,please check')
From f07b5b2e04c69cb9dc1a2532c67fe4617d8fecf3 Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Fri, 27 Aug 2021 16:08:11 +0800
Subject: [PATCH 29/65] Update scripts/release_issue_status/main.py
---
scripts/release_issue_status/main.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index 04abdbf5c712..717490a520d8 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -180,6 +180,7 @@ def main():
except Exception as e:
item.bot_advice = 'failed to modify the body of the new issue. Please modify manually'
item.labels.append('attention')
+ continue
item.labels.append('auto-link')
item.issue_object.set_labels(*item.labels)
else:
From b39342b77a3477bb5046236709b9ec0fa101d44f Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Fri, 27 Aug 2021 16:33:11 +0800
Subject: [PATCH 30/65] Update
scripts/release_issue_status/update_issue_body.py
---
scripts/release_issue_status/update_issue_body.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/scripts/release_issue_status/update_issue_body.py b/scripts/release_issue_status/update_issue_body.py
index 8163835f8552..07772271357b 100644
--- a/scripts/release_issue_status/update_issue_body.py
+++ b/scripts/release_issue_status/update_issue_body.py
@@ -49,7 +49,10 @@ def get_pkname_and_readme_link(rest_repo, link):
for pr_changed_file in pr_info.get_files():
contents_url = pr_changed_file.contents_url
if '/resource-manager' in contents_url:
- pk_url_name1 = re.findall(r'/specification/(.*?)/resource-manager/', contents_url)[0]
+ try:
+ pk_url_name1 = re.findall(r'/specification/(.*?)/resource-manager/', contents_url)[0]
+ except Exception as e:
+ continue
if not pk_url_name:
pk_url_name = pk_url_name1
elif pk_url_name != pk_url_name1:
From 44d4de9763329e9794dd4e638c47d5963ffcf106 Mon Sep 17 00:00:00 2001
From: Zed Lei <59104634+RAY-316@users.noreply.github.com>
Date: Fri, 27 Aug 2021 16:39:14 +0800
Subject: [PATCH 31/65] Update reply_generator.py
---
.../release_issue_status/reply_generator.py | 193 +++++++++---------
1 file changed, 101 insertions(+), 92 deletions(-)
diff --git a/scripts/release_issue_status/reply_generator.py b/scripts/release_issue_status/reply_generator.py
index 84e83a786945..af1b55a7d27d 100644
--- a/scripts/release_issue_status/reply_generator.py
+++ b/scripts/release_issue_status/reply_generator.py
@@ -1,102 +1,111 @@
import re
-link_dict = {}
+issue_object_rg = None
+
+
+def weather_change_readme(rest_repo, link_dict, labels):
+ # to see whether need change readme
+ contents = str(rest_repo.get_contents(link_dict['readme_path']).decoded_content)
+ pattern_tag = re.compile(r'tag: package-[\w+-.]+')
+ package_tag = pattern_tag.search(contents).group()
+ package_tag = package_tag.split(':')[1].strip()
+ readme_python_contents = str(rest_repo.get_contents(link_dict['readme_python_path']).decoded_content)
+ whether_multi_api = 'multi-api' in readme_python_contents
+ whether_same_tag = package_tag == link_dict['readme_tag']
+ whether_change_readme = not whether_same_tag or whether_multi_api and not 'MultiAPI' in labels
+ return whether_change_readme
+
+
+# parse owner's comment and get links
+def get_links(readme_link):
+ link_dict = {}
+ comment_body = issue_object_rg.body
+ pattern_readme = re.compile(r'/specification/([\w-]+/)+readme.md')
+ pattern_resource_manager = re.compile(r'/specification/([\w-]+/)+resource-manager')
+ pattern_tag = re.compile(r'package-[\w+-.]+')
+ readme_path = pattern_readme.search(readme_link).group()
+ readme_tag = pattern_tag.search(comment_body).group()
+ resource_manager = pattern_resource_manager.search(readme_link).group()
+ link_dict['readme_path'] = readme_path
+ link_dict['readme_python_path'] = readme_path[:readme_path.rfind('/')] + '/readme.python.md'
+ link_dict['readme_tag'] = readme_tag
+ link_dict['resource_manager'] = resource_manager
+ return link_dict
+
+
+def get_latest_pr_from_readme(rest_repo, link_dict):
+ commits = rest_repo.get_commits(path=link_dict['resource_manager'])
+ latest_commit = [commit for commit in commits][0]
+ latest_pr_brief = latest_commit.commit.message
+ latest_pr_number = re.findall('\(\#[0-9]+\)', latest_pr_brief)
+ latest_pr_number_int = []
+ for number in latest_pr_number:
+ number = int(re.search('\d+', number).group())
+ latest_pr_number_int.append(number)
+ latest_pr_number_int.sort()
+
+ return latest_pr_number_int[-1]
+
+
+def latest_pr_parse(rest_repo, latest_pr_number):
+ latest_pr = rest_repo.get_issue(latest_pr_number)
+ latest_pr_comments = latest_pr.get_comments()
+ b = [i for i in latest_pr_comments]
+ for comment in latest_pr_comments:
+ if 'Swagger Generation Artifacts
' in comment.body:
+ return swagger_generator_parse(comment.body, latest_pr_number)
+
+
+def swagger_generator_parse(context, latest_pr_number):
+ track1_info_model = ''
+ try:
+ if ' azure-sdk-for-python' in context:
+ pattern_python_t1 = re.compile(' azure-sdk-for-python.+?', re.DOTALL)
+ python_t1 = re.search(pattern_python_t1, context).group()
+ prttern_python_track1 = re.compile('\s+?- \s+?', re.DOTALL)
+ python_track1_info = re.search(prttern_python_track1, python_t1).group()
+ track1_info_model = '
python-track1
{} '.format(
+ python_track1_info)
+ except Exception as e:
+ print('track1 generate error')
+ pattern_python = re.compile(' azure-sdk-for-python-track2.+?', re.DOTALL)
+ python = re.search(pattern_python, context).group()
+ # the way that reply not contains [Release SDK Changes]
+ # pattern_python_track2 = re.compile('\s*?- \s*?', re.DOTALL)
+ pattern_python_track2 = re.compile('track2_.*
', re.DOTALL)
+ python_track2_info = re.search(pattern_python_track2, python).group()
+ track2_info_model = ' python-track2
{} '.format(
+ python_track2_info)
+ info_model = 'hi @{} Please check the package whether works well and the changelog info is as below:\n' \
+ '{}\n{}\n' \
+ '\n* (The version of the package is only a temporary version for testing)\n' \
+ '\nhttps://github.com/Azure/azure-rest-api-specs/pull/{}\n' \
+ .format(issue_object_rg.user.login, track1_info_model, track2_info_model, str(latest_pr_number))
+
+ return info_model
+
+
+def reply_owner(reply_content):
+ issue_object_rg.create_comment(reply_content)
+
+
+def add_label(label_name, labels):
+ if label_name not in labels:
+ labels.append(label_name)
+ issue_object_rg.set_labels(*labels)
def begin_reply_generate(issue_object, rest_repo, readme_link):
- def weather_change_readme():
- # to see whether need change readme
- contents = str(rest_repo.get_contents(link_dict['readme_path']).decoded_content)
- pattern_tag = re.compile(r'tag: package-[\w+-.]+')
- package_tag = pattern_tag.search(contents).group()
- package_tag = package_tag.split(':')[1].strip()
- readme_python_contents = str(rest_repo.get_contents(link_dict['readme_python_path']).decoded_content)
- whether_multi_api = 'multi-api' in readme_python_contents
- whether_same_tag = package_tag == link_dict['readme_tag']
- whether_change_readme = not whether_same_tag or whether_multi_api and not 'MultiAPI' in labels
- return whether_change_readme
-
- # parse owner's comment and get links
- def get_links():
- comment_body = issue_object.body
- pattern_readme = re.compile(r'/specification/([\w-]+/)+readme.md')
- pattern_resource_manager = re.compile(r'/specification/([\w-]+/)+resource-manager')
- pattern_tag = re.compile(r'package-[\w+-.]+')
- readme_path = pattern_readme.search(readme_link).group()
- readme_tag = pattern_tag.search(comment_body).group()
- resource_manager = pattern_resource_manager.search(readme_link).group()
- link_dict['readme_path'] = readme_path
- link_dict['readme_python_path'] = readme_path[:readme_path.rfind('/')] + '/readme.python.md'
- link_dict['readme_tag'] = readme_tag
- link_dict['resource_manager'] = resource_manager
-
- def get_latest_pr_from_readme():
- commits = rest_repo.get_commits(path=link_dict['resource_manager'])
- latest_commit = [commit for commit in commits][0]
- latest_pr_brief = latest_commit.commit.message
- latest_pr_number = re.findall('\(\#[0-9]+\)', latest_pr_brief)
- latest_pr_number_int = []
- for number in latest_pr_number:
- number = int(re.search('\d+', number).group())
- latest_pr_number_int.append(number)
- latest_pr_number_int.sort()
-
- return latest_pr_number_int[-1]
-
- def latest_pr_parse():
- latest_pr = rest_repo.get_issue(latest_pr_number)
- latest_pr_comments = latest_pr.get_comments()
- b = [i for i in latest_pr_comments]
- for comment in latest_pr_comments:
- if 'Swagger Generation Artifacts
' in comment.body:
- return swagger_generator_parse(comment.body, issue_object, latest_pr_number)
-
- def swagger_generator_parse(context, issue_object, latest_pr_number):
- track1_info_model = ''
- try:
- if ' azure-sdk-for-python' in context:
- pattern_python_t1 = re.compile(' azure-sdk-for-python.+?', re.DOTALL)
- python_t1 = re.search(pattern_python_t1, context).group()
- prttern_python_track1 = re.compile('\s+?- \s+?', re.DOTALL)
- python_track1_info = re.search(prttern_python_track1, python_t1).group()
- track1_info_model = '
python-track1
{} '.format(
- python_track1_info)
- except Exception as e:
- print('track1 generate error')
- pattern_python = re.compile(' azure-sdk-for-python-track2.+?', re.DOTALL)
- python = re.search(pattern_python, context).group()
- # the way that reply not contains [Release SDK Changes]
- # pattern_python_track2 = re.compile('\s*?- \s*?', re.DOTALL)
- pattern_python_track2 = re.compile('track2_.*
', re.DOTALL)
- python_track2_info = re.search(pattern_python_track2, python).group()
- track2_info_model = ' python-track2
{} '.format(
- python_track2_info)
- info_model = 'hi @{} Please check the package whether works well and the changelog info is as below:\n' \
- '{}\n{}\n' \
- '\n* (The version of the package is only a temporary version for testing)\n' \
- '\nhttps://github.com/Azure/azure-rest-api-specs/pull/{}\n' \
- .format(issue_object.user.login, track1_info_model, track2_info_model, str(latest_pr_number))
-
- return info_model
-
- def reply_owner():
- issue_object.create_comment(reply_content)
-
- def add_label(label_name):
- if label_name not in labels:
- labels.append(label_name)
- issue_object.set_labels(*labels)
-
- get_links()
- whether_change_readme = weather_change_readme()
- # get issue labels
+ global issue_object_rg
+ issue_object_rg = issue_object
+ link_dict = get_links(readme_link)
labels = [label.name for label in issue_object.labels]
+ whether_change_readme = weather_change_readme(rest_repo, link_dict, labels)
if not whether_change_readme:
- # get the latest pr about service
- latest_pr_number = get_latest_pr_from_readme()
- reply_content = latest_pr_parse()
- reply_owner()
- add_label('P1')
+ latest_pr_number = get_latest_pr_from_readme(rest_repo,link_dict)
+ reply_content = latest_pr_parse(rest_repo, latest_pr_number)
+ reply_owner(reply_content)
+ add_label('P1', labels)
else:
print('issue {} need config readme***********'.format(issue_object.number))
From 86b603a00c7016ef0173b13c591915f64e7ea384 Mon Sep 17 00:00:00 2001
From: Zed Lei <59104634+RAY-316@users.noreply.github.com>
Date: Fri, 27 Aug 2021 16:47:57 +0800
Subject: [PATCH 32/65] Update main.py
---
scripts/release_issue_status/main.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index 717490a520d8..75c56f4edb70 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -11,7 +11,7 @@
_NULL = ' '
_FILE_OUT = 'release_issue_status.csv'
-_FILE_OUT_PYTHON = 'release_python_status.md
+_FILE_OUT_PYTHON = 'release_python_status.md'
_PYTHON_SDK_ADMINISTRATORS = {'msyyc', 'RAY-316', 'BigCat20196'}
def my_print(cmd):
From b9abd0f29af4784a9b9c2f9f84b1a35a79e98c0b Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Mon, 30 Aug 2021 13:40:25 +0800
Subject: [PATCH 33/65] Update
scripts/release_issue_status/update_issue_body.py
Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
---
scripts/release_issue_status/update_issue_body.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/release_issue_status/update_issue_body.py b/scripts/release_issue_status/update_issue_body.py
index 07772271357b..beedc6a00409 100644
--- a/scripts/release_issue_status/update_issue_body.py
+++ b/scripts/release_issue_status/update_issue_body.py
@@ -45,7 +45,7 @@ def get_pkname_and_readme_link(rest_repo, link):
# Get Readme link
pr_info = rest_repo.get_pull(number=pr_number)
- pk_url_name = ''
+ pk_url_name = {}
for pr_changed_file in pr_info.get_files():
contents_url = pr_changed_file.contents_url
if '/resource-manager' in contents_url:
From 7ae26ce618085aa54ce93285468b8a90c6bbc0f4 Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Mon, 30 Aug 2021 13:40:29 +0800
Subject: [PATCH 34/65] Update
scripts/release_issue_status/update_issue_body.py
Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
---
scripts/release_issue_status/update_issue_body.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/release_issue_status/update_issue_body.py b/scripts/release_issue_status/update_issue_body.py
index beedc6a00409..e754e6a79906 100644
--- a/scripts/release_issue_status/update_issue_body.py
+++ b/scripts/release_issue_status/update_issue_body.py
@@ -50,7 +50,7 @@ def get_pkname_and_readme_link(rest_repo, link):
contents_url = pr_changed_file.contents_url
if '/resource-manager' in contents_url:
try:
- pk_url_name1 = re.findall(r'/specification/(.*?)/resource-manager/', contents_url)[0]
+ pk_url_name.add(re.findall(r'/specification/(.*?)/resource-manager/', contents_url)[0])
except Exception as e:
continue
if not pk_url_name:
From e4b3ed8905388f0d5a9bcff6465dd5060c3e873a Mon Sep 17 00:00:00 2001
From: Zed Lei <59104634+RAY-316@users.noreply.github.com>
Date: Mon, 30 Aug 2021 13:42:01 +0800
Subject: [PATCH 35/65] Update reply_generator.py
---
scripts/release_issue_status/reply_generator.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/release_issue_status/reply_generator.py b/scripts/release_issue_status/reply_generator.py
index af1b55a7d27d..f043ee70db1f 100644
--- a/scripts/release_issue_status/reply_generator.py
+++ b/scripts/release_issue_status/reply_generator.py
@@ -106,6 +106,6 @@ def begin_reply_generate(issue_object, rest_repo, readme_link):
latest_pr_number = get_latest_pr_from_readme(rest_repo,link_dict)
reply_content = latest_pr_parse(rest_repo, latest_pr_number)
reply_owner(reply_content)
- add_label('P1', labels)
+ add_label('auto-ask-check', labels)
else:
print('issue {} need config readme***********'.format(issue_object.number))
From b587233613425489d56526d714ad6bb0e99f421d Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Mon, 30 Aug 2021 13:42:52 +0800
Subject: [PATCH 36/65] Update update_issue_body.py
---
scripts/release_issue_status/update_issue_body.py | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/scripts/release_issue_status/update_issue_body.py b/scripts/release_issue_status/update_issue_body.py
index e754e6a79906..8995c6fd98ff 100644
--- a/scripts/release_issue_status/update_issue_body.py
+++ b/scripts/release_issue_status/update_issue_body.py
@@ -53,9 +53,7 @@ def get_pkname_and_readme_link(rest_repo, link):
pk_url_name.add(re.findall(r'/specification/(.*?)/resource-manager/', contents_url)[0])
except Exception as e:
continue
- if not pk_url_name:
- pk_url_name = pk_url_name1
- elif pk_url_name != pk_url_name1:
+ if len(pk_url_name) > 1:
print("\nexists multiple package names: {}, {} \n".format(pk_url_name, pk_url_name1))
raise Exception('Not find readme link, because it exists multiple package names')
From 5ca4ac18541dd797b5d5e9c48e6d23c000fab6f6 Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Mon, 30 Aug 2021 14:11:15 +0800
Subject: [PATCH 37/65] Update main.py
---
scripts/release_issue_status/main.py | 53 ++++++++++++++++------------
1 file changed, 30 insertions(+), 23 deletions(-)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index 75c56f4edb70..d5e33d54a55f 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -121,6 +121,34 @@ def _latest_comment_time(comments, delay_from_create_date):
return delay_from_create_date if not q else int((time.time() - q[-1][0]) / 3600 / 24)
+def auto_reply(item, sdk_repo, rest_repo):
+ if 'auto-link' not in item.labels:
+ try:
+ readme_link = update_issue_body(sdk_repo, rest_repo, item.link)
+ except Exception as e:
+ item.bot_advice = 'failed to modify the body of the new issue. Please modify manually'
+ item.labels.append('attention')
+ raise
+ item.labels.append('auto-link')
+ item.issue_object.set_labels(*item.labels)
+ else:
+ try:
+ readme_link = find_readme_link(sdk_repo, item.issue_object.number)
+ except Exception as e:
+ print('Issue: {} updates body failed'.format(item.issue_object.number))
+ item.bot_advice = 'failed to find Readme link, Please check !!'
+ item.labels.append('attention')
+ raise
+ try:
+ reply = rg.begin_reply_generate(issue_object=item.issue_object, rest_repo=rest_repo, readme_link=readme_link)
+ except Exception as e:
+ item.bot_advice = 'auto reply failed, Please intervene manually !!'
+ print('Error from auto reply ========================')
+ print('Issue:{}'.format(item.issue_object.number))
+ print(traceback.format_exc())
+ print('==============================================')
+
+
def main():
# get latest issue status
g = Github(os.getenv('TOKEN')) # please fill user_token
@@ -174,31 +202,10 @@ def main():
item.bot_advice = 'new comment for author.'
elif item.comment_num == 0 and 'Python' in item.labels:
item.bot_advice = 'new issue and better to confirm quickly.'
- if 'auto-link' not in item.labels:
- try:
- readme_link = update_issue_body(sdk_repo, rest_repo, item.link)
- except Exception as e:
- item.bot_advice = 'failed to modify the body of the new issue. Please modify manually'
- item.labels.append('attention')
- continue
- item.labels.append('auto-link')
- item.issue_object.set_labels(*item.labels)
- else:
- try:
- readme_link = find_readme_link(sdk_repo, item.issue_object.number)
- except Exception as e:
- print('Issue: {} updates body failed'.format(item.issue_object.number))
- item.bot_advice = 'failed to find Readme link, Please check !!'
- item.labels.append('attention')
- continue
try:
- reply = rg.begin_reply_generate(issue_object=item.issue_object, rest_repo=rest_repo, readme_link=readme_link)
+ auto_reply(item, sdk_repo, rest_repo)
except Exception as e:
- item.bot_advice = 'auto reply failed, Please intervene manually !!'
- print('Error from auto reply ========================')
- print('Issue:{}'.format(item.issue_object.number))
- print(traceback.format_exc())
- print('==============================================')
+ continue
elif item.delay_from_latest_update >= 7:
item.bot_advice = 'delay for a long time and better to handle now.'
From 262d323ed58227a7fd9acb2a2c998eb50fdbd1de Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Mon, 30 Aug 2021 14:57:21 +0800
Subject: [PATCH 38/65] Update main.py
---
scripts/release_issue_status/main.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index d5e33d54a55f..5510839ec3d5 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -124,7 +124,7 @@ def _latest_comment_time(comments, delay_from_create_date):
def auto_reply(item, sdk_repo, rest_repo):
if 'auto-link' not in item.labels:
try:
- readme_link = update_issue_body(sdk_repo, rest_repo, item.link)
+ readme_link = update_issue_body(sdk_repo, rest_repo, item.issue_object.number)
except Exception as e:
item.bot_advice = 'failed to modify the body of the new issue. Please modify manually'
item.labels.append('attention')
From df737f24d51901d97e0e811aa71b86793ef76fe8 Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Mon, 30 Aug 2021 15:37:34 +0800
Subject: [PATCH 39/65] Update update_issue_body.py
---
scripts/release_issue_status/update_issue_body.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/release_issue_status/update_issue_body.py b/scripts/release_issue_status/update_issue_body.py
index 8995c6fd98ff..29ae13022883 100644
--- a/scripts/release_issue_status/update_issue_body.py
+++ b/scripts/release_issue_status/update_issue_body.py
@@ -28,7 +28,7 @@ def update_issue_body(sdk_repo, rest_repo, issue_number):
issue_body_up += raw + '\n'
issue_info.edit(body=issue_body_up)
- return readme_link
+ return package_name, readme_link
def get_pkname_and_readme_link(rest_repo, link):
From b792d312427ee5cedd328c09fcce4f31245eb7e0 Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Mon, 30 Aug 2021 15:47:46 +0800
Subject: [PATCH 40/65] Update main.py
---
scripts/release_issue_status/main.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index 5510839ec3d5..5b3cf1f5fedf 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -124,7 +124,10 @@ def _latest_comment_time(comments, delay_from_create_date):
def auto_reply(item, sdk_repo, rest_repo):
if 'auto-link' not in item.labels:
try:
- readme_link = update_issue_body(sdk_repo, rest_repo, item.issue_object.number)
+ package_name, readme_link = update_issue_body(sdk_repo, rest_repo, item.issue_object.number)
+ item.package = package_name
+ key = (issue.language, issue.package)
+ duplicated_issue[key] = duplicated_issue.get(key, 0) + 1
except Exception as e:
item.bot_advice = 'failed to modify the body of the new issue. Please modify manually'
item.labels.append('attention')
From c34adbf5eec147e3af82fa6723207574984f7b21 Mon Sep 17 00:00:00 2001
From: msyyc <70930885+msyyc@users.noreply.github.com>
Date: Mon, 30 Aug 2021 15:59:41 +0800
Subject: [PATCH 41/65] Update scripts/release_issue_status/main.py
---
scripts/release_issue_status/main.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index 5b3cf1f5fedf..ef15875ac6eb 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -201,7 +201,7 @@ def main():
for item in issue_status:
if item.status == 'release':
item.bot_advice = 'better to release asap.'
- elif item.author == item.author_latest_comment:
+ elif not item.author_latest_comment in _PYTHON_SDK_ADMINISTRATORS:
item.bot_advice = 'new comment for author.'
elif item.comment_num == 0 and 'Python' in item.labels:
item.bot_advice = 'new issue and better to confirm quickly.'
From 962683e2fe29e1f50189bab363284f882ca6afe8 Mon Sep 17 00:00:00 2001
From: Zed Lei <59104634+RAY-316@users.noreply.github.com>
Date: Mon, 30 Aug 2021 16:01:06 +0800
Subject: [PATCH 42/65] Update main.py
---
scripts/release_issue_status/main.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index ef15875ac6eb..404e5102b1c5 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -143,7 +143,7 @@ def auto_reply(item, sdk_repo, rest_repo):
item.labels.append('attention')
raise
try:
- reply = rg.begin_reply_generate(issue_object=item.issue_object, rest_repo=rest_repo, readme_link=readme_link)
+ reply = rg.begin_reply_generate(issue_object=item, rest_repo=rest_repo, readme_link=readme_link)
except Exception as e:
item.bot_advice = 'auto reply failed, Please intervene manually !!'
print('Error from auto reply ========================')
From b59c2b9a75cd26cfaa903973dfa2115f4941b9ef Mon Sep 17 00:00:00 2001
From: Zed Lei <59104634+RAY-316@users.noreply.github.com>
Date: Mon, 30 Aug 2021 16:38:31 +0800
Subject: [PATCH 43/65] Update reply_generator.py
---
scripts/release_issue_status/reply_generator.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/scripts/release_issue_status/reply_generator.py b/scripts/release_issue_status/reply_generator.py
index f043ee70db1f..f0cd175c81af 100644
--- a/scripts/release_issue_status/reply_generator.py
+++ b/scripts/release_issue_status/reply_generator.py
@@ -95,11 +95,11 @@ def add_label(label_name, labels):
issue_object_rg.set_labels(*labels)
-def begin_reply_generate(issue_object, rest_repo, readme_link):
+def begin_reply_generate(item, rest_repo, readme_link):
global issue_object_rg
- issue_object_rg = issue_object
+ issue_object_rg = item.issue_object
link_dict = get_links(readme_link)
- labels = [label.name for label in issue_object.labels]
+ labels = item.labels
whether_change_readme = weather_change_readme(rest_repo, link_dict, labels)
if not whether_change_readme:
From 91f68276b2e1ff9658e41840f5bad2d61d013823 Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Mon, 30 Aug 2021 16:53:05 +0800
Subject: [PATCH 44/65] Update main.py
---
scripts/release_issue_status/main.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index 404e5102b1c5..82e430add873 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -122,9 +122,11 @@ def _latest_comment_time(comments, delay_from_create_date):
def auto_reply(item, sdk_repo, rest_repo):
+ print("+++++++++++issue number: {}".format(item.issue_object.number))
if 'auto-link' not in item.labels:
try:
package_name, readme_link = update_issue_body(sdk_repo, rest_repo, item.issue_object.number)
+ print("----------------pkname, readme", package_name, readme_link)
item.package = package_name
key = (issue.language, issue.package)
duplicated_issue[key] = duplicated_issue.get(key, 0) + 1
From 2cbf44ad4e1fa21c9d5f5144d3ab4c1508916342 Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Mon, 30 Aug 2021 16:57:24 +0800
Subject: [PATCH 45/65] Update main.py
---
scripts/release_issue_status/main.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index 82e430add873..3f62d869d958 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -207,6 +207,7 @@ def main():
item.bot_advice = 'new comment for author.'
elif item.comment_num == 0 and 'Python' in item.labels:
item.bot_advice = 'new issue and better to confirm quickly.'
+ print("#########", item.issue_object.number)
try:
auto_reply(item, sdk_repo, rest_repo)
except Exception as e:
From 28f1be0693ab7e782af0ed826c13c79366ce3785 Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Mon, 30 Aug 2021 17:22:58 +0800
Subject: [PATCH 46/65] Update main.py
---
scripts/release_issue_status/main.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index 3f62d869d958..fdae7249809b 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -203,7 +203,7 @@ def main():
for item in issue_status:
if item.status == 'release':
item.bot_advice = 'better to release asap.'
- elif not item.author_latest_comment in _PYTHON_SDK_ADMINISTRATORS:
+ elif item.author_latest_comment and not item.author_latest_comment in _PYTHON_SDK_ADMINISTRATORS:
item.bot_advice = 'new comment for author.'
elif item.comment_num == 0 and 'Python' in item.labels:
item.bot_advice = 'new issue and better to confirm quickly.'
From 9c6adec21ca536a4b5ee43f3ff4709dee71011bc Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Mon, 30 Aug 2021 17:34:54 +0800
Subject: [PATCH 47/65] Update main.py
---
scripts/release_issue_status/main.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index fdae7249809b..61632628fbd9 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -201,6 +201,8 @@ def main():
# rule6: if delay from created date is over 30 days and owner never reply, close it.
# rule7: if delay from created date is over 15 days and owner never reply, remind owner to handle it.
for item in issue_status:
+ if item.issue_object.number in [1826, 1896]:
+ print("1111111111--: ", item.author_latest_comment)
if item.status == 'release':
item.bot_advice = 'better to release asap.'
elif item.author_latest_comment and not item.author_latest_comment in _PYTHON_SDK_ADMINISTRATORS:
From d021e85e7d7f87a8b5db770780bfde5b10ffbb0d Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Mon, 30 Aug 2021 17:41:54 +0800
Subject: [PATCH 48/65] Update main.py
---
scripts/release_issue_status/main.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index 61632628fbd9..0b0d13ba4e20 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -205,7 +205,7 @@ def main():
print("1111111111--: ", item.author_latest_comment)
if item.status == 'release':
item.bot_advice = 'better to release asap.'
- elif item.author_latest_comment and not item.author_latest_comment in _PYTHON_SDK_ADMINISTRATORS:
+ elif (item.author_latest_comment) and (not item.author_latest_comment in _PYTHON_SDK_ADMINISTRATORS):
item.bot_advice = 'new comment for author.'
elif item.comment_num == 0 and 'Python' in item.labels:
item.bot_advice = 'new issue and better to confirm quickly.'
From 9f05d43cce3997c71fd4bd42754a60f51d1ca72a Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Mon, 30 Aug 2021 17:48:29 +0800
Subject: [PATCH 49/65] Update main.py
---
scripts/release_issue_status/main.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index 0b0d13ba4e20..80283584c4c3 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -205,8 +205,6 @@ def main():
print("1111111111--: ", item.author_latest_comment)
if item.status == 'release':
item.bot_advice = 'better to release asap.'
- elif (item.author_latest_comment) and (not item.author_latest_comment in _PYTHON_SDK_ADMINISTRATORS):
- item.bot_advice = 'new comment for author.'
elif item.comment_num == 0 and 'Python' in item.labels:
item.bot_advice = 'new issue and better to confirm quickly.'
print("#########", item.issue_object.number)
@@ -214,6 +212,8 @@ def main():
auto_reply(item, sdk_repo, rest_repo)
except Exception as e:
continue
+ elif not item.author_latest_comment in _PYTHON_SDK_ADMINISTRATORS:
+ item.bot_advice = 'new comment for author.'
elif item.delay_from_latest_update >= 7:
item.bot_advice = 'delay for a long time and better to handle now.'
From 3a83841b18f9fc25010793243eb87e343c5ecefa Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Tue, 31 Aug 2021 09:08:40 +0800
Subject: [PATCH 50/65] Update main.py
---
scripts/release_issue_status/main.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index 80283584c4c3..44cd0a92c215 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -209,7 +209,7 @@ def main():
item.bot_advice = 'new issue and better to confirm quickly.'
print("#########", item.issue_object.number)
try:
- auto_reply(item, sdk_repo, rest_repo)
+ auto_reply(item, sdk_repo, rest_repo, duplicated_issue)
except Exception as e:
continue
elif not item.author_latest_comment in _PYTHON_SDK_ADMINISTRATORS:
From 05cf904aafedebb73a7df785f552e176d3d2c2be Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Tue, 31 Aug 2021 09:15:06 +0800
Subject: [PATCH 51/65] Update main.py
---
scripts/release_issue_status/main.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index 44cd0a92c215..99edd76d5793 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -121,7 +121,7 @@ def _latest_comment_time(comments, delay_from_create_date):
return delay_from_create_date if not q else int((time.time() - q[-1][0]) / 3600 / 24)
-def auto_reply(item, sdk_repo, rest_repo):
+def auto_reply(item, sdk_repo, rest_repo, duplicated_issue):
print("+++++++++++issue number: {}".format(item.issue_object.number))
if 'auto-link' not in item.labels:
try:
From 529ed2458e5a03b197e6468c92ae2cd88e1e8131 Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Tue, 31 Aug 2021 09:28:28 +0800
Subject: [PATCH 52/65] Update main.py
---
scripts/release_issue_status/main.py | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index 99edd76d5793..5b157f80ee98 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -128,11 +128,12 @@ def auto_reply(item, sdk_repo, rest_repo, duplicated_issue):
package_name, readme_link = update_issue_body(sdk_repo, rest_repo, item.issue_object.number)
print("----------------pkname, readme", package_name, readme_link)
item.package = package_name
- key = (issue.language, issue.package)
+ key = ('Python', item.package)
duplicated_issue[key] = duplicated_issue.get(key, 0) + 1
except Exception as e:
item.bot_advice = 'failed to modify the body of the new issue. Please modify manually'
item.labels.append('attention')
+ print(e)
raise
item.labels.append('auto-link')
item.issue_object.set_labels(*item.labels)
@@ -201,13 +202,10 @@ def main():
# rule6: if delay from created date is over 30 days and owner never reply, close it.
# rule7: if delay from created date is over 15 days and owner never reply, remind owner to handle it.
for item in issue_status:
- if item.issue_object.number in [1826, 1896]:
- print("1111111111--: ", item.author_latest_comment)
if item.status == 'release':
item.bot_advice = 'better to release asap.'
elif item.comment_num == 0 and 'Python' in item.labels:
item.bot_advice = 'new issue and better to confirm quickly.'
- print("#########", item.issue_object.number)
try:
auto_reply(item, sdk_repo, rest_repo, duplicated_issue)
except Exception as e:
From ad02d861ca36f8240b0fb6ef20348b933182ced4 Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Tue, 31 Aug 2021 09:41:11 +0800
Subject: [PATCH 53/65] Update update_issue_body.py
---
scripts/release_issue_status/update_issue_body.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/scripts/release_issue_status/update_issue_body.py b/scripts/release_issue_status/update_issue_body.py
index 29ae13022883..694d2515269d 100644
--- a/scripts/release_issue_status/update_issue_body.py
+++ b/scripts/release_issue_status/update_issue_body.py
@@ -5,7 +5,7 @@ def update_issue_body(sdk_repo, rest_repo, issue_number):
# Get Issue Number
issue_info = sdk_repo.get_issue(number=issue_number)
issue_body = issue_info.body
-
+ print("Got the issue body")
issue_body_list = [i for i in issue_body.split("\n") if i]
# Get the link in issue body
for row in issue_body_list:
@@ -45,6 +45,7 @@ def get_pkname_and_readme_link(rest_repo, link):
# Get Readme link
pr_info = rest_repo.get_pull(number=pr_number)
+ print("Got the PR")
pk_url_name = {}
for pr_changed_file in pr_info.get_files():
contents_url = pr_changed_file.contents_url
From d8c9fd2640be09cd4dc74ad3187bc4b07f96a4d6 Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Tue, 31 Aug 2021 09:42:45 +0800
Subject: [PATCH 54/65] Update main.py
---
scripts/release_issue_status/main.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index 5b157f80ee98..20903240e760 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -228,7 +228,7 @@ def main():
# judge whether there is duplicated issue for same package
if item.package != _NULL and duplicated_issue.get((item.language, item.package)) > 1:
- item.bot_advice = f'Warning:There is duplicated issue for {item.package}. ' + item.bot_advice
+ item.bot_advice = f'Warning:There is duplicated issue for {item.package}.
' + item.bot_advice
if item.language == 'Python':
issue_status_python.append(item)
From e5fd8a184ddb192f696c99ee4532145d5605cbc7 Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Tue, 31 Aug 2021 09:47:33 +0800
Subject: [PATCH 55/65] Update update_issue_body.py
---
scripts/release_issue_status/update_issue_body.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/release_issue_status/update_issue_body.py b/scripts/release_issue_status/update_issue_body.py
index 694d2515269d..f0419779d380 100644
--- a/scripts/release_issue_status/update_issue_body.py
+++ b/scripts/release_issue_status/update_issue_body.py
@@ -5,7 +5,6 @@ def update_issue_body(sdk_repo, rest_repo, issue_number):
# Get Issue Number
issue_info = sdk_repo.get_issue(number=issue_number)
issue_body = issue_info.body
- print("Got the issue body")
issue_body_list = [i for i in issue_body.split("\n") if i]
# Get the link in issue body
for row in issue_body_list:
@@ -27,7 +26,9 @@ def update_issue_body(sdk_repo, rest_repo, issue_number):
issue_body_up += '\n'
issue_body_up += raw + '\n'
+ print("begin to update body")
issue_info.edit(body=issue_body_up)
+ print("update body success")
return package_name, readme_link
@@ -45,7 +46,6 @@ def get_pkname_and_readme_link(rest_repo, link):
# Get Readme link
pr_info = rest_repo.get_pull(number=pr_number)
- print("Got the PR")
pk_url_name = {}
for pr_changed_file in pr_info.get_files():
contents_url = pr_changed_file.contents_url
From 5be276ad533cd9f9aacd2c02b7bcbb043911ebcd Mon Sep 17 00:00:00 2001
From: Zed Lei <59104634+RAY-316@users.noreply.github.com>
Date: Tue, 31 Aug 2021 09:48:21 +0800
Subject: [PATCH 56/65] Update reply_generator.py
---
scripts/release_issue_status/reply_generator.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/release_issue_status/reply_generator.py b/scripts/release_issue_status/reply_generator.py
index f0cd175c81af..dbe6494bd7d1 100644
--- a/scripts/release_issue_status/reply_generator.py
+++ b/scripts/release_issue_status/reply_generator.py
@@ -108,4 +108,4 @@ def begin_reply_generate(item, rest_repo, readme_link):
reply_owner(reply_content)
add_label('auto-ask-check', labels)
else:
- print('issue {} need config readme***********'.format(issue_object.number))
+ print('issue {} need config readme***********'.format(issue_object_rg.number))
From a49bcde1172a3602cbcbaad52ed73973207cbfcf Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Tue, 31 Aug 2021 09:53:08 +0800
Subject: [PATCH 57/65] Update update_issue_body.py
---
scripts/release_issue_status/update_issue_body.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/scripts/release_issue_status/update_issue_body.py b/scripts/release_issue_status/update_issue_body.py
index f0419779d380..aa13f2132172 100644
--- a/scripts/release_issue_status/update_issue_body.py
+++ b/scripts/release_issue_status/update_issue_body.py
@@ -47,6 +47,7 @@ def get_pkname_and_readme_link(rest_repo, link):
# Get Readme link
pr_info = rest_repo.get_pull(number=pr_number)
pk_url_name = {}
+ print("Got file change")
for pr_changed_file in pr_info.get_files():
contents_url = pr_changed_file.contents_url
if '/resource-manager' in contents_url:
@@ -70,6 +71,7 @@ def get_pkname_and_readme_link(rest_repo, link):
readme_link = link.split('/resource-manager')[0] + '/resource-manager/readme.python.md'
# get the package name by readme link
readme_link_part = '/specification' + readme_link.split('/specification')[-1]
+ print("Get Readme contents")
readme_contents = str(rest_repo.get_contents(readme_link_part).decoded_content)
pk_name = re.findall(r'package-name: (.*?)\\n', readme_contents)[0]
readme_link = readme_link.replace('python.', '')
From cb053b0929ad4cbb54236128ec48a9d8751eedf4 Mon Sep 17 00:00:00 2001
From: Zed Lei <59104634+RAY-316@users.noreply.github.com>
Date: Tue, 31 Aug 2021 09:58:49 +0800
Subject: [PATCH 58/65] Update main.py
---
scripts/release_issue_status/main.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index 20903240e760..47d0e892e304 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -146,7 +146,7 @@ def auto_reply(item, sdk_repo, rest_repo, duplicated_issue):
item.labels.append('attention')
raise
try:
- reply = rg.begin_reply_generate(issue_object=item, rest_repo=rest_repo, readme_link=readme_link)
+ reply = rg.begin_reply_generate(item=item, rest_repo=rest_repo, readme_link=readme_link)
except Exception as e:
item.bot_advice = 'auto reply failed, Please intervene manually !!'
print('Error from auto reply ========================')
From 77755505f89ddaee5c484347f82844b4b11f949e Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Tue, 31 Aug 2021 10:10:50 +0800
Subject: [PATCH 59/65] Update update_issue_body.py
---
scripts/release_issue_status/update_issue_body.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/release_issue_status/update_issue_body.py b/scripts/release_issue_status/update_issue_body.py
index aa13f2132172..f41e49520708 100644
--- a/scripts/release_issue_status/update_issue_body.py
+++ b/scripts/release_issue_status/update_issue_body.py
@@ -46,7 +46,7 @@ def get_pkname_and_readme_link(rest_repo, link):
# Get Readme link
pr_info = rest_repo.get_pull(number=pr_number)
- pk_url_name = {}
+ pk_url_name = set()
print("Got file change")
for pr_changed_file in pr_info.get_files():
contents_url = pr_changed_file.contents_url
From 4799c3979352af7a09e73e21ce212115fb33b223 Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Tue, 31 Aug 2021 10:23:32 +0800
Subject: [PATCH 60/65] Update update_issue_body.py
---
scripts/release_issue_status/update_issue_body.py | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/scripts/release_issue_status/update_issue_body.py b/scripts/release_issue_status/update_issue_body.py
index f41e49520708..57bc5c96e5a9 100644
--- a/scripts/release_issue_status/update_issue_body.py
+++ b/scripts/release_issue_status/update_issue_body.py
@@ -26,9 +26,7 @@ def update_issue_body(sdk_repo, rest_repo, issue_number):
issue_body_up += '\n'
issue_body_up += raw + '\n'
- print("begin to update body")
issue_info.edit(body=issue_body_up)
- print("update body success")
return package_name, readme_link
@@ -47,7 +45,6 @@ def get_pkname_and_readme_link(rest_repo, link):
# Get Readme link
pr_info = rest_repo.get_pull(number=pr_number)
pk_url_name = set()
- print("Got file change")
for pr_changed_file in pr_info.get_files():
contents_url = pr_changed_file.contents_url
if '/resource-manager' in contents_url:
@@ -60,7 +57,7 @@ def get_pkname_and_readme_link(rest_repo, link):
raise Exception('Not find readme link, because it exists multiple package names')
readme_link = 'https://github.com/Azure/azure-rest-api-specs/blob/main/specification/{}/' \
- 'resource-manager/readme.python.md'.format(pk_url_name)
+ 'resource-manager/readme.python.md'.format(list(pk_url_name)[0])
# if link is a rest url(i.e. https://github.com/Azure/azure-rest-api-specs/blob/main/specification/xxx/resource-manager/readme.python.md)
@@ -71,7 +68,6 @@ def get_pkname_and_readme_link(rest_repo, link):
readme_link = link.split('/resource-manager')[0] + '/resource-manager/readme.python.md'
# get the package name by readme link
readme_link_part = '/specification' + readme_link.split('/specification')[-1]
- print("Get Readme contents")
readme_contents = str(rest_repo.get_contents(readme_link_part).decoded_content)
pk_name = re.findall(r'package-name: (.*?)\\n', readme_contents)[0]
readme_link = readme_link.replace('python.', '')
From c44d53894c0324d21015183518b54eb5be857d84 Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Tue, 31 Aug 2021 10:50:33 +0800
Subject: [PATCH 61/65] Update update_issue_body.py
---
scripts/release_issue_status/update_issue_body.py | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/scripts/release_issue_status/update_issue_body.py b/scripts/release_issue_status/update_issue_body.py
index 57bc5c96e5a9..669a7a04f1ab 100644
--- a/scripts/release_issue_status/update_issue_body.py
+++ b/scripts/release_issue_status/update_issue_body.py
@@ -6,17 +6,27 @@ def update_issue_body(sdk_repo, rest_repo, issue_number):
issue_info = sdk_repo.get_issue(number=issue_number)
issue_body = issue_info.body
issue_body_list = [i for i in issue_body.split("\n") if i]
- # Get the link in issue body
+ # Get the link and readme tag in issue body
+ link, readme_tag = '', ''
for row in issue_body_list:
if 'link' in row.lower():
link = row.split(":", 1)[-1].strip()
break
+ if 'readme tag' in row.lower():
+ readme_tag = row.split(":", 1)[-1].strip()
+ if link and readme_tag:
+ break
if link.count('https') > 1:
link = link.split(']')[0]
link = link.replace('[', "").replace(']', "").replace('(', "").replace(')', "")
package_name, readme_link = get_pkname_and_readme_link(rest_repo, link)
+
+ # Check readme tag format
+ if 'package' not in readme_tag:
+ readme_tag = 'package-{}'.format(readme_tag)
+ issue_body_list.insert(0, f'Readme Tag: {readme_tag}')
issue_body_list.insert(0, f'\n{readme_link.replace("/readme.md", "")}')
issue_body_list.insert(1, package_name)
From 963d458be27ad58c53ab4ed84970359fea65d740 Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Tue, 31 Aug 2021 11:02:00 +0800
Subject: [PATCH 62/65] Update update_issue_body.py
---
scripts/release_issue_status/update_issue_body.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/scripts/release_issue_status/update_issue_body.py b/scripts/release_issue_status/update_issue_body.py
index 669a7a04f1ab..f403680773f8 100644
--- a/scripts/release_issue_status/update_issue_body.py
+++ b/scripts/release_issue_status/update_issue_body.py
@@ -14,6 +14,7 @@ def update_issue_body(sdk_repo, rest_repo, issue_number):
break
if 'readme tag' in row.lower():
readme_tag = row.split(":", 1)[-1].strip()
+ print("find readme tag: ", readme_tag)
if link and readme_tag:
break
From 8134df9283e36c542b569b08d81a822b58d3a2dc Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Tue, 31 Aug 2021 11:07:09 +0800
Subject: [PATCH 63/65] Update update_issue_body.py
---
scripts/release_issue_status/update_issue_body.py | 2 --
1 file changed, 2 deletions(-)
diff --git a/scripts/release_issue_status/update_issue_body.py b/scripts/release_issue_status/update_issue_body.py
index f403680773f8..718bc906fc80 100644
--- a/scripts/release_issue_status/update_issue_body.py
+++ b/scripts/release_issue_status/update_issue_body.py
@@ -11,10 +11,8 @@ def update_issue_body(sdk_repo, rest_repo, issue_number):
for row in issue_body_list:
if 'link' in row.lower():
link = row.split(":", 1)[-1].strip()
- break
if 'readme tag' in row.lower():
readme_tag = row.split(":", 1)[-1].strip()
- print("find readme tag: ", readme_tag)
if link and readme_tag:
break
From c7109013258b84fa1dc388a0f019bfc23c4fef82 Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Tue, 31 Aug 2021 11:20:13 +0800
Subject: [PATCH 64/65] Update main.py
---
scripts/release_issue_status/main.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index 47d0e892e304..909b51f8892f 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -122,11 +122,11 @@ def _latest_comment_time(comments, delay_from_create_date):
def auto_reply(item, sdk_repo, rest_repo, duplicated_issue):
- print("+++++++++++issue number: {}".format(item.issue_object.number))
+ print("==========new issue number: {}".format(item.issue_object.number))
if 'auto-link' not in item.labels:
try:
package_name, readme_link = update_issue_body(sdk_repo, rest_repo, item.issue_object.number)
- print("----------------pkname, readme", package_name, readme_link)
+ print("pkname, readme", package_name, readme_link)
item.package = package_name
key = ('Python', item.package)
duplicated_issue[key] = duplicated_issue.get(key, 0) + 1
From bc261c9c1a02a9d7635d5f9369c2eb0e920a87b0 Mon Sep 17 00:00:00 2001
From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
Date: Tue, 31 Aug 2021 11:37:25 +0800
Subject: [PATCH 65/65] Update main.py
---
scripts/release_issue_status/main.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/release_issue_status/main.py b/scripts/release_issue_status/main.py
index 909b51f8892f..6bdf38279c4f 100644
--- a/scripts/release_issue_status/main.py
+++ b/scripts/release_issue_status/main.py
@@ -228,7 +228,7 @@ def main():
# judge whether there is duplicated issue for same package
if item.package != _NULL and duplicated_issue.get((item.language, item.package)) > 1:
- item.bot_advice = f'Warning:There is duplicated issue for {item.package}.
' + item.bot_advice
+ item.bot_advice = f'Warning:There is duplicated issue for {item.package}. ' + item.bot_advice
if item.language == 'Python':
issue_status_python.append(item)