Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release_iseus_status_auto_reply #20441

Merged
merged 66 commits into from
Aug 31, 2021
Merged
Changes from 1 commit
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
2c563ff
release_iseus_status_auto_reply
RAY-316 Aug 23, 2021
9603d0f
issue_aoto_close_revert
RAY-316 Aug 23, 2021
133a6a0
Update main.py
RAY-316 Aug 23, 2021
d37ca66
Update main.py
RAY-316 Aug 23, 2021
f5a24c8
Update update_issue_body.py
RAY-316 Aug 23, 2021
590dc3d
Update reply_generator.py
BigCat20196 Aug 23, 2021
0a20a20
Update reply_generator.py
BigCat20196 Aug 24, 2021
1644cf1
Update update_issue_body.py
BigCat20196 Aug 24, 2021
6b1f482
Update main.py
BigCat20196 Aug 24, 2021
fafae8e
Update update_issue_body.py
BigCat20196 Aug 24, 2021
fba944d
Update update_issue_body.py
BigCat20196 Aug 24, 2021
256fb62
Update main.py
BigCat20196 Aug 24, 2021
ff27a87
Update reply_generator.py
RAY-316 Aug 24, 2021
9bbde53
Update main.py
RAY-316 Aug 24, 2021
c065cf7
Update update_issue_body.py
BigCat20196 Aug 25, 2021
80007ac
Update main.py
BigCat20196 Aug 25, 2021
bef41b1
Update scripts/release_issue_status/update_issue_body.py
msyyc Aug 25, 2021
2682c0e
Update update_issue_body.py
BigCat20196 Aug 25, 2021
af36ccc
Update main.py
BigCat20196 Aug 27, 2021
9223146
Update reply_generator.py
BigCat20196 Aug 27, 2021
8ee91fe
Update update_issue_body.py
BigCat20196 Aug 27, 2021
bef133c
Update main.py
BigCat20196 Aug 27, 2021
9dfd084
Update scripts/release_issue_status/main.py
msyyc Aug 27, 2021
51f92fd
Update main.py
msyyc Aug 27, 2021
5259157
Update scripts/release_issue_status/main.py
msyyc Aug 27, 2021
6949bfb
Update scripts/release_issue_status/main.py
msyyc Aug 27, 2021
7b14fd2
Update scripts/release_issue_status/main.py
msyyc Aug 27, 2021
299cfae
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-python …
msyyc Aug 27, 2021
7d3fab8
Update scripts/release_issue_status/update_issue_body.py
msyyc Aug 27, 2021
f07b5b2
Update scripts/release_issue_status/main.py
BigCat20196 Aug 27, 2021
b39342b
Update scripts/release_issue_status/update_issue_body.py
BigCat20196 Aug 27, 2021
44d4de9
Update reply_generator.py
RAY-316 Aug 27, 2021
86b603a
Update main.py
RAY-316 Aug 27, 2021
b9abd0f
Update scripts/release_issue_status/update_issue_body.py
BigCat20196 Aug 30, 2021
7ae26ce
Update scripts/release_issue_status/update_issue_body.py
BigCat20196 Aug 30, 2021
e4b3ed8
Update reply_generator.py
RAY-316 Aug 30, 2021
b587233
Update update_issue_body.py
BigCat20196 Aug 30, 2021
5ca4ac1
Update main.py
BigCat20196 Aug 30, 2021
262d323
Update main.py
BigCat20196 Aug 30, 2021
df737f2
Update update_issue_body.py
BigCat20196 Aug 30, 2021
b792d31
Update main.py
BigCat20196 Aug 30, 2021
c34adbf
Update scripts/release_issue_status/main.py
msyyc Aug 30, 2021
962683e
Update main.py
RAY-316 Aug 30, 2021
b59c2b9
Update reply_generator.py
RAY-316 Aug 30, 2021
91f6827
Update main.py
BigCat20196 Aug 30, 2021
2cbf44a
Update main.py
BigCat20196 Aug 30, 2021
28f1be0
Update main.py
BigCat20196 Aug 30, 2021
9c6adec
Update main.py
BigCat20196 Aug 30, 2021
d021e85
Update main.py
BigCat20196 Aug 30, 2021
9f05d43
Update main.py
BigCat20196 Aug 30, 2021
3a83841
Update main.py
BigCat20196 Aug 31, 2021
05cf904
Update main.py
BigCat20196 Aug 31, 2021
529ed24
Update main.py
BigCat20196 Aug 31, 2021
ad02d86
Update update_issue_body.py
BigCat20196 Aug 31, 2021
d8c9fd2
Update main.py
BigCat20196 Aug 31, 2021
e5fd8a1
Update update_issue_body.py
BigCat20196 Aug 31, 2021
5be276a
Update reply_generator.py
RAY-316 Aug 31, 2021
a49bcde
Update update_issue_body.py
BigCat20196 Aug 31, 2021
cb053b0
Update main.py
RAY-316 Aug 31, 2021
7775550
Update update_issue_body.py
BigCat20196 Aug 31, 2021
4799c39
Update update_issue_body.py
BigCat20196 Aug 31, 2021
c44d538
Update update_issue_body.py
BigCat20196 Aug 31, 2021
963d458
Update update_issue_body.py
BigCat20196 Aug 31, 2021
8134df9
Update update_issue_body.py
BigCat20196 Aug 31, 2021
c710901
Update main.py
BigCat20196 Aug 31, 2021
bc261c9
Update main.py
BigCat20196 Aug 31, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update reply_generator.py
BigCat20196 authored Aug 27, 2021
commit 922314665c01b7224651891151cefb7153a40fe0
98 changes: 45 additions & 53 deletions scripts/release_issue_status/reply_generator.py
Original file line number Diff line number Diff line change
@@ -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 '<h3>Swagger Generation Artifacts</h3>' 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 '<b> azure-sdk-for-python</b>' 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))