From a4c664586cabd51a79a991e6c80b9af21a1f702a Mon Sep 17 00:00:00 2001 From: msyyc <70930885+msyyc@users.noreply.github.com> Date: Fri, 26 Nov 2021 15:00:25 +0800 Subject: [PATCH 001/103] update for Go --- scripts/release_helper/go.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release_helper/go.py b/scripts/release_helper/go.py index 190fc007d81b..0405cd053be3 100644 --- a/scripts/release_helper/go.py +++ b/scripts/release_helper/go.py @@ -6,7 +6,7 @@ _GO_OWNER = {'ArcturusZhang'} # 'github assignee': 'token' -_ASSIGNEE_TOKEN_GO = {'ArcturusZhang': os.getenv('PYTHON_ZED_TOKEN')} +_ASSIGNEE_TOKEN_GO = {'ArcturusZhang': os.getenv('GO_DAPENGZHANG_TOKEN')} class IssueProcessGo(IssueProcess): From d96f9e1f5df1f4a31abb193b61aff7a6ca84818a Mon Sep 17 00:00:00 2001 From: msyyc <70930885+msyyc@users.noreply.github.com> Date: Fri, 26 Nov 2021 17:23:25 +0800 Subject: [PATCH 002/103] check tag consistency and optize reply --- scripts/release_helper/common.py | 59 ++++++++++++++++++-------------- scripts/release_helper/java.py | 17 ++++++++- scripts/release_helper/main.py | 3 +- scripts/release_helper/utils.py | 4 +-- 4 files changed, 53 insertions(+), 30 deletions(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index 4f813b359370..101857f4c847 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -16,17 +16,20 @@ _ASSIGNEE_TOKEN = {'msyyc': os.getenv('PYTHON_MSYYC_TOKEN')} +_SWAGGER_URL = 'https://github.com/Azure/azure-rest-api-specs/blob/main/specification' +_SWAGGER_PULL = 'https://github.com/Azure/azure-rest-api-specs/pull' + class IssueProcess: # won't be changed anymore after __init__ request_repo_dict = {} # request repo instance generated by different token owner = '' # issue owner assignee_candidates = {} # assignee candidates who will be assigned to handle issue - language_owner = {} # language owner who may handle issue + language_owner = {} # language owner who may handle issue # will be changed by order issue = None # issue that needs to handle assignee = '' - bot = '' # bot advice to help SDK owner + bot = [] # bot advice to help SDK owner target_readme_tag = '' # swagger content that customers want readme_link = '' # https link which swagger definition is in default_readme_tag = '' # configured in `README.md` @@ -55,33 +58,35 @@ def comment(self, message: str) -> None: self.issue_package.issue.create_comment(message) def get_readme_from_pr_link(self, link: str) -> str: - pr_number = int(link.replace("https://github.com/Azure/azure-rest-api-specs/pull/", "").strip('/')) + pr_number = int(link.replace(f"{_SWAGGER_PULL}/", "").strip('/')) # Get Readme link pr_info = self.issue_package.rest_repo.get_pull(number=pr_number) pk_url_name = set() for pr_changed_file in pr_info.get_files(): contents_url = pr_changed_file.contents_url - if '/resource-manager' in contents_url: - try: - pk_url_name.add(re.findall(r'/specification/(.*?)/resource-manager/', contents_url)[0]) - except Exception as e: - continue - if len(pk_url_name) > 1: - message = f"{pk_url_name} contains multiple packages " - self.log(message) - self.comment( - f'Hi, @{self.assignee}, "{link}" contains multi packages, please extract readme link manually.') - raise Exception(message) - - readme_link = f'https://github.com/Azure/azure-rest-api-specs/blob/main/specification/' \ - f'{pk_url_name.pop()}/resource-manager' - return readme_link + if '/resource-manager' not in contents_url: + continue + try: + pk_url_name.add(re.findall(r'/specification/(.*?)/resource-manager/', contents_url)[0]) + except Exception as e: + continue + readme_link = [f'{_SWAGGER_URL}/{item}/resource-manager' for item in pk_url_name] + if len(readme_link) > 1: + multi_link = ', '.join(readme_link) + pr = f"{_SWAGGER_PULL}/{pr_number}" + self.comment(f'Hi, @{self.assignee}, by parsing {pr}, there are multi service link: {multi_link}. Please decide which one is the right.') + self.bot.append('multi readme link!') + raise Exception(f'multi link in "{pr}"') + + return readme_link[0] def get_readme_link(self, origin_link: str): # check whether link is valid if 'azure-rest-api-specs' not in origin_link: - self.comment(f'Hi, @{self.owner}, "{origin_link}" is not valid link. Please provide valid link like ' + self.comment(f'Hi, @{self.owner}, "{origin_link}" is not valid link. Please follow [doc]' + f'(https://github.com/Azure/azure-rest-api-specs/blob/main/documentation/release-request/' + f'rules-for-release-request.md#2-link-to-pr-or-spec-if-pr-unavailable) to provide valid link like ' f'"https://github.com/Azure/azure-rest-api-specs/pull/16750" or ' f'"https://github.com/Azure/azure-rest-api-specs/tree/main/' f'specification/network/resource-manager"') @@ -128,9 +133,11 @@ def edit_issue_body(self) -> None: def check_tag_consistency(self) -> None: if self.default_readme_tag != self.target_readme_tag: - self.comment(f'Hi, @{self.owner}, your **Readme Tag** is `{self.target_readme_tag}`, ' - f'but in [readme.md]({self.readme_link}) it is still `{self.default_readme_tag}`, ' - f'please modify the readme.md or your **Readme Tag** above ') + self.comment(f'Hi, @{self.owner}, according to [rule](https://github.com/Azure/azure-rest-api-specs/blob/' + f'main/documentation/release-request/rules-for-release-request.md#3-readme-tag-to-be-released),' + f' your **Readme Tag** is `{self.target_readme_tag}`, but in [readme.md]({self.readme_link}#basic-information) ' + f'it is still `{self.default_readme_tag}`, please modify the readme.md or your ' + f'**Readme Tag** above ') def auto_parse(self) -> None: if AUTO_PARSE_LABEL in self.issue_package.labels_name: @@ -146,9 +153,9 @@ def auto_parse(self) -> None: self.get_readme_link(origin_link) # get default tag with readme_link - # self.get_default_readme_tag() + self.get_default_readme_tag() - # self.check_tag_consistency() + self.check_tag_consistency() self.edit_issue_body() @@ -200,7 +207,7 @@ class Common: issues_package = None # issues that need to handle request_repo_dict = {} # request repo instance generated by different token assignee_candidates = {} # assignee candidates who will be assigned to handle issue - language_owner = {} # language owner who may handle issue + language_owner = {} # language owner who may handle issue def __init__(self, issues: List[IssuePackage], assignee_token: Dict[str, str], language_owner: Set[str]): self.issues_package = issues @@ -215,7 +222,7 @@ def run(self): try: issue.run() except Exception as e: - _LOG.error(f'Error happened during handling issue {item.issue_package.issue.number}: {e}') + _LOG.error(f'Error happened during handling issue {item.issue.number}: {e}') def common_process(issues: List[IssuePackage]): diff --git a/scripts/release_helper/java.py b/scripts/release_helper/java.py index 810c81be11e9..32d0185e63dc 100644 --- a/scripts/release_helper/java.py +++ b/scripts/release_helper/java.py @@ -1,4 +1,5 @@ from common import IssueProcess, Common +from utils import AUTO_PARSE_LABEL, get_origin_link_and_tag from typing import Any, List import os @@ -14,7 +15,21 @@ class IssueProcessJava(IssueProcess): - pass + + def auto_parse(self) -> None: + if AUTO_PARSE_LABEL in self.issue_package.labels_name: + return + + self.add_label(AUTO_PARSE_LABEL) + issue_body_list = self.get_issue_body() + + # Get the origin link and readme tag in issue body + origin_link, self.target_readme_tag = get_origin_link_and_tag(issue_body_list) + + # get readme_link + self.get_readme_link(origin_link) + + self.edit_issue_body() class Java(Common): diff --git a/scripts/release_helper/main.py b/scripts/release_helper/main.py index cfdc4db86859..5ee6e579622f 100644 --- a/scripts/release_helper/main.py +++ b/scripts/release_helper/main.py @@ -5,6 +5,7 @@ from go import go_process from java import java_process from js import js_process +from common import common_process import os from typing import List @@ -22,7 +23,7 @@ 't': 'Test' } _LANGUAGES = { - 'Test': python_process, + 'Test': common_process, # 'Python': python_process, 'Java': java_process, 'Go': go_process, diff --git a/scripts/release_helper/utils.py b/scripts/release_helper/utils.py index 49e036fce502..5cbb80341213 100644 --- a/scripts/release_helper/utils.py +++ b/scripts/release_helper/utils.py @@ -14,9 +14,9 @@ def get_origin_link_and_tag(issue_body_list: List[str]) -> (str, str): link, readme_tag = '', '' for row in issue_body_list: - if 'link' in row.lower(): + if 'link' in row.lower() and link == '': link = row.split(":", 1)[-1].strip() - if 'readme tag' in row.lower(): + if 'readme tag' in row.lower() and readme_tag == '': readme_tag = row.split(":", 1)[-1].strip() if link and readme_tag: break From 29dcc3b74f66aaea9a48f2be4c0997ee52037425 Mon Sep 17 00:00:00 2001 From: Zed <601306339@qq.com> Date: Tue, 30 Nov 2021 17:08:06 +0800 Subject: [PATCH 003/103] add write.md --- scripts/release_helper/common.py | 38 ++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index 101857f4c847..dd5d1505f366 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -1,3 +1,4 @@ +from datetime import date, datetime from typing import Set, List, Dict import os from utils import IssuePackage, REQUEST_REPO, AUTO_ASSIGN_LABEL, AUTO_PARSE_LABEL, get_origin_link_and_tag @@ -15,10 +16,10 @@ # 'github assignee': 'token' _ASSIGNEE_TOKEN = {'msyyc': os.getenv('PYTHON_MSYYC_TOKEN')} - _SWAGGER_URL = 'https://github.com/Azure/azure-rest-api-specs/blob/main/specification' _SWAGGER_PULL = 'https://github.com/Azure/azure-rest-api-specs/pull' + class IssueProcess: # won't be changed anymore after __init__ request_repo_dict = {} # request repo instance generated by different token @@ -75,7 +76,8 @@ def get_readme_from_pr_link(self, link: str) -> str: if len(readme_link) > 1: multi_link = ', '.join(readme_link) pr = f"{_SWAGGER_PULL}/{pr_number}" - self.comment(f'Hi, @{self.assignee}, by parsing {pr}, there are multi service link: {multi_link}. Please decide which one is the right.') + self.comment( + f'Hi, @{self.assignee}, by parsing {pr}, there are multi service link: {multi_link}. Please decide which one is the right.') self.bot.append('multi readme link!') raise Exception(f'multi link in "{pr}"') @@ -213,16 +215,48 @@ def __init__(self, issues: List[IssuePackage], assignee_token: Dict[str, str], l self.issues_package = issues self.assignee_candidates = set(assignee_token.keys()) self.language_owner = language_owner + # arguments add to language.md + self.file_out_name = 'common.md' + self.bot_advice = '' + self.target_release_date = '' + self.date_from_target = '' + self.package_name = '' + for assignee in assignee_token: self.request_repo_dict[assignee] = Github(assignee_token[assignee]).get_repo(REQUEST_REPO) + def output_python_md(self, items): + with open(self.file_out_name, 'w') as file_out: + file_out.write( + '| issue | author | package | assignee | bot advice | created date of issue | target release date | date from target |\n') + file_out.write('| ------ | ------ | ------ | ------ | ------ | ------ | ------ | :-----: |\n') + file_out.writelines([self.output_python(item) for item in items]) + + def output_python(self, item): + create_date = str(date.fromtimestamp(item.created_at.timestamp()).strftime('%m-%d')) + + return '| [#{}]({}) | {} | {} | {} | {} | {} | {} | {} |\n'.format( + item.issue_package.issue.html_url.split('/')[-1], + item.issue_package.issue.html_url, + item.user.login, + self.package_name, + item.assignee.login, + self.bot_advice, + create_date, + self.target_release_date, + self.date_from_target + ) + def run(self): + items = [] for item in self.issues_package: issue = IssueProcess(item, self.request_repo_dict, self.assignee_candidates, self.language_owner) try: issue.run() + items.append(issue) except Exception as e: _LOG.error(f'Error happened during handling issue {item.issue.number}: {e}') + self.output_python_md(items) def common_process(issues: List[IssuePackage]): From 7c41af8849ba8cbe8e5f67968d46c4f198d621f4 Mon Sep 17 00:00:00 2001 From: Zed <601306339@qq.com> Date: Tue, 30 Nov 2021 17:14:35 +0800 Subject: [PATCH 004/103] update go js readme --- scripts/release_helper/go.py | 4 +++- scripts/release_helper/js.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/release_helper/go.py b/scripts/release_helper/go.py index 0405cd053be3..5d17ddf56ecf 100644 --- a/scripts/release_helper/go.py +++ b/scripts/release_helper/go.py @@ -14,7 +14,9 @@ class IssueProcessGo(IssueProcess): class Go(Common): - pass + def __init__(self): + super(Go, self).__init__() + self.file_out_name = 'release_go_status.md' def go_process(issues: List[Any]): diff --git a/scripts/release_helper/js.py b/scripts/release_helper/js.py index 4bdd596986e9..9139d8adce73 100644 --- a/scripts/release_helper/js.py +++ b/scripts/release_helper/js.py @@ -14,7 +14,9 @@ class IssueProcessJs(IssueProcess): class Js(Common): - pass + def __init__(self): + super(Js, self).__init__() + self.file_out_name = 'release_js_status.md' def js_process(issues: List[Any]): From bdeabc39b23d7ed6bb0e0ea4573d85e139c49709 Mon Sep 17 00:00:00 2001 From: Zed <601306339@qq.com> Date: Tue, 30 Nov 2021 17:43:29 +0800 Subject: [PATCH 005/103] update --- scripts/release_helper/common.py | 6 ++++++ scripts/release_helper/go.py | 4 ++-- scripts/release_helper/js.py | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index dd5d1505f366..e9c3c1db54eb 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -7,6 +7,7 @@ import time from github import Github from github.Repository import Repository +import subprocess as sp _LOG = logging.getLogger(__name__) @@ -247,6 +248,10 @@ def output_python(self, item): self.date_from_target ) + def push_md_to_storage(self): + cmd_list = ['git add .', 'git commit -m \"update excel\"', 'git push -f origin HEAD'] + [sp.check_call(cmd, shell=True) for cmd in cmd_list] + def run(self): items = [] for item in self.issues_package: @@ -257,6 +262,7 @@ def run(self): except Exception as e: _LOG.error(f'Error happened during handling issue {item.issue.number}: {e}') self.output_python_md(items) + self.push_md_to_storage() def common_process(issues: List[IssuePackage]): diff --git a/scripts/release_helper/go.py b/scripts/release_helper/go.py index 5d17ddf56ecf..61464dd1c681 100644 --- a/scripts/release_helper/go.py +++ b/scripts/release_helper/go.py @@ -14,8 +14,8 @@ class IssueProcessGo(IssueProcess): class Go(Common): - def __init__(self): - super(Go, self).__init__() + def __init__(self, issues, assignee_token, language_owner): + super(Go, self).__init__(issues, assignee_token, language_owner) self.file_out_name = 'release_go_status.md' diff --git a/scripts/release_helper/js.py b/scripts/release_helper/js.py index 9139d8adce73..4792a38336fd 100644 --- a/scripts/release_helper/js.py +++ b/scripts/release_helper/js.py @@ -14,8 +14,8 @@ class IssueProcessJs(IssueProcess): class Js(Common): - def __init__(self): - super(Js, self).__init__() + def __init__(self, issues, assignee_token, language_owner): + super(Js, self).__init__(issues, assignee_token, language_owner) self.file_out_name = 'release_js_status.md' From c0ab72fc522d46d1c71d5c7cff3ea6c206f0369b Mon Sep 17 00:00:00 2001 From: Yiming Lei <59104634+RAY-316@users.noreply.github.com> Date: Tue, 30 Nov 2021 17:51:56 +0800 Subject: [PATCH 006/103] Update common.py --- scripts/release_helper/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index e9c3c1db54eb..84c0aafddd99 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -234,7 +234,7 @@ def output_python_md(self, items): file_out.writelines([self.output_python(item) for item in items]) def output_python(self, item): - create_date = str(date.fromtimestamp(item.created_at.timestamp()).strftime('%m-%d')) + create_date = str(date.fromtimestamp(item.issue_package.issue.created_at.timestamp()).strftime('%m-%d')) return '| [#{}]({}) | {} | {} | {} | {} | {} | {} | {} |\n'.format( item.issue_package.issue.html_url.split('/')[-1], From ba7d78589a0c87c59c7f7586cc490b0021ce1b78 Mon Sep 17 00:00:00 2001 From: Yiming Lei <59104634+RAY-316@users.noreply.github.com> Date: Wed, 1 Dec 2021 10:03:17 +0800 Subject: [PATCH 007/103] Update common.py --- scripts/release_helper/common.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index 84c0aafddd99..1b290f982926 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -239,9 +239,9 @@ def output_python(self, item): return '| [#{}]({}) | {} | {} | {} | {} | {} | {} | {} |\n'.format( item.issue_package.issue.html_url.split('/')[-1], item.issue_package.issue.html_url, - item.user.login, + item.issue_package.issue.user.login, self.package_name, - item.assignee.login, + item.issue_package.issue.assignee.login, self.bot_advice, create_date, self.target_release_date, From 6231625ba1a662e698acab1cb98574e4ea3705f1 Mon Sep 17 00:00:00 2001 From: msyyc <70930885+msyyc@users.noreply.github.com> Date: Wed, 1 Dec 2021 13:16:41 +0800 Subject: [PATCH 008/103] update assignee for JS --- scripts/release_helper/js.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/release_helper/js.py b/scripts/release_helper/js.py index 4bdd596986e9..e2515070cb44 100644 --- a/scripts/release_helper/js.py +++ b/scripts/release_helper/js.py @@ -3,10 +3,10 @@ import os # assignee dict which will be assigned to handle issues -_JS_OWNER = {'lirenhe'} +_JS_OWNER = {'qiaozha', 'lirenhe'} # 'github assignee': 'token' -_ASSIGNEE_TOKEN_JS = {'lirenhe': os.getenv('JS_QIAOQIAO_TOKEN')} +_ASSIGNEE_TOKEN_JS = {'qiaozha': os.getenv('JS_QIAOQIAO_TOKEN')} class IssueProcessJs(IssueProcess): From 41190c6d7c2df2066b8bb749ec0f2761c277411b Mon Sep 17 00:00:00 2001 From: Zed <601306339@qq.com> Date: Wed, 1 Dec 2021 14:26:10 +0800 Subject: [PATCH 009/103] update --- scripts/release_helper/common.py | 7 +++---- scripts/release_helper/release_helper.yml | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index 1b290f982926..44333640e864 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -218,7 +218,6 @@ def __init__(self, issues: List[IssuePackage], assignee_token: Dict[str, str], l self.language_owner = language_owner # arguments add to language.md self.file_out_name = 'common.md' - self.bot_advice = '' self.target_release_date = '' self.date_from_target = '' self.package_name = '' @@ -226,7 +225,7 @@ def __init__(self, issues: List[IssuePackage], assignee_token: Dict[str, str], l for assignee in assignee_token: self.request_repo_dict[assignee] = Github(assignee_token[assignee]).get_repo(REQUEST_REPO) - def output_python_md(self, items): + def output_md(self, items): with open(self.file_out_name, 'w') as file_out: file_out.write( '| issue | author | package | assignee | bot advice | created date of issue | target release date | date from target |\n') @@ -242,7 +241,7 @@ def output_python(self, item): item.issue_package.issue.user.login, self.package_name, item.issue_package.issue.assignee.login, - self.bot_advice, + item.bot, create_date, self.target_release_date, self.date_from_target @@ -261,7 +260,7 @@ def run(self): items.append(issue) except Exception as e: _LOG.error(f'Error happened during handling issue {item.issue.number}: {e}') - self.output_python_md(items) + self.output_md(items) self.push_md_to_storage() diff --git a/scripts/release_helper/release_helper.yml b/scripts/release_helper/release_helper.yml index 2f6bbc31a499..3307b787837b 100644 --- a/scripts/release_helper/release_helper.yml +++ b/scripts/release_helper/release_helper.yml @@ -55,8 +55,8 @@ jobs: pip install -r $script_path/requirement.txt # checkout the target branch - # cd file-storage - # git checkout release-helper + cd file-storage + git checkout release-helper # run python $script_path/main.py From d5ca1dc6edfa9dca14dc4880a28561bdbb16207e Mon Sep 17 00:00:00 2001 From: Zed <601306339@qq.com> Date: Wed, 1 Dec 2021 14:49:10 +0800 Subject: [PATCH 010/103] update --- scripts/release_helper/common.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index 44333640e864..b32f9c048ab2 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -248,9 +248,19 @@ def output_python(self, item): ) def push_md_to_storage(self): + with open('release_go_status.md','r') as f : + print(f.read()) cmd_list = ['git add .', 'git commit -m \"update excel\"', 'git push -f origin HEAD'] [sp.check_call(cmd, shell=True) for cmd in cmd_list] + def traversal_files(self,path): + for dir in os.listdir(path): + dir = os.path.join(path, dir) + print(dir) + # 判断当前目录是否为文件夹 + if os.path.isdir(dir): + self.traversal_files(dir) + def run(self): items = [] for item in self.issues_package: From 7110dbbe6cdb1645851c4091bcdfbe5346152682 Mon Sep 17 00:00:00 2001 From: Yiming Lei <59104634+RAY-316@users.noreply.github.com> Date: Wed, 1 Dec 2021 14:59:18 +0800 Subject: [PATCH 011/103] Update common.py --- scripts/release_helper/common.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index b32f9c048ab2..a5704f6fc226 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -249,14 +249,14 @@ def output_python(self, item): def push_md_to_storage(self): with open('release_go_status.md','r') as f : - print(f.read()) + print(f.read(),'++++++++++++++++++') cmd_list = ['git add .', 'git commit -m \"update excel\"', 'git push -f origin HEAD'] [sp.check_call(cmd, shell=True) for cmd in cmd_list] def traversal_files(self,path): for dir in os.listdir(path): dir = os.path.join(path, dir) - print(dir) + print(dir,'+++++++++++++++++++++++') # 判断当前目录是否为文件夹 if os.path.isdir(dir): self.traversal_files(dir) @@ -271,6 +271,7 @@ def run(self): except Exception as e: _LOG.error(f'Error happened during handling issue {item.issue.number}: {e}') self.output_md(items) + self.traversal_files('.') self.push_md_to_storage() From 32bc8ef1808d3d5b08d25c8b671ab3da88ab290a Mon Sep 17 00:00:00 2001 From: Yiming Lei <59104634+RAY-316@users.noreply.github.com> Date: Wed, 1 Dec 2021 15:15:35 +0800 Subject: [PATCH 012/103] Update common.py --- scripts/release_helper/common.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index a5704f6fc226..568a613ec5b3 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -253,14 +253,6 @@ def push_md_to_storage(self): cmd_list = ['git add .', 'git commit -m \"update excel\"', 'git push -f origin HEAD'] [sp.check_call(cmd, shell=True) for cmd in cmd_list] - def traversal_files(self,path): - for dir in os.listdir(path): - dir = os.path.join(path, dir) - print(dir,'+++++++++++++++++++++++') - # 判断当前目录是否为文件夹 - if os.path.isdir(dir): - self.traversal_files(dir) - def run(self): items = [] for item in self.issues_package: @@ -271,7 +263,7 @@ def run(self): except Exception as e: _LOG.error(f'Error happened during handling issue {item.issue.number}: {e}') self.output_md(items) - self.traversal_files('.') + print(os.listdir('.'),os.getcwd(),'+++++++++++') self.push_md_to_storage() From e76d3ab489d4fa2bc0c80a145404d12356a6f845 Mon Sep 17 00:00:00 2001 From: Yiming Lei <59104634+RAY-316@users.noreply.github.com> Date: Wed, 1 Dec 2021 15:37:13 +0800 Subject: [PATCH 013/103] Update release_helper.yml for Azure Pipelines --- scripts/release_helper/release_helper.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/release_helper/release_helper.yml b/scripts/release_helper/release_helper.yml index 3307b787837b..9023f73a5785 100644 --- a/scripts/release_helper/release_helper.yml +++ b/scripts/release_helper/release_helper.yml @@ -36,8 +36,8 @@ jobs: git config --global user.name "ReleaseHelper" # clone(REPO: https://github.com/Azure/azure-sdk-for-python.git, USR_NAME: Azure, USR_TOKEN: xxxxxxxxxxxxx) - # mkdir file-storage - # git clone ${FILE_REPO:0:8}$(USR_NAME):$(Yuchao-GitToken)@${FILE_REPO:8} $(pwd)/file-storage + mkdir file-storage + git clone ${FILE_REPO:0:8}$(USR_NAME):$(Yuchao-GitToken)@${FILE_REPO:8} $(pwd)/file-storage # import env variable export TOKEN=$(Yuchao-GitToken) From 5c4b1395de0aa52d317403e2a1189c375ad0e0b2 Mon Sep 17 00:00:00 2001 From: Yiming Lei <59104634+RAY-316@users.noreply.github.com> Date: Wed, 1 Dec 2021 15:49:09 +0800 Subject: [PATCH 014/103] Update common.py --- scripts/release_helper/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index 568a613ec5b3..678351f168d3 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -248,7 +248,7 @@ def output_python(self, item): ) def push_md_to_storage(self): - with open('release_go_status.md','r') as f : + with open('release_js_status.md','r') as f : print(f.read(),'++++++++++++++++++') cmd_list = ['git add .', 'git commit -m \"update excel\"', 'git push -f origin HEAD'] [sp.check_call(cmd, shell=True) for cmd in cmd_list] From 9230cc8397ee78faf9648cf4a07ff82e5c6b41a8 Mon Sep 17 00:00:00 2001 From: Zed <601306339@qq.com> Date: Wed, 1 Dec 2021 16:26:29 +0800 Subject: [PATCH 015/103] update --- scripts/release_helper/common.py | 8 +++----- scripts/release_helper/main.py | 3 ++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index 568a613ec5b3..8eafca8b1817 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -247,9 +247,8 @@ def output_python(self, item): self.date_from_target ) - def push_md_to_storage(self): - with open('release_go_status.md','r') as f : - print(f.read(),'++++++++++++++++++') + @staticmethod + def push_md_to_storage(): cmd_list = ['git add .', 'git commit -m \"update excel\"', 'git push -f origin HEAD'] [sp.check_call(cmd, shell=True) for cmd in cmd_list] @@ -263,8 +262,7 @@ def run(self): except Exception as e: _LOG.error(f'Error happened during handling issue {item.issue.number}: {e}') self.output_md(items) - print(os.listdir('.'),os.getcwd(),'+++++++++++') - self.push_md_to_storage() + def common_process(issues: List[IssuePackage]): diff --git a/scripts/release_helper/main.py b/scripts/release_helper/main.py index 5ee6e579622f..3e3ac080187d 100644 --- a/scripts/release_helper/main.py +++ b/scripts/release_helper/main.py @@ -5,7 +5,7 @@ from go import go_process from java import java_process from js import js_process -from common import common_process +from common import common_process, Common import os from typing import List @@ -54,6 +54,7 @@ def main(): for language in languages: language_issues = select_language_issues(issues, language) languages[language](language_issues) + Common.push_md_to_storage() if __name__ == '__main__': From 0708059a492d45f0d8e8699e9f2c2dea3ee75906 Mon Sep 17 00:00:00 2001 From: Yiming Lei <59104634+RAY-316@users.noreply.github.com> Date: Wed, 1 Dec 2021 16:41:06 +0800 Subject: [PATCH 016/103] Update common.py --- scripts/release_helper/common.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index 8eafca8b1817..5351ece5bd62 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -225,7 +225,8 @@ def __init__(self, issues: List[IssuePackage], assignee_token: Dict[str, str], l for assignee in assignee_token: self.request_repo_dict[assignee] = Github(assignee_token[assignee]).get_repo(REQUEST_REPO) - def output_md(self, items): + def output_md(self, items): + print('++++file out name',self.file_out_name) with open(self.file_out_name, 'w') as file_out: file_out.write( '| issue | author | package | assignee | bot advice | created date of issue | target release date | date from target |\n') From 3ae973996df5c0077f9d67ed31d53eceafc3729f Mon Sep 17 00:00:00 2001 From: Yiming Lei <59104634+RAY-316@users.noreply.github.com> Date: Wed, 1 Dec 2021 17:10:36 +0800 Subject: [PATCH 017/103] Update common.py --- scripts/release_helper/common.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index 5351ece5bd62..19bc987581bb 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -254,6 +254,7 @@ def push_md_to_storage(): [sp.check_call(cmd, shell=True) for cmd in cmd_list] def run(self): + print(self.file_out_name,'77777777777777') items = [] for item in self.issues_package: issue = IssueProcess(item, self.request_repo_dict, self.assignee_candidates, self.language_owner) From 4726a3047595420af2118428096f1599d0697b05 Mon Sep 17 00:00:00 2001 From: Yiming Lei <59104634+RAY-316@users.noreply.github.com> Date: Wed, 1 Dec 2021 17:28:33 +0800 Subject: [PATCH 018/103] Update main.py --- scripts/release_helper/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/release_helper/main.py b/scripts/release_helper/main.py index 3e3ac080187d..f6ba3eda3435 100644 --- a/scripts/release_helper/main.py +++ b/scripts/release_helper/main.py @@ -51,6 +51,7 @@ def main(): issues = collect_open_issues() language = os.getenv('LANGUAGE') languages = {_CONVERT[language]: _LANGUAGES[_CONVERT[language]]} if language in _CONVERT else _LANGUAGES + print(languages,'++++++++++') for language in languages: language_issues = select_language_issues(issues, language) languages[language](language_issues) From 910e856d7cd66a86573edb89dc9ab199064a86c6 Mon Sep 17 00:00:00 2001 From: Zed <601306339@qq.com> Date: Thu, 2 Dec 2021 10:38:22 +0800 Subject: [PATCH 019/103] update --- scripts/release_helper/common.py | 1 + scripts/release_helper/java.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index 8eafca8b1817..bdea823443f3 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -226,6 +226,7 @@ def __init__(self, issues: List[IssuePackage], assignee_token: Dict[str, str], l self.request_repo_dict[assignee] = Github(assignee_token[assignee]).get_repo(REQUEST_REPO) def output_md(self, items): + print('++++file out name',self.file_out_name) with open(self.file_out_name, 'w') as file_out: file_out.write( '| issue | author | package | assignee | bot advice | created date of issue | target release date | date from target |\n') diff --git a/scripts/release_helper/java.py b/scripts/release_helper/java.py index 32d0185e63dc..69fddae8b06c 100644 --- a/scripts/release_helper/java.py +++ b/scripts/release_helper/java.py @@ -33,7 +33,9 @@ def auto_parse(self) -> None: class Java(Common): - pass + def __init__(self, issues, assignee_token, language_owner): + super(Java, self).__init__(issues, assignee_token, language_owner) + self.file_out_name = 'release_java_status.md' def java_process(issues: List[Any]): From 6053c72b6836d1298be88fd0037661b593ec72f3 Mon Sep 17 00:00:00 2001 From: Zed <601306339@qq.com> Date: Thu, 2 Dec 2021 16:01:57 +0800 Subject: [PATCH 020/103] update bot advice --- scripts/release_helper/common.py | 17 ++++++++++++++--- scripts/release_helper/java.py | 1 + 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index bdea823443f3..bb62d726e9c0 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -31,7 +31,7 @@ class IssueProcess: # will be changed by order issue = None # issue that needs to handle assignee = '' - bot = [] # bot advice to help SDK owner + bot = '' # bot advice to help SDK owner target_readme_tag = '' # swagger content that customers want readme_link = '' # https link which swagger definition is in default_readme_tag = '' # configured in `README.md` @@ -199,10 +199,23 @@ def auto_assign(self) -> None: self.update_issue_instance() self.add_label(AUTO_ASSIGN_LABEL) + def bot_advice(self): + latest_comments = '' + comments = [(comment.updated_at.timestamp(), comment.user.login) for comment in + self.issue_package.issue.get_comments()] + comments.sort() + if comments: + latest_comments = comments[-1][1] + if self.issue_package.issue.comments == 0: + self.bot = 'new issue !
' + elif latest_comments not in self.language_owner: + self.bot = 'new comment.
' + def run(self) -> None: # common part(don't change the order) self.auto_assign() # necessary flow self.auto_parse() # necessary flow + self.bot_advice() class Common: @@ -226,7 +239,6 @@ def __init__(self, issues: List[IssuePackage], assignee_token: Dict[str, str], l self.request_repo_dict[assignee] = Github(assignee_token[assignee]).get_repo(REQUEST_REPO) def output_md(self, items): - print('++++file out name',self.file_out_name) with open(self.file_out_name, 'w') as file_out: file_out.write( '| issue | author | package | assignee | bot advice | created date of issue | target release date | date from target |\n') @@ -265,7 +277,6 @@ def run(self): self.output_md(items) - def common_process(issues: List[IssuePackage]): instance = Common(issues, _ASSIGNEE_TOKEN, _LANGUAGE_OWNER) instance.run() diff --git a/scripts/release_helper/java.py b/scripts/release_helper/java.py index 69fddae8b06c..d83e87ee1ae8 100644 --- a/scripts/release_helper/java.py +++ b/scripts/release_helper/java.py @@ -38,6 +38,7 @@ def __init__(self, issues, assignee_token, language_owner): self.file_out_name = 'release_java_status.md' + def java_process(issues: List[Any]): instance = Java(issues, _ASSIGNEE_TOKEN_JAVA, _JAVA_OWNER) instance.run() From be9e9bcdff544da9e9edd41cce60db1335778210 Mon Sep 17 00:00:00 2001 From: Zed <601306339@qq.com> Date: Thu, 2 Dec 2021 16:04:09 +0800 Subject: [PATCH 021/103] update --- scripts/release_helper/main.py | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/release_helper/main.py b/scripts/release_helper/main.py index f6ba3eda3435..3e3ac080187d 100644 --- a/scripts/release_helper/main.py +++ b/scripts/release_helper/main.py @@ -51,7 +51,6 @@ def main(): issues = collect_open_issues() language = os.getenv('LANGUAGE') languages = {_CONVERT[language]: _LANGUAGES[_CONVERT[language]]} if language in _CONVERT else _LANGUAGES - print(languages,'++++++++++') for language in languages: language_issues = select_language_issues(issues, language) languages[language](language_issues) From eb3875ee98030f960a68b4136ed9fb3a73a20fa6 Mon Sep 17 00:00:00 2001 From: msyyc <70930885+msyyc@users.noreply.github.com> Date: Wed, 15 Dec 2021 17:00:56 +0800 Subject: [PATCH 022/103] update --- scripts/release_helper/common.py | 13 +++++++------ scripts/release_helper/main.py | 1 - 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index bb62d726e9c0..d2f92773da11 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -224,6 +224,7 @@ class Common: request_repo_dict = {} # request repo instance generated by different token assignee_candidates = {} # assignee candidates who will be assigned to handle issue language_owner = {} # language owner who may handle issue + result = [] def __init__(self, issues: List[IssuePackage], assignee_token: Dict[str, str], language_owner: Set[str]): self.issues_package = issues @@ -238,14 +239,15 @@ def __init__(self, issues: List[IssuePackage], assignee_token: Dict[str, str], l for assignee in assignee_token: self.request_repo_dict[assignee] = Github(assignee_token[assignee]).get_repo(REQUEST_REPO) - def output_md(self, items): + def output(self): with open(self.file_out_name, 'w') as file_out: file_out.write( '| issue | author | package | assignee | bot advice | created date of issue | target release date | date from target |\n') file_out.write('| ------ | ------ | ------ | ------ | ------ | ------ | ------ | :-----: |\n') - file_out.writelines([self.output_python(item) for item in items]) + file_out.writelines([self.output_md(item) for item in self.result]) + Common.push_md_to_storage() - def output_python(self, item): + def output_md(self, item): create_date = str(date.fromtimestamp(item.issue_package.issue.created_at.timestamp()).strftime('%m-%d')) return '| [#{}]({}) | {} | {} | {} | {} | {} | {} | {} |\n'.format( @@ -266,15 +268,14 @@ def push_md_to_storage(): [sp.check_call(cmd, shell=True) for cmd in cmd_list] def run(self): - items = [] for item in self.issues_package: issue = IssueProcess(item, self.request_repo_dict, self.assignee_candidates, self.language_owner) try: issue.run() - items.append(issue) + self.result.append(issue) except Exception as e: _LOG.error(f'Error happened during handling issue {item.issue.number}: {e}') - self.output_md(items) + self.output() def common_process(issues: List[IssuePackage]): diff --git a/scripts/release_helper/main.py b/scripts/release_helper/main.py index 3e3ac080187d..59d7894f5985 100644 --- a/scripts/release_helper/main.py +++ b/scripts/release_helper/main.py @@ -54,7 +54,6 @@ def main(): for language in languages: language_issues = select_language_issues(issues, language) languages[language](language_issues) - Common.push_md_to_storage() if __name__ == '__main__': From cbba97b1c979634427916d2bcc75b0e77be55a71 Mon Sep 17 00:00:00 2001 From: msyyc <70930885+msyyc@users.noreply.github.com> Date: Wed, 15 Dec 2021 17:14:43 +0800 Subject: [PATCH 023/103] update excel --- scripts/release_helper/common.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 scripts/release_helper/common.md diff --git a/scripts/release_helper/common.md b/scripts/release_helper/common.md new file mode 100644 index 000000000000..bf792e848355 --- /dev/null +++ b/scripts/release_helper/common.md @@ -0,0 +1,3 @@ +| issue | author | package | assignee | bot advice | created date of issue | target release date | date from target | +| ------ | ------ | ------ | ------ | ------ | ------ | ------ | :-----: | +| [#2223](https://github.com/Azure/sdk-release-request/issues/2223) | msyyc | | msyyc | | 11-15 | | | From 578d349511e80449b758dbf48f959fdb49c90841 Mon Sep 17 00:00:00 2001 From: msyyc <70930885+msyyc@users.noreply.github.com> Date: Thu, 16 Dec 2021 13:58:36 +0800 Subject: [PATCH 024/103] update output function --- scripts/release_helper/common.md | 3 - scripts/release_helper/common.py | 105 ++++++++++++++++++++++--------- scripts/release_helper/utils.py | 1 + 3 files changed, 78 insertions(+), 31 deletions(-) delete mode 100644 scripts/release_helper/common.md diff --git a/scripts/release_helper/common.md b/scripts/release_helper/common.md deleted file mode 100644 index bf792e848355..000000000000 --- a/scripts/release_helper/common.md +++ /dev/null @@ -1,3 +0,0 @@ -| issue | author | package | assignee | bot advice | created date of issue | target release date | date from target | -| ------ | ------ | ------ | ------ | ------ | ------ | ------ | :-----: | -| [#2223](https://github.com/Azure/sdk-release-request/issues/2223) | msyyc | | msyyc | | 11-15 | | | diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index d2f92773da11..14aa5c5d26c9 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -1,7 +1,8 @@ from datetime import date, datetime from typing import Set, List, Dict import os -from utils import IssuePackage, REQUEST_REPO, AUTO_ASSIGN_LABEL, AUTO_PARSE_LABEL, get_origin_link_and_tag +from utils import IssuePackage, REQUEST_REPO, AUTO_ASSIGN_LABEL, AUTO_PARSE_LABEL, get_origin_link_and_tag,\ + MULTI_LINK_LABEL import re import logging import time @@ -29,19 +30,22 @@ class IssueProcess: language_owner = {} # language owner who may handle issue # will be changed by order - issue = None # issue that needs to handle + issue_package = None # issue that needs to handle assignee = '' - bot = '' # bot advice to help SDK owner + bot_advice = [] # bot advice to help SDK owner target_readme_tag = '' # swagger content that customers want readme_link = '' # https link which swagger definition is in default_readme_tag = '' # configured in `README.md` + package_name = '' # target package name + target_date = '' # target release date asked by customer + date_from_target = 0 - def __init__(self, issue: IssuePackage, request_repo_dict: Dict[str, Repository], + def __init__(self, issue_package: IssuePackage, request_repo_dict: Dict[str, Repository], assignee_candidates: Set[str], language_owner: Set[str]): - self.issue_package = issue + self.issue_package = issue_package self.request_repo_dict = request_repo_dict - self.assignee = issue.issue.assignee.login - self.owner = issue.issue.user.login + self.assignee = issue_package.issue.assignee.login + self.owner = issue_package.issue.user.login self.assignee_candidates = assignee_candidates self.language_owner = language_owner @@ -79,7 +83,7 @@ def get_readme_from_pr_link(self, link: str) -> str: pr = f"{_SWAGGER_PULL}/{pr_number}" self.comment( f'Hi, @{self.assignee}, by parsing {pr}, there are multi service link: {multi_link}. Please decide which one is the right.') - self.bot.append('multi readme link!') + self.add_label(MULTI_LINK_LABEL) raise Exception(f'multi link in "{pr}"') return readme_link[0] @@ -199,23 +203,62 @@ def auto_assign(self) -> None: self.update_issue_instance() self.add_label(AUTO_ASSIGN_LABEL) - def bot_advice(self): - latest_comments = '' + def new_issue_policy(self): + new_issue_advice = 'new issue.' + if self.issue_package.issue.comments == 0: + self.bot_advice.append(new_issue_advice) + else: + # issue that no comment from language owner will also be treated as new issue + comment_from_owner = set(comment.user.login for comment in self.issue_package.issue.get_comments() + if comment.user.login in self.language_owner) + if not comment_from_owner: + self.bot_advice.append(new_issue_advice) + + def new_comment_policy(self): + if self.issue_package.issue.comments == 0: + return comments = [(comment.updated_at.timestamp(), comment.user.login) for comment in self.issue_package.issue.get_comments()] comments.sort() - if comments: - latest_comments = comments[-1][1] - if self.issue_package.issue.comments == 0: - self.bot = 'new issue !
' - elif latest_comments not in self.language_owner: - self.bot = 'new comment.
' + latest_comments = comments[-1][1] + if latest_comments not in self.language_owner: + self.bot_advice.append('new comment.') + + def multi_link_policy(self): + if MULTI_LINK_LABEL in self.issue_package.labels_name: + self.bot_advice.append('multi readme link!') + + def remind_logic(self) -> bool: + return abs(self.date_from_target) <= 2 + + def print_date_from_target_date(self) -> str: + return str(self.date_from_target) if self.remind_logic() else '' + + def date_remind_policy(self): + if self.remind_logic(): + self.bot_advice.append('close to release date. ') + + def auto_bot_advice(self): + self.new_issue_policy() + self.new_comment_policy() + self.multi_link_policy() + self.date_remind_policy() + + def get_target_date(self): + body = self.get_issue_body() + try: + self.target_date = [line.split(':')[-1].strip() for line in body if 'Target release date' in line][0] + self.date_from_target = int((time.mktime(time.strptime(self.target_date, '%Y-%m-%d')) - time.time()) / 3600 / 24) + except Exception: + self.target_date = 'fail to get.' + self.date_from_target = 1000 # make a ridiculous data to remind failure when error happens def run(self) -> None: # common part(don't change the order) self.auto_assign() # necessary flow self.auto_parse() # necessary flow - self.bot_advice() + self.get_target_date() + self.auto_bot_advice() # make sure this is the last step class Common: @@ -241,31 +284,37 @@ def __init__(self, issues: List[IssuePackage], assignee_token: Dict[str, str], l def output(self): with open(self.file_out_name, 'w') as file_out: - file_out.write( - '| issue | author | package | assignee | bot advice | created date of issue | target release date | date from target |\n') + file_out.write('| issue | author | package | assignee | bot advice | created date of issue | target release date | date from target |\n') file_out.write('| ------ | ------ | ------ | ------ | ------ | ------ | ------ | :-----: |\n') - file_out.writelines([self.output_md(item) for item in self.result]) + for item in self.result: + try: + item_status = Common.output_md(item) + file_out.write(item_status) + except Exception as e: + _LOG.error(f'Error happened during output result of handled issue {item.issue_package.issue.number}: {e}') Common.push_md_to_storage() - def output_md(self, item): + @staticmethod + def output_md(item: IssueProcess): create_date = str(date.fromtimestamp(item.issue_package.issue.created_at.timestamp()).strftime('%m-%d')) + target_date = str(datetime.strptime(item.target_date, "%Y-%m-%d").strftime('%m-%d')) return '| [#{}]({}) | {} | {} | {} | {} | {} | {} | {} |\n'.format( item.issue_package.issue.html_url.split('/')[-1], item.issue_package.issue.html_url, item.issue_package.issue.user.login, - self.package_name, - item.issue_package.issue.assignee.login, - item.bot, + item.package_name, + item.assignee, + ' '.join(item.bot_advice), create_date, - self.target_release_date, - self.date_from_target + target_date, + item.print_date_from_target_date() ) @staticmethod def push_md_to_storage(): - cmd_list = ['git add .', 'git commit -m \"update excel\"', 'git push -f origin HEAD'] - [sp.check_call(cmd, shell=True) for cmd in cmd_list] + cmd_list = ['git add -u', 'git commit -m \"update excel\"', 'git push -f origin HEAD'] + [sp.call(cmd, shell=True) for cmd in cmd_list] def run(self): for item in self.issues_package: diff --git a/scripts/release_helper/utils.py b/scripts/release_helper/utils.py index 5cbb80341213..611a6e8e989c 100644 --- a/scripts/release_helper/utils.py +++ b/scripts/release_helper/utils.py @@ -7,6 +7,7 @@ REST_REPO = 'Azure/azure-rest-api-specs' AUTO_ASSIGN_LABEL = 'assigned' AUTO_PARSE_LABEL = 'auto-link' +MULTI_LINK_LABEL = 'MultiLink' _LOG = logging.getLogger(__name__) From 9648164733d226eae69bed9ec3ebe73decf127bf Mon Sep 17 00:00:00 2001 From: msyyc <70930885+msyyc@users.noreply.github.com> Date: Thu, 16 Dec 2021 15:10:56 +0800 Subject: [PATCH 025/103] add exception handle for bad credential --- scripts/release_helper/common.py | 9 +++++++++ scripts/release_helper/main.py | 7 +++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index 14aa5c5d26c9..ce4b87e38721 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -23,6 +23,7 @@ class IssueProcess: + """ # won't be changed anymore after __init__ request_repo_dict = {} # request repo instance generated by different token owner = '' # issue owner @@ -39,6 +40,7 @@ class IssueProcess: package_name = '' # target package name target_date = '' # target release date asked by customer date_from_target = 0 + """ def __init__(self, issue_package: IssuePackage, request_repo_dict: Dict[str, Repository], assignee_candidates: Set[str], language_owner: Set[str]): @@ -48,6 +50,13 @@ def __init__(self, issue_package: IssuePackage, request_repo_dict: Dict[str, Rep self.owner = issue_package.issue.user.login self.assignee_candidates = assignee_candidates self.language_owner = language_owner + self.bot_advice = [] + self.target_readme_tag = '' + self.readme_link = '' + self.default_readme_tag = '' + self.package_name = '' + self.target_date = '' + self.date_from_target = 0 def get_issue_body(self) -> List[str]: return [i for i in self.issue_package.issue.body.split("\n") if i] diff --git a/scripts/release_helper/main.py b/scripts/release_helper/main.py index 59d7894f5985..4db0a332c74d 100644 --- a/scripts/release_helper/main.py +++ b/scripts/release_helper/main.py @@ -52,8 +52,11 @@ def main(): language = os.getenv('LANGUAGE') languages = {_CONVERT[language]: _LANGUAGES[_CONVERT[language]]} if language in _CONVERT else _LANGUAGES for language in languages: - language_issues = select_language_issues(issues, language) - languages[language](language_issues) + try: + language_issues = select_language_issues(issues, language) + languages[language](language_issues) + except Exception as e: + _LOG.error(f'Error happened during handling {language} issue: {e}') if __name__ == '__main__': From cd06868a663ac4cc71d25330da367fefc2f61922 Mon Sep 17 00:00:00 2001 From: msyyc <70930885+msyyc@users.noreply.github.com> Date: Thu, 16 Dec 2021 15:23:07 +0800 Subject: [PATCH 026/103] fix static varaible in class --- scripts/release_helper/common.py | 17 +++++++---------- scripts/release_helper/main.py | 5 +++++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index ce4b87e38721..5fa24a5087b1 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -8,7 +8,6 @@ import time from github import Github from github.Repository import Repository -import subprocess as sp _LOG = logging.getLogger(__name__) @@ -271,15 +270,17 @@ def run(self) -> None: class Common: - """ The class defines some function for all languages to reference """ + """ The class defines some function for all languages to reference issues_package = None # issues that need to handle request_repo_dict = {} # request repo instance generated by different token assignee_candidates = {} # assignee candidates who will be assigned to handle issue language_owner = {} # language owner who may handle issue result = [] + file_out_name = '' # file that storages issue status + """ - def __init__(self, issues: List[IssuePackage], assignee_token: Dict[str, str], language_owner: Set[str]): - self.issues_package = issues + def __init__(self, issues_package: List[IssuePackage], assignee_token: Dict[str, str], language_owner: Set[str]): + self.issues_package = issues_package self.assignee_candidates = set(assignee_token.keys()) self.language_owner = language_owner # arguments add to language.md @@ -287,6 +288,8 @@ def __init__(self, issues: List[IssuePackage], assignee_token: Dict[str, str], l self.target_release_date = '' self.date_from_target = '' self.package_name = '' + self.result = [] + self.request_repo_dict = {} for assignee in assignee_token: self.request_repo_dict[assignee] = Github(assignee_token[assignee]).get_repo(REQUEST_REPO) @@ -301,7 +304,6 @@ def output(self): file_out.write(item_status) except Exception as e: _LOG.error(f'Error happened during output result of handled issue {item.issue_package.issue.number}: {e}') - Common.push_md_to_storage() @staticmethod def output_md(item: IssueProcess): @@ -320,11 +322,6 @@ def output_md(item: IssueProcess): item.print_date_from_target_date() ) - @staticmethod - def push_md_to_storage(): - cmd_list = ['git add -u', 'git commit -m \"update excel\"', 'git push -f origin HEAD'] - [sp.call(cmd, shell=True) for cmd in cmd_list] - def run(self): for item in self.issues_package: issue = IssueProcess(item, self.request_repo_dict, self.assignee_candidates, self.language_owner) diff --git a/scripts/release_helper/main.py b/scripts/release_helper/main.py index 4db0a332c74d..b1bce8266034 100644 --- a/scripts/release_helper/main.py +++ b/scripts/release_helper/main.py @@ -6,6 +6,7 @@ from java import java_process from js import js_process from common import common_process, Common +import subprocess as sp import os from typing import List @@ -58,6 +59,10 @@ def main(): except Exception as e: _LOG.error(f'Error happened during handling {language} issue: {e}') + # output + cmd_list = ['git add -u', 'git commit -m \"update excel\"', 'git push -f origin HEAD'] + [sp.call(cmd, shell=True) for cmd in cmd_list] + if __name__ == '__main__': main() From 9a79019d2ff64fcb043257be50b60d570c240139 Mon Sep 17 00:00:00 2001 From: msyyc <70930885+msyyc@users.noreply.github.com> Date: Thu, 16 Dec 2021 15:34:49 +0800 Subject: [PATCH 027/103] update auto_assignee algorithm --- scripts/release_helper/common.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index 5fa24a5087b1..d42a503550a5 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -6,6 +6,7 @@ import re import logging import time +from random import randint from github import Github from github.Repository import Repository @@ -198,7 +199,7 @@ def auto_assign(self) -> None: return # assign averagely assignees = list(self.assignee_candidates) - random_idx = int(str(time.time())[-1]) % len(assignees) if len(assignees) > 1 else 0 + random_idx = randint(0, len(assignees) - 1) if len(assignees) > 1 else 0 assignee = assignees[random_idx] # update assignee From baaa5687009fb9ddb0f95ad7c6651145a10e0148 Mon Sep 17 00:00:00 2001 From: msyyc <70930885+msyyc@users.noreply.github.com> Date: Wed, 22 Dec 2021 14:12:20 +0800 Subject: [PATCH 028/103] update bot token to have a try --- scripts/release_helper/common.py | 2 +- scripts/release_helper/release_helper.yml | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index 7798c3b37432..5c50e47dbce4 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -16,7 +16,7 @@ _LANGUAGE_OWNER = {'msyyc'} # 'github assignee': 'token' -_ASSIGNEE_TOKEN = {'msyyc': os.getenv('PYTHON_MSYYC_TOKEN')} +_ASSIGNEE_TOKEN = {'msyyc': os.getenv('AZURESDK_BOT_TOKEN')} _SWAGGER_URL = 'https://github.com/Azure/azure-rest-api-specs/blob/main/specification' _SWAGGER_PULL = 'https://github.com/Azure/azure-rest-api-specs/pull' diff --git a/scripts/release_helper/release_helper.yml b/scripts/release_helper/release_helper.yml index 9023f73a5785..cc81770803e6 100644 --- a/scripts/release_helper/release_helper.yml +++ b/scripts/release_helper/release_helper.yml @@ -15,6 +15,12 @@ schedules: - main always: true +variables: + - group: Release Secrets for GitHub + - group: SDK Release Helper + - group: Azure SDK Auto Release Pipeline Secrets + + jobs: - job: ReleaseHelper displayName: ReleaseHelper Python 3.8 @@ -48,6 +54,8 @@ jobs: export GO_DAPENGZHANG_TOKEN=$(Dapeng-GitToken) export JS_QIAOQIAO_TOKEN=$(QiaoQiao-GitToken) export LANGUAGE=$(RUN_LANGUAGE) + export AZURESDK_BOT_TOKEN=$(azuresdk-github-pat) + # create virtual env python -m venv venv-sdk From 2f8b3015db0496b0eff0dbcf7659e996a1572388 Mon Sep 17 00:00:00 2001 From: msyyc <70930885+msyyc@users.noreply.github.com> Date: Wed, 22 Dec 2021 14:26:32 +0800 Subject: [PATCH 029/103] update bot token --- scripts/release_helper/go.py | 2 +- scripts/release_helper/java.py | 6 +++--- scripts/release_helper/js.py | 2 +- scripts/release_helper/release_helper.yml | 5 +---- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/scripts/release_helper/go.py b/scripts/release_helper/go.py index 61464dd1c681..7904212f78e6 100644 --- a/scripts/release_helper/go.py +++ b/scripts/release_helper/go.py @@ -6,7 +6,7 @@ _GO_OWNER = {'ArcturusZhang'} # 'github assignee': 'token' -_ASSIGNEE_TOKEN_GO = {'ArcturusZhang': os.getenv('GO_DAPENGZHANG_TOKEN')} +_ASSIGNEE_TOKEN_GO = {'ArcturusZhang': os.getenv('AZURESDK_BOT_TOKEN')} class IssueProcessGo(IssueProcess): diff --git a/scripts/release_helper/java.py b/scripts/release_helper/java.py index d83e87ee1ae8..f880edb7a9c1 100644 --- a/scripts/release_helper/java.py +++ b/scripts/release_helper/java.py @@ -8,9 +8,9 @@ # 'github assignee': 'token' _ASSIGNEE_TOKEN_JAVA = { - 'weidongxu-microsoft': os.getenv('JAVA_WEIDONGXU_TOKEN'), - 'haolingdong-msft': os.getenv('JAVA_WEIDONGXU_TOKEN'), - 'XiaofeiCao': os.getenv('JAVA_WEIDONGXU_TOKEN'), + 'weidongxu-microsoft': os.getenv('AZURESDK_BOT_TOKEN'), + 'haolingdong-msft': os.getenv('AZURESDK_BOT_TOKEN'), + 'XiaofeiCao': os.getenv('AZURESDK_BOT_TOKEN'), } diff --git a/scripts/release_helper/js.py b/scripts/release_helper/js.py index e4532e28b90b..ae8cd80f7974 100644 --- a/scripts/release_helper/js.py +++ b/scripts/release_helper/js.py @@ -6,7 +6,7 @@ _JS_OWNER = {'qiaozha', 'lirenhe'} # 'github assignee': 'token' -_ASSIGNEE_TOKEN_JS = {'qiaozha': os.getenv('JS_QIAOQIAO_TOKEN')} +_ASSIGNEE_TOKEN_JS = {'qiaozha': os.getenv('AZURESDK_BOT_TOKEN')} class IssueProcessJs(IssueProcess): diff --git a/scripts/release_helper/release_helper.yml b/scripts/release_helper/release_helper.yml index cc81770803e6..88fbe28e2cab 100644 --- a/scripts/release_helper/release_helper.yml +++ b/scripts/release_helper/release_helper.yml @@ -50,11 +50,8 @@ jobs: export PYTHON_BIGCAT_TOKEN=$(Jiefeng-GitToken) export PYTHON_ZED_TOKEN=$(Zed-GitToken) export PYTHON_MSYYC_TOKEN=$(Yuchao-GitToken) - export JAVA_WEIDONGXU_TOKEN=$(Weidong-GitToken) - export GO_DAPENGZHANG_TOKEN=$(Dapeng-GitToken) - export JS_QIAOQIAO_TOKEN=$(QiaoQiao-GitToken) - export LANGUAGE=$(RUN_LANGUAGE) export AZURESDK_BOT_TOKEN=$(azuresdk-github-pat) + export LANGUAGE=$(RUN_LANGUAGE) # create virtual env From c914ef8697d484dc6b5cf83357a241648fbf2d65 Mon Sep 17 00:00:00 2001 From: msyyc <70930885+msyyc@users.noreply.github.com> Date: Wed, 22 Dec 2021 15:16:42 +0800 Subject: [PATCH 030/103] force to single process --- scripts/release_helper/release_helper.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release_helper/release_helper.yml b/scripts/release_helper/release_helper.yml index 88fbe28e2cab..c2a580e16924 100644 --- a/scripts/release_helper/release_helper.yml +++ b/scripts/release_helper/release_helper.yml @@ -26,7 +26,7 @@ jobs: displayName: ReleaseHelper Python 3.8 timeoutInMinutes: 30 strategy: - maxParallel: 3 + maxParallel: 1 pool: vmImage: 'ubuntu-20.04' steps: From 04f1cabf6b8924011f8342323e55a9f42da18957 Mon Sep 17 00:00:00 2001 From: "Jiefeng Chen (WICRESOFT NORTH AMERICA LTD)" Date: Thu, 17 Mar 2022 11:00:05 +0800 Subject: [PATCH 031/103] test --- scripts/release_helper/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index 5c50e47dbce4..19186a410d8b 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -46,7 +46,7 @@ def __init__(self, issue_package: IssuePackage, request_repo_dict: Dict[str, Rep assignee_candidates: Set[str], language_owner: Set[str]): self.issue_package = issue_package self.request_repo_dict = request_repo_dict - self.assignee = issue_package.issue.assignee.login + self.assignee = assignee if (assignee := issue_package.issue.assignee.login) else '' self.owner = issue_package.issue.user.login self.assignee_candidates = assignee_candidates self.language_owner = language_owner From 50a757d0a2a059146430b0dad4ad6cd0a6f57ef4 Mon Sep 17 00:00:00 2001 From: "Jiefeng Chen (WICRESOFT NORTH AMERICA LTD)" Date: Thu, 17 Mar 2022 11:17:48 +0800 Subject: [PATCH 032/103] test --- scripts/release_helper/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index 19186a410d8b..f4cc39080d32 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -46,7 +46,7 @@ def __init__(self, issue_package: IssuePackage, request_repo_dict: Dict[str, Rep assignee_candidates: Set[str], language_owner: Set[str]): self.issue_package = issue_package self.request_repo_dict = request_repo_dict - self.assignee = assignee if (assignee := issue_package.issue.assignee.login) else '' + self.assignee = assignee.login if (assignee := issue_package.issue.assignee) else '' self.owner = issue_package.issue.user.login self.assignee_candidates = assignee_candidates self.language_owner = language_owner From 27dca4fa569cdbd68ce308d876709a79aef9eaf1 Mon Sep 17 00:00:00 2001 From: "Jiefeng Chen (WICRESOFT NORTH AMERICA LTD)" Date: Thu, 17 Mar 2022 11:23:24 +0800 Subject: [PATCH 033/103] test --- scripts/release_helper/common.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index f4cc39080d32..ae9d075d0167 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -180,7 +180,8 @@ def add_label(self, label: str) -> None: self.issue_package.labels_name.add(label) def update_assignee(self, assignee_to_del: str, assignee_to_add: str) -> None: - self.issue_package.issue.remove_from_assignees(assignee_to_del) + if self.assignee: + self.issue_package.issue.remove_from_assignees(assignee_to_del) self.issue_package.issue.add_to_assignees(assignee_to_add) self.assignee = assignee_to_add From 11afaaab258363b7196c677f3575fbf3a28ce107 Mon Sep 17 00:00:00 2001 From: "Jiefeng Chen (WICRESOFT NORTH AMERICA LTD)" Date: Thu, 17 Mar 2022 11:37:10 +0800 Subject: [PATCH 034/103] test --- scripts/release_helper/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index ae9d075d0167..c5ac3a433e2d 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -180,7 +180,7 @@ def add_label(self, label: str) -> None: self.issue_package.labels_name.add(label) def update_assignee(self, assignee_to_del: str, assignee_to_add: str) -> None: - if self.assignee: + if assignee_to_del: self.issue_package.issue.remove_from_assignees(assignee_to_del) self.issue_package.issue.add_to_assignees(assignee_to_add) self.assignee = assignee_to_add From 1b4959d802e6ac32b63c0ce6071301f5e748185a Mon Sep 17 00:00:00 2001 From: "Jiefeng Chen (WICRESOFT NORTH AMERICA LTD)" Date: Thu, 17 Mar 2022 13:43:40 +0800 Subject: [PATCH 035/103] fix bug --- scripts/release_helper/common.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index c5ac3a433e2d..adc6271328e1 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -310,7 +310,10 @@ def output(self): @staticmethod def output_md(item: IssueProcess): create_date = str(date.fromtimestamp(item.issue_package.issue.created_at.timestamp()).strftime('%m-%d')) - target_date = str(datetime.strptime(item.target_date, "%Y-%m-%d").strftime('%m-%d')) + try: + target_date = str(datetime.strptime(item.target_date, "%Y-%m-%d").strftime('%m-%d')) + except: + target_date = str(item.target_date) return '| [#{}]({}) | {} | {} | {} | {} | {} | {} | {} |\n'.format( item.issue_package.issue.html_url.split('/')[-1], From 032ac00c67b310588fff9b0ed96903e514b615ab Mon Sep 17 00:00:00 2001 From: "Jiefeng Chen (WICRESOFT NORTH AMERICA LTD)" Date: Thu, 17 Mar 2022 13:47:25 +0800 Subject: [PATCH 036/103] fix --- scripts/release_helper/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index adc6271328e1..c9a953975e62 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -46,7 +46,7 @@ def __init__(self, issue_package: IssuePackage, request_repo_dict: Dict[str, Rep assignee_candidates: Set[str], language_owner: Set[str]): self.issue_package = issue_package self.request_repo_dict = request_repo_dict - self.assignee = assignee.login if (assignee := issue_package.issue.assignee) else '' + self.assignee = issue_package.issue.assignee.login if issue_package.issue.assignee else '' self.owner = issue_package.issue.user.login self.assignee_candidates = assignee_candidates self.language_owner = language_owner From 08c51a078279012068157b0e72fd4ff2b73db94f Mon Sep 17 00:00:00 2001 From: "Jiefeng Chen (WICRESOFT NORTH AMERICA LTD)" Date: Tue, 29 Mar 2022 15:51:08 +0800 Subject: [PATCH 037/103] update release_helper/js --- scripts/release_helper/js.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/scripts/release_helper/js.py b/scripts/release_helper/js.py index ae8cd80f7974..dc3d1afd2a6d 100644 --- a/scripts/release_helper/js.py +++ b/scripts/release_helper/js.py @@ -1,13 +1,25 @@ +import datetime from common import IssueProcess, Common -from typing import Any, List +from typing import Any, List, Dict import os # assignee dict which will be assigned to handle issues _JS_OWNER = {'qiaozha', 'lirenhe'} # 'github assignee': 'token' -_ASSIGNEE_TOKEN_JS = {'qiaozha': os.getenv('AZURESDK_BOT_TOKEN')} +_ASSIGNEE_TOKEN_JS = {'qiaozha': os.getenv('AZURESDK_BOT_TOKEN'), 'dw511214992': os.getenv('AZURESDK_BOT_TOKEN')} +# Set the start time to 2022-02-28 +SATRAT_DAY = '2022-02-28' + +def choose_this_week_assignee(assignee_token: Dict): + assignees = list(assignee_token.keys()) + today = datetime.datetime.today().date() + apart_days = (today - SATRAT_DAY).days + index = (apart_days//7)%len(assignees) + return {assignees[index]: _ASSIGNEE_TOKEN_JS[assignees[index]]} + +this_week_assign = choose_this_week_assignee(_ASSIGNEE_TOKEN_JS) class IssueProcessJs(IssueProcess): pass @@ -20,5 +32,5 @@ def __init__(self, issues, assignee_token, language_owner): def js_process(issues: List[Any]): - instance = Js(issues, _ASSIGNEE_TOKEN_JS, _JS_OWNER) + instance = Js(issues, this_week_assign, _JS_OWNER) instance.run() From b85417544691a0fcd16b32ed2f0be475f0b92aa0 Mon Sep 17 00:00:00 2001 From: "Jiefeng Chen (WICRESOFT NORTH AMERICA LTD)" Date: Tue, 29 Mar 2022 15:58:08 +0800 Subject: [PATCH 038/103] update release_helper/js --- scripts/release_helper/js.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/scripts/release_helper/js.py b/scripts/release_helper/js.py index dc3d1afd2a6d..dbcabdee299d 100644 --- a/scripts/release_helper/js.py +++ b/scripts/release_helper/js.py @@ -12,25 +12,24 @@ # Set the start time to 2022-02-28 SATRAT_DAY = '2022-02-28' -def choose_this_week_assignee(assignee_token: Dict): - assignees = list(assignee_token.keys()) - today = datetime.datetime.today().date() - apart_days = (today - SATRAT_DAY).days - index = (apart_days//7)%len(assignees) - return {assignees[index]: _ASSIGNEE_TOKEN_JS[assignees[index]]} - -this_week_assign = choose_this_week_assignee(_ASSIGNEE_TOKEN_JS) - class IssueProcessJs(IssueProcess): pass class Js(Common): def __init__(self, issues, assignee_token, language_owner): - super(Js, self).__init__(issues, assignee_token, language_owner) + super(Js, self).__init__(issues, self.assign_policy(assignee_token), language_owner) self.file_out_name = 'release_js_status.md' + @staticmethod + def assign_policy(assignee_token): + assignees = list(assignee_token.keys()) + today = datetime.datetime.today().date() + apart_days = (today - SATRAT_DAY).days + index = (apart_days // 7) % len(assignees) + return {assignees[index]: _ASSIGNEE_TOKEN_JS[assignees[index]]} + def js_process(issues: List[Any]): - instance = Js(issues, this_week_assign, _JS_OWNER) + instance = Js(issues, _ASSIGNEE_TOKEN_JS, _JS_OWNER) instance.run() From 3db56d9141798dd491c54ae9b354688dbd1a0f72 Mon Sep 17 00:00:00 2001 From: "Jiefeng Chen (WICRESOFT NORTH AMERICA LTD)" Date: Tue, 29 Mar 2022 16:09:26 +0800 Subject: [PATCH 039/103] fix bug --- scripts/release_helper/js.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release_helper/js.py b/scripts/release_helper/js.py index dbcabdee299d..a01d0a733737 100644 --- a/scripts/release_helper/js.py +++ b/scripts/release_helper/js.py @@ -10,7 +10,7 @@ _ASSIGNEE_TOKEN_JS = {'qiaozha': os.getenv('AZURESDK_BOT_TOKEN'), 'dw511214992': os.getenv('AZURESDK_BOT_TOKEN')} # Set the start time to 2022-02-28 -SATRAT_DAY = '2022-02-28' +SATRAT_DAY = datetime.datetime(2022, 2, 28).date() class IssueProcessJs(IssueProcess): pass From a5f26977c049037cda3cd9943f5fd9cbfb90b1e8 Mon Sep 17 00:00:00 2001 From: "Jiefeng Chen (WICRESOFT NORTH AMERICA LTD)" Date: Wed, 30 Mar 2022 11:27:54 +0800 Subject: [PATCH 040/103] update release helper --- scripts/release_helper/common.py | 12 ++++++++---- scripts/release_helper/java.py | 17 +---------------- scripts/release_helper/js.py | 23 +++++++++-------------- 3 files changed, 18 insertions(+), 34 deletions(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index c9a953975e62..e91760fd960e 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -194,14 +194,17 @@ def request_repo(self) -> Repository: def update_issue_instance(self) -> None: self.issue_package.issue = self.request_repo().get_issue(self.issue_package.issue.number) + def auto_assign_policy(self) -> str: + assignees = list(self.assignee_candidates) + random_idx = randint(0, len(assignees) - 1) if len(assignees) > 1 else 0 + return assignees[random_idx] + def auto_assign(self) -> None: if AUTO_ASSIGN_LABEL in self.issue_package.labels_name: self.update_issue_instance() return # assign averagely - assignees = list(self.assignee_candidates) - random_idx = randint(0, len(assignees) - 1) if len(assignees) > 1 else 0 - assignee = assignees[random_idx] + assignee = self.auto_assign_policy() # update assignee if self.assignee != assignee: @@ -292,6 +295,7 @@ def __init__(self, issues_package: List[IssuePackage], assignee_token: Dict[str, self.package_name = '' self.result = [] self.request_repo_dict = {} + self.issue_process_function = IssueProcess for assignee in assignee_token: self.request_repo_dict[assignee] = Github(assignee_token[assignee]).get_repo(REQUEST_REPO) @@ -330,7 +334,7 @@ def output_md(item: IssueProcess): def run(self): items = [] for item in self.issues_package: - issue = IssueProcess(item, self.request_repo_dict, self.assignee_candidates, self.language_owner) + issue = self.issue_process_function(item, self.request_repo_dict, self.assignee_candidates, self.language_owner) try: issue.run() self.result.append(issue) diff --git a/scripts/release_helper/java.py b/scripts/release_helper/java.py index f880edb7a9c1..65b84f38c601 100644 --- a/scripts/release_helper/java.py +++ b/scripts/release_helper/java.py @@ -15,22 +15,7 @@ class IssueProcessJava(IssueProcess): - - def auto_parse(self) -> None: - if AUTO_PARSE_LABEL in self.issue_package.labels_name: - return - - self.add_label(AUTO_PARSE_LABEL) - issue_body_list = self.get_issue_body() - - # Get the origin link and readme tag in issue body - origin_link, self.target_readme_tag = get_origin_link_and_tag(issue_body_list) - - # get readme_link - self.get_readme_link(origin_link) - - self.edit_issue_body() - + pass class Java(Common): def __init__(self, issues, assignee_token, language_owner): diff --git a/scripts/release_helper/js.py b/scripts/release_helper/js.py index a01d0a733737..911abdb57e36 100644 --- a/scripts/release_helper/js.py +++ b/scripts/release_helper/js.py @@ -7,28 +7,23 @@ _JS_OWNER = {'qiaozha', 'lirenhe'} # 'github assignee': 'token' -_ASSIGNEE_TOKEN_JS = {'qiaozha': os.getenv('AZURESDK_BOT_TOKEN'), 'dw511214992': os.getenv('AZURESDK_BOT_TOKEN')} +_ASSIGNEE_TOKEN_JS = {'qiaozha': os.getenv('AZURESDK_BOT_TOKEN'), 'MaryGao': os.getenv('AZURESDK_BOT_TOKEN')} -# Set the start time to 2022-02-28 -SATRAT_DAY = datetime.datetime(2022, 2, 28).date() class IssueProcessJs(IssueProcess): - pass + def auto_assign_policy(self) -> str: + weeks = datetime.datetime.now().isocalendar()[1] + assignees = list(self.assignee_candidates) + assignees.sort(key=list(_ASSIGNEE_TOKEN_JS.keys()).index) + random_idx = weeks % len(assignees) + return assignees[random_idx] class Js(Common): def __init__(self, issues, assignee_token, language_owner): - super(Js, self).__init__(issues, self.assign_policy(assignee_token), language_owner) + super(Js, self).__init__(issues, assignee_token, language_owner) self.file_out_name = 'release_js_status.md' - - @staticmethod - def assign_policy(assignee_token): - assignees = list(assignee_token.keys()) - today = datetime.datetime.today().date() - apart_days = (today - SATRAT_DAY).days - index = (apart_days // 7) % len(assignees) - return {assignees[index]: _ASSIGNEE_TOKEN_JS[assignees[index]]} - + self.issue_process_function = IssueProcessJs def js_process(issues: List[Any]): instance = Js(issues, _ASSIGNEE_TOKEN_JS, _JS_OWNER) From 59ca18609701cb9777abf393c4615dd42bfdbd32 Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Wed, 30 Mar 2022 15:05:13 +0800 Subject: [PATCH 041/103] Update js.py --- scripts/release_helper/js.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release_helper/js.py b/scripts/release_helper/js.py index 911abdb57e36..05d77cbc1fb1 100644 --- a/scripts/release_helper/js.py +++ b/scripts/release_helper/js.py @@ -14,7 +14,7 @@ class IssueProcessJs(IssueProcess): def auto_assign_policy(self) -> str: weeks = datetime.datetime.now().isocalendar()[1] assignees = list(self.assignee_candidates) - assignees.sort(key=list(_ASSIGNEE_TOKEN_JS.keys()).index) + assignees.sort() random_idx = weeks % len(assignees) return assignees[random_idx] From f3f66c2fffa83838a202217d0827d5867a647bbb Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Wed, 30 Mar 2022 16:33:16 +0800 Subject: [PATCH 042/103] Update js.py --- scripts/release_helper/js.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release_helper/js.py b/scripts/release_helper/js.py index 05d77cbc1fb1..426194c77f88 100644 --- a/scripts/release_helper/js.py +++ b/scripts/release_helper/js.py @@ -1,6 +1,6 @@ import datetime from common import IssueProcess, Common -from typing import Any, List, Dict +from typing import Any, List import os # assignee dict which will be assigned to handle issues From 1a79e8943d90c84ba506c219bc16249a9dd9ce41 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Wed, 30 Mar 2022 16:35:31 +0800 Subject: [PATCH 043/103] Update js.py --- scripts/release_helper/js.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release_helper/js.py b/scripts/release_helper/js.py index 426194c77f88..12495205d993 100644 --- a/scripts/release_helper/js.py +++ b/scripts/release_helper/js.py @@ -4,7 +4,7 @@ import os # assignee dict which will be assigned to handle issues -_JS_OWNER = {'qiaozha', 'lirenhe'} +_JS_OWNER = {'qiaozha', 'lirenhe', 'MaryGao'} # 'github assignee': 'token' _ASSIGNEE_TOKEN_JS = {'qiaozha': os.getenv('AZURESDK_BOT_TOKEN'), 'MaryGao': os.getenv('AZURESDK_BOT_TOKEN')} From 3cadc340f19c404acba695eb455125dd7fb4cb9f Mon Sep 17 00:00:00 2001 From: "Jiefeng Chen (WICRESOFT NORTH AMERICA LTD)" Date: Fri, 8 Apr 2022 09:51:38 +0800 Subject: [PATCH 044/103] urldecode --- scripts/release_helper/common.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index e91760fd960e..5b1184e58f39 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -1,15 +1,18 @@ from datetime import date, datetime from typing import Set, List, Dict import os -from utils import IssuePackage, REQUEST_REPO, AUTO_ASSIGN_LABEL, AUTO_PARSE_LABEL, get_origin_link_and_tag,\ - MULTI_LINK_LABEL import re import logging import time +import urllib.parse + from random import randint from github import Github from github.Repository import Repository +from utils import IssuePackage, REQUEST_REPO, AUTO_ASSIGN_LABEL, AUTO_PARSE_LABEL, get_origin_link_and_tag,\ + MULTI_LINK_LABEL + _LOG = logging.getLogger(__name__) # assignee dict which will be assigned to handle issues @@ -79,7 +82,7 @@ def get_readme_from_pr_link(self, link: str) -> str: pr_info = self.issue_package.rest_repo.get_pull(number=pr_number) pk_url_name = set() for pr_changed_file in pr_info.get_files(): - contents_url = pr_changed_file.contents_url + contents_url = urllib.parse.unquote(pr_changed_file.contents_url) if '/resource-manager' not in contents_url: continue try: From 7fe5dda0ff368f229f1a7895403b5480cb0eea36 Mon Sep 17 00:00:00 2001 From: "Jiefeng Chen (WICRESOFT NORTH AMERICA LTD)" Date: Fri, 8 Apr 2022 10:04:22 +0800 Subject: [PATCH 045/103] format --- scripts/release_helper/common.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index 5b1184e58f39..87ec050e5a5c 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -1,12 +1,12 @@ -from datetime import date, datetime -from typing import Set, List, Dict import os import re import logging import time import urllib.parse - +from datetime import date, datetime +from typing import Set, List, Dict from random import randint + from github import Github from github.Repository import Repository From 1d7b49281c41e1457eb14c9d410211d1c485057b Mon Sep 17 00:00:00 2001 From: "Jiefeng Chen (WICRESOFT NORTH AMERICA LTD)" Date: Thu, 9 Jun 2022 16:07:25 +0800 Subject: [PATCH 046/103] add python --- scripts/release_helper/main.py | 2 +- scripts/release_helper/python.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/release_helper/main.py b/scripts/release_helper/main.py index 2a7098746820..2f382a601dac 100644 --- a/scripts/release_helper/main.py +++ b/scripts/release_helper/main.py @@ -26,7 +26,7 @@ } _LANGUAGES = { 'Test': common_process, - # 'Python': python_process, + 'Python': python_process, 'Java': java_process, 'Go': go_process, 'JS': js_process diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index 3ac9aabf4581..fcd6267107b1 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -17,7 +17,9 @@ class IssueProcessPython(IssueProcess): class Python(Common): - pass + def __init__(self, issues, assignee_token, language_owner): + super(Python, self).__init__(issues, assignee_token, language_owner) + self.file_out_name = 'release_java_status.md' def python_process(issues: List[Any]): From 1a7ea45783904d77035c210c51e6e81d99a50756 Mon Sep 17 00:00:00 2001 From: "Jiefeng Chen (WICRESOFT NORTH AMERICA LTD)" Date: Thu, 9 Jun 2022 16:17:59 +0800 Subject: [PATCH 047/103] fix --- scripts/release_helper/python.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index fcd6267107b1..ff8a7f986c52 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -19,7 +19,7 @@ class IssueProcessPython(IssueProcess): class Python(Common): def __init__(self, issues, assignee_token, language_owner): super(Python, self).__init__(issues, assignee_token, language_owner) - self.file_out_name = 'release_java_status.md' + self.file_out_name = 'release_python_status.md' def python_process(issues: List[Any]): From 38c743bee99ba57c627bd2fefdcb32be099b47b5 Mon Sep 17 00:00:00 2001 From: "Jiefeng Chen (WICRESOFT NORTH AMERICA LTD)" Date: Thu, 9 Jun 2022 17:14:29 +0800 Subject: [PATCH 048/103] add package name --- scripts/release_helper/python.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index ff8a7f986c52..fe1c31405494 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -1,9 +1,11 @@ +import re + from common import IssueProcess, Common from typing import Any, List import os # assignee dict which will be assigned to handle issues -_PYTHON_OWNER = {'BigCat20196', 'msyyc'} +_PYTHON_OWNER = {'BigCat20196', 'msyyc', 'azure-sdk'} # 'github assignee': 'token' _ASSIGNEE_TOKEN_PYTHON = { @@ -13,8 +15,26 @@ class IssueProcessPython(IssueProcess): - pass + def get_package_name(self) -> None: + pattern_resource_manager = re.compile(r'/specification/([\w-]+/)+resource-manager') + readme_python_path = pattern_resource_manager.search(self.readme_link).group() + '/readme.python.md' + contents = str(self.issue_package.rest_repo.get_contents(readme_python_path).decoded_content) + pattern_package = re.compile(r'package-name: [\w+-.]+') + self.package_name = pattern_package.search(contents).group().split(':')[-1].strip() + + def edit_issue_body(self) -> None: + self.get_package_name() + issue_body_list = [i for i in self.issue_package.issue.body.split("\n") if i] + issue_body_list.insert(0, f'\n{self.readme_link.replace("/readme.md", "")}') + issue_body_list.insert(1, self.package_name) + issue_body_up = '' + # solve format problems + for raw in issue_body_list: + if raw == '---\r' or raw == '---': + issue_body_up += '\n' + issue_body_up += raw + '\n' + self.issue_package.issue.edit(body=issue_body_up) class Python(Common): def __init__(self, issues, assignee_token, language_owner): From fbd66880e3471575d3dc536c744cf0ef04bd0126 Mon Sep 17 00:00:00 2001 From: "Jiefeng Chen (WICRESOFT NORTH AMERICA LTD)" Date: Thu, 9 Jun 2022 17:42:24 +0800 Subject: [PATCH 049/103] update package name --- scripts/release_helper/python.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index fe1c31405494..be9648f3ac5e 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -16,18 +16,18 @@ class IssueProcessPython(IssueProcess): - def get_package_name(self) -> None: + def get_package_name(self) -> str: pattern_resource_manager = re.compile(r'/specification/([\w-]+/)+resource-manager') readme_python_path = pattern_resource_manager.search(self.readme_link).group() + '/readme.python.md' contents = str(self.issue_package.rest_repo.get_contents(readme_python_path).decoded_content) pattern_package = re.compile(r'package-name: [\w+-.]+') - self.package_name = pattern_package.search(contents).group().split(':')[-1].strip() + package_name = pattern_package.search(contents).group().split(':')[-1].strip() + return package_name def edit_issue_body(self) -> None: - self.get_package_name() issue_body_list = [i for i in self.issue_package.issue.body.split("\n") if i] issue_body_list.insert(0, f'\n{self.readme_link.replace("/readme.md", "")}') - issue_body_list.insert(1, self.package_name) + issue_body_list.insert(1, self.get_package_name()) issue_body_up = '' # solve format problems for raw in issue_body_list: From 80176c7707e66e8d8ddf9cf38ca243c23990bccc Mon Sep 17 00:00:00 2001 From: "Jiefeng Chen (WICRESOFT NORTH AMERICA LTD)" Date: Thu, 9 Jun 2022 17:46:44 +0800 Subject: [PATCH 050/103] update package name --- scripts/release_helper/python.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index be9648f3ac5e..09a3a2a4f335 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -22,6 +22,7 @@ def get_package_name(self) -> str: contents = str(self.issue_package.rest_repo.get_contents(readme_python_path).decoded_content) pattern_package = re.compile(r'package-name: [\w+-.]+') package_name = pattern_package.search(contents).group().split(':')[-1].strip() + print(f'*** package_name: {package_name}') return package_name def edit_issue_body(self) -> None: From 751f1d96aa60cacd87d393ae071074da1e97bd97 Mon Sep 17 00:00:00 2001 From: "Jiefeng Chen (WICRESOFT NORTH AMERICA LTD)" Date: Thu, 9 Jun 2022 17:52:56 +0800 Subject: [PATCH 051/103] fix bug --- scripts/release_helper/python.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index 09a3a2a4f335..0cb41603ae0e 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -16,19 +16,19 @@ class IssueProcessPython(IssueProcess): - def get_package_name(self) -> str: + def get_package_name(self) -> None: pattern_resource_manager = re.compile(r'/specification/([\w-]+/)+resource-manager') readme_python_path = pattern_resource_manager.search(self.readme_link).group() + '/readme.python.md' contents = str(self.issue_package.rest_repo.get_contents(readme_python_path).decoded_content) pattern_package = re.compile(r'package-name: [\w+-.]+') - package_name = pattern_package.search(contents).group().split(':')[-1].strip() - print(f'*** package_name: {package_name}') - return package_name + self.package_name = pattern_package.search(contents).group().split(':')[-1].strip() + print(f'*** package_name: {self.package_name}') def edit_issue_body(self) -> None: + self.get_package_name() issue_body_list = [i for i in self.issue_package.issue.body.split("\n") if i] issue_body_list.insert(0, f'\n{self.readme_link.replace("/readme.md", "")}') - issue_body_list.insert(1, self.get_package_name()) + issue_body_list.insert(1, self.package_name) issue_body_up = '' # solve format problems for raw in issue_body_list: @@ -41,6 +41,7 @@ class Python(Common): def __init__(self, issues, assignee_token, language_owner): super(Python, self).__init__(issues, assignee_token, language_owner) self.file_out_name = 'release_python_status.md' + self.issue_process_function = IssueProcessPython def python_process(issues: List[Any]): From fba64566c0a0fb5723f7f075dc20c5827463215e Mon Sep 17 00:00:00 2001 From: "Jiefeng Chen (WICRESOFT NORTH AMERICA LTD)" Date: Fri, 10 Jun 2022 10:06:30 +0800 Subject: [PATCH 052/103] update get edit_content --- scripts/release_helper/common.py | 7 ++++++- scripts/release_helper/python.py | 13 ++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index 87ec050e5a5c..38a516dc70b6 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -57,6 +57,7 @@ def __init__(self, issue_package: IssuePackage, request_repo_dict: Dict[str, Rep self.target_readme_tag = '' self.readme_link = '' self.default_readme_tag = '' + self.edit_content = '' self.package_name = '' self.target_date = '' self.date_from_target = 0 @@ -139,9 +140,13 @@ def get_default_readme_tag(self) -> None: pattern_tag = re.compile(r'tag: package-[\w+-.]+') self.default_readme_tag = pattern_tag.search(contents).group().split(':')[-1].strip() + def get_edit_content(self) -> None: + self.edit_content = f'\n{self.readme_link.replace("/readme.md", "")}' + def edit_issue_body(self) -> None: + self.get_edit_content() issue_body_list = [i for i in self.issue_package.issue.body.split("\n") if i] - issue_body_list.insert(0, f'\n{self.readme_link.replace("/readme.md", "")}') + issue_body_list.insert(0, self.edit_content) issue_body_up = '' # solve format problems for raw in issue_body_list: diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index 0cb41603ae0e..3a5e48a00c7d 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -24,18 +24,9 @@ def get_package_name(self) -> None: self.package_name = pattern_package.search(contents).group().split(':')[-1].strip() print(f'*** package_name: {self.package_name}') - def edit_issue_body(self) -> None: + def get_edit_content(self) -> None: self.get_package_name() - issue_body_list = [i for i in self.issue_package.issue.body.split("\n") if i] - issue_body_list.insert(0, f'\n{self.readme_link.replace("/readme.md", "")}') - issue_body_list.insert(1, self.package_name) - issue_body_up = '' - # solve format problems - for raw in issue_body_list: - if raw == '---\r' or raw == '---': - issue_body_up += '\n' - issue_body_up += raw + '\n' - self.issue_package.issue.edit(body=issue_body_up) + self.edit_content = f'\n{self.readme_link.replace("/readme.md", "")}\n{self.package_name}' class Python(Common): def __init__(self, issues, assignee_token, language_owner): From e4dcb02f051a367813d42cae900dde0ba0bc3d43 Mon Sep 17 00:00:00 2001 From: "Jiefeng Chen (WICRESOFT NORTH AMERICA LTD)" Date: Fri, 10 Jun 2022 13:35:04 +0800 Subject: [PATCH 053/103] auto-close --- scripts/release_helper/common.py | 1 + scripts/release_helper/python.py | 20 ++++++++++++++++++-- scripts/release_helper/utils.py | 24 ++++++++++++++++++++++-- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index 38a516dc70b6..472d7bec1fdb 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -51,6 +51,7 @@ def __init__(self, issue_package: IssuePackage, request_repo_dict: Dict[str, Rep self.request_repo_dict = request_repo_dict self.assignee = issue_package.issue.assignee.login if issue_package.issue.assignee else '' self.owner = issue_package.issue.user.login + self.created_time = issue_package.issue.created_at self.assignee_candidates = assignee_candidates self.language_owner = language_owner self.bot_advice = [] diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index 3a5e48a00c7d..d94c4a0c6b84 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -1,8 +1,9 @@ +import os import re +from typing import Any, List from common import IssueProcess, Common -from typing import Any, List -import os +from utils import AUTO_CLOSE_LABEL, get_last_released_date # assignee dict which will be assigned to handle issues _PYTHON_OWNER = {'BigCat20196', 'msyyc', 'azure-sdk'} @@ -28,6 +29,21 @@ def get_edit_content(self) -> None: self.get_package_name() self.edit_content = f'\n{self.readme_link.replace("/readme.md", "")}\n{self.package_name}' + def auto_close(self) -> None: + if AUTO_CLOSE_LABEL in self.issue_package.labels_name: + return + last_version, last_time = get_last_released_date(self.package_name) + if last_time and last_time > self.created_time: + comment = f'Hi @{self.owner}, pypi link: https://pypi.org/project/{self.package_name}/{last_version}/' + self.issue_package.issue.create_comment(body=comment) + self.issue_package.issue.edit(state='closed') + self.issue_package.issue.add_to_labels('auto-closed') + self.log("has been closed!") + + def run(self) -> None: + super().run() + self.auto_close() + class Python(Common): def __init__(self, issues, assignee_token, language_owner): super(Python, self).__init__(issues, assignee_token, language_owner) diff --git a/scripts/release_helper/utils.py b/scripts/release_helper/utils.py index 611a6e8e989c..67220ea89eab 100644 --- a/scripts/release_helper/utils.py +++ b/scripts/release_helper/utils.py @@ -1,12 +1,17 @@ -from github.Issue import Issue -from github.Repository import Repository +import datetime import logging from typing import List +from bs4 import BeautifulSoup +from github.Issue import Issue +from github.Repository import Repository +import requests + REQUEST_REPO = 'Azure/sdk-release-request' REST_REPO = 'Azure/azure-rest-api-specs' AUTO_ASSIGN_LABEL = 'assigned' AUTO_PARSE_LABEL = 'auto-link' +AUTO_CLOSE_LABEL = 'auto-close' MULTI_LINK_LABEL = 'MultiLink' _LOG = logging.getLogger(__name__) @@ -27,6 +32,20 @@ def get_origin_link_and_tag(issue_body_list: List[str]) -> (str, str): link = link.replace('[', "").replace(']', "").replace('(', "").replace(')', "") return link, readme_tag +def get_last_released_date(package_name): + pypi_link = f'https://pypi.org/project/{package_name}/#history' + res = requests.get(pypi_link) + soup = BeautifulSoup(res.text, 'html.parser') + # find top div from
+ try: + package_info = soup.select('div[class="release-timeline"]')[0].find_all('div')[0] + last_version_mix = package_info.find_all('p', class_="release__version")[0].contents[0] + except IndexError as e: + return '', '' + last_version = last_version_mix.replace(' ', '').replace('\n', '') + last_version_date_str = package_info.time.attrs['datetime'].split('+')[0] + last_version_date = datetime.datetime.strptime(last_version_date_str, '%Y-%m-%dT%H:%M:%S') + return last_version, last_version_date class IssuePackage: issue = None # origin issue instance @@ -35,5 +54,6 @@ class IssuePackage: def __init__(self, issue: Issue, rest_repo: Repository): self.issue = issue + self.issue_num = self.rest_repo = rest_repo self.labels_name = {label.name for label in issue.labels} From 98acf92cc42cc0891a98b327db52ce8e9cdd0ced Mon Sep 17 00:00:00 2001 From: "Jiefeng Chen (WICRESOFT NORTH AMERICA LTD)" Date: Mon, 13 Jun 2022 14:22:16 +0800 Subject: [PATCH 054/103] record release --- scripts/release_helper/python.py | 7 ++++++- scripts/release_helper/utils.py | 20 +++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index d94c4a0c6b84..16a5dd281677 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -3,7 +3,7 @@ from typing import Any, List from common import IssueProcess, Common -from utils import AUTO_CLOSE_LABEL, get_last_released_date +from utils import AUTO_CLOSE_LABEL, get_last_released_date, record_release # assignee dict which will be assigned to handle issues _PYTHON_OWNER = {'BigCat20196', 'msyyc', 'azure-sdk'} @@ -14,6 +14,9 @@ 'msyyc': os.getenv('PYTHON_MSYYC_TOKEN'), } +# record published issues +_FILE_OUT = 'published_issues_python.csv' + class IssueProcessPython(IssueProcess): @@ -39,10 +42,12 @@ def auto_close(self) -> None: self.issue_package.issue.edit(state='closed') self.issue_package.issue.add_to_labels('auto-closed') self.log("has been closed!") + record_release(self.package_name, self.issue_package.issue, _FILE_OUT) def run(self) -> None: super().run() self.auto_close() + class Python(Common): def __init__(self, issues, assignee_token, language_owner): diff --git a/scripts/release_helper/utils.py b/scripts/release_helper/utils.py index 67220ea89eab..17ce9bc7285e 100644 --- a/scripts/release_helper/utils.py +++ b/scripts/release_helper/utils.py @@ -1,6 +1,6 @@ import datetime import logging -from typing import List +from typing import List, Any from bs4 import BeautifulSoup from github.Issue import Issue @@ -32,7 +32,8 @@ def get_origin_link_and_tag(issue_body_list: List[str]) -> (str, str): link = link.replace('[', "").replace(']', "").replace('(', "").replace(')', "") return link, readme_tag -def get_last_released_date(package_name): + +def get_last_released_date(package_name: str) -> (str, str): pypi_link = f'https://pypi.org/project/{package_name}/#history' res = requests.get(pypi_link) soup = BeautifulSoup(res.text, 'html.parser') @@ -47,6 +48,20 @@ def get_last_released_date(package_name): last_version_date = datetime.datetime.strptime(last_version_date_str, '%Y-%m-%dT%H:%M:%S') return last_version, last_version_date + +def record_release(package_name: str, issue_info: Any, file: str) -> None: + created_at = issue_info.created_at.strftime('%Y-%m-%d') + closed_at = issue_info.closed_at.strftime('%Y-%m-%d') + assignee = issue_info.assignee.login + link = issue_info.html_url + closed_issue_info = f'{package_name},{assignee},{created_at},{closed_at},{link}\n' + with open(file, 'r') as file_read: + lines = file_read.readlines() + with open(file, 'w') as file_write: + lines.insert(1, closed_issue_info) + file_write.writelines(lines) + + class IssuePackage: issue = None # origin issue instance rest_repo = None # repo instance: Azure/azure-rest-api-specs @@ -54,6 +69,5 @@ class IssuePackage: def __init__(self, issue: Issue, rest_repo: Repository): self.issue = issue - self.issue_num = self.rest_repo = rest_repo self.labels_name = {label.name for label in issue.labels} From 59a156b68622efb563fa45e7a08e62fa266f61f7 Mon Sep 17 00:00:00 2001 From: "Jiefeng Chen (WICRESOFT NORTH AMERICA LTD)" Date: Mon, 13 Jun 2022 14:37:02 +0800 Subject: [PATCH 055/103] debug --- scripts/release_helper/common.py | 1 + scripts/release_helper/python.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index 472d7bec1fdb..abb817cf0328 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -314,6 +314,7 @@ def output(self): file_out.write('| issue | author | package | assignee | bot advice | created date of issue | target release date | date from target |\n') file_out.write('| ------ | ------ | ------ | ------ | ------ | ------ | ------ | :-----: |\n') for item in self.result: + print(f'**** item: {item}') try: item_status = Common.output_md(item) file_out.write(item_status) diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index 16a5dd281677..7d8871d1dcc0 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -47,7 +47,7 @@ def auto_close(self) -> None: def run(self) -> None: super().run() self.auto_close() - + class Python(Common): def __init__(self, issues, assignee_token, language_owner): From d7f4fcae5e59f7ccff2c76db0764a6219e352661 Mon Sep 17 00:00:00 2001 From: "Jiefeng Chen (WICRESOFT NORTH AMERICA LTD)" Date: Mon, 13 Jun 2022 14:43:33 +0800 Subject: [PATCH 056/103] debug --- scripts/release_helper/common.py | 2 +- scripts/release_helper/python.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index abb817cf0328..fb8a40b1f450 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -314,7 +314,7 @@ def output(self): file_out.write('| issue | author | package | assignee | bot advice | created date of issue | target release date | date from target |\n') file_out.write('| ------ | ------ | ------ | ------ | ------ | ------ | ------ | :-----: |\n') for item in self.result: - print(f'**** item: {item}') + print(f'**** item: {dict(item)}') try: item_status = Common.output_md(item) file_out.write(item_status) diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index 7d8871d1dcc0..c49cd7f4669d 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -29,7 +29,6 @@ def get_package_name(self) -> None: print(f'*** package_name: {self.package_name}') def get_edit_content(self) -> None: - self.get_package_name() self.edit_content = f'\n{self.readme_link.replace("/readme.md", "")}\n{self.package_name}' def auto_close(self) -> None: @@ -45,6 +44,7 @@ def auto_close(self) -> None: record_release(self.package_name, self.issue_package.issue, _FILE_OUT) def run(self) -> None: + self.get_package_name() super().run() self.auto_close() From c338d581ca090de71a080f6141cc2070bc23397d Mon Sep 17 00:00:00 2001 From: "Jiefeng Chen (WICRESOFT NORTH AMERICA LTD)" Date: Mon, 13 Jun 2022 14:49:35 +0800 Subject: [PATCH 057/103] debug --- scripts/release_helper/common.py | 2 +- scripts/release_helper/python.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index fb8a40b1f450..abb817cf0328 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -314,7 +314,7 @@ def output(self): file_out.write('| issue | author | package | assignee | bot advice | created date of issue | target release date | date from target |\n') file_out.write('| ------ | ------ | ------ | ------ | ------ | ------ | ------ | :-----: |\n') for item in self.result: - print(f'**** item: {dict(item)}') + print(f'**** item: {item}') try: item_status = Common.output_md(item) file_out.write(item_status) diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index c49cd7f4669d..5dbd79ff44cd 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -48,6 +48,9 @@ def run(self) -> None: super().run() self.auto_close() + def __repr__(self): + return self.issue_package.issue.number, self.package_name + class Python(Common): def __init__(self, issues, assignee_token, language_owner): From 7d04c42208a866726a70f98514a2ecba137bffd9 Mon Sep 17 00:00:00 2001 From: "Jiefeng Chen (WICRESOFT NORTH AMERICA LTD)" Date: Mon, 13 Jun 2022 16:10:15 +0800 Subject: [PATCH 058/103] override run --- scripts/release_helper/python.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index 5dbd79ff44cd..7310f19da85b 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -44,8 +44,12 @@ def auto_close(self) -> None: record_release(self.package_name, self.issue_package.issue, _FILE_OUT) def run(self) -> None: + # common part(don't change the order) + self.auto_assign() # necessary flow + self.auto_parse() # necessary flow self.get_package_name() - super().run() + self.get_target_date() + self.auto_bot_advice() # make sure this is the last step self.auto_close() def __repr__(self): From 195d661575f674c3fada288021288691753b734b Mon Sep 17 00:00:00 2001 From: "Jiefeng Chen (WICRESOFT NORTH AMERICA LTD)" Date: Mon, 13 Jun 2022 16:29:04 +0800 Subject: [PATCH 059/103] init readme link --- scripts/release_helper/common.py | 1 + scripts/release_helper/python.py | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index abb817cf0328..3c699dca900f 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -278,6 +278,7 @@ def get_target_date(self): def run(self) -> None: # common part(don't change the order) self.auto_assign() # necessary flow + self.init_readme_link() self.auto_parse() # necessary flow self.get_target_date() self.auto_bot_advice() # make sure this is the last step diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index 7310f19da85b..c2b2ff0ba94a 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -2,7 +2,7 @@ import re from typing import Any, List -from common import IssueProcess, Common +from common import IssueProcess, Common, get_origin_link_and_tag from utils import AUTO_CLOSE_LABEL, get_last_released_date, record_release # assignee dict which will be assigned to handle issues @@ -20,7 +20,17 @@ class IssueProcessPython(IssueProcess): + def init_readme_link(self) -> None: + issue_body_list = self.get_issue_body() + + # Get the origin link and readme tag in issue body + origin_link, self.target_readme_tag = get_origin_link_and_tag(issue_body_list) + + # get readme_link + self.get_readme_link(origin_link) + def get_package_name(self) -> None: + self.init_readme_link() pattern_resource_manager = re.compile(r'/specification/([\w-]+/)+resource-manager') readme_python_path = pattern_resource_manager.search(self.readme_link).group() + '/readme.python.md' contents = str(self.issue_package.rest_repo.get_contents(readme_python_path).decoded_content) @@ -44,12 +54,8 @@ def auto_close(self) -> None: record_release(self.package_name, self.issue_package.issue, _FILE_OUT) def run(self) -> None: - # common part(don't change the order) - self.auto_assign() # necessary flow - self.auto_parse() # necessary flow self.get_package_name() - self.get_target_date() - self.auto_bot_advice() # make sure this is the last step + super().run() self.auto_close() def __repr__(self): From b182787df7b1ef61899ca80769d172f3bac5bc93 Mon Sep 17 00:00:00 2001 From: "Jiefeng Chen (WICRESOFT NORTH AMERICA LTD)" Date: Mon, 13 Jun 2022 16:43:19 +0800 Subject: [PATCH 060/103] fix --- scripts/release_helper/common.py | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index 3c699dca900f..abb817cf0328 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -278,7 +278,6 @@ def get_target_date(self): def run(self) -> None: # common part(don't change the order) self.auto_assign() # necessary flow - self.init_readme_link() self.auto_parse() # necessary flow self.get_target_date() self.auto_bot_advice() # make sure this is the last step From 059636375c191078adcac1f146ab657363efc74a Mon Sep 17 00:00:00 2001 From: "Jiefeng Chen (WICRESOFT NORTH AMERICA LTD)" Date: Mon, 13 Jun 2022 16:49:32 +0800 Subject: [PATCH 061/103] fix --- scripts/release_helper/common.py | 2 +- scripts/release_helper/python.py | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index abb817cf0328..fb6c4e63e157 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -314,7 +314,7 @@ def output(self): file_out.write('| issue | author | package | assignee | bot advice | created date of issue | target release date | date from target |\n') file_out.write('| ------ | ------ | ------ | ------ | ------ | ------ | ------ | :-----: |\n') for item in self.result: - print(f'**** item: {item}') + print(f'**** item: {item.issue}') try: item_status = Common.output_md(item) file_out.write(item_status) diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index c2b2ff0ba94a..fa27564aac76 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -58,10 +58,6 @@ def run(self) -> None: super().run() self.auto_close() - def __repr__(self): - return self.issue_package.issue.number, self.package_name - - class Python(Common): def __init__(self, issues, assignee_token, language_owner): super(Python, self).__init__(issues, assignee_token, language_owner) From 7b11ace7920be500c60c36b3bc79c6e0841156d8 Mon Sep 17 00:00:00 2001 From: "Jiefeng Chen (WICRESOFT NORTH AMERICA LTD)" Date: Mon, 13 Jun 2022 16:54:22 +0800 Subject: [PATCH 062/103] fix --- scripts/release_helper/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index fb6c4e63e157..480ddcdd7128 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -314,7 +314,7 @@ def output(self): file_out.write('| issue | author | package | assignee | bot advice | created date of issue | target release date | date from target |\n') file_out.write('| ------ | ------ | ------ | ------ | ------ | ------ | ------ | :-----: |\n') for item in self.result: - print(f'**** item: {item.issue}') + print(f'**** item: {item.issue_package.issue.number}') try: item_status = Common.output_md(item) file_out.write(item_status) From 373c12b81308a0039b0ce1dc96e24bee1d241aec Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Mon, 20 Jun 2022 17:16:22 +0800 Subject: [PATCH 063/103] update assignee_token and auto-close --- scripts/release_helper/common.py | 21 ++++++++++++--------- scripts/release_helper/go.py | 11 ++++------- scripts/release_helper/java.py | 15 ++++----------- scripts/release_helper/js.py | 11 ++++------- scripts/release_helper/python.py | 9 +++------ 5 files changed, 27 insertions(+), 40 deletions(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index 480ddcdd7128..82e3edf5fa11 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -19,7 +19,8 @@ _LANGUAGE_OWNER = {'msyyc'} # 'github assignee': 'token' -_ASSIGNEE_TOKEN = {'msyyc': os.getenv('AZURESDK_BOT_TOKEN')} +_BOT_NAME = 'azure-sdk' +_ASSIGNEE_TOKEN = os.getenv('AZURESDK_BOT_TOKEN') _SWAGGER_URL = 'https://github.com/Azure/azure-rest-api-specs/blob/main/specification' _SWAGGER_PULL = 'https://github.com/Azure/azure-rest-api-specs/pull' @@ -62,6 +63,7 @@ def __init__(self, issue_package: IssuePackage, request_repo_dict: Dict[str, Rep self.package_name = '' self.target_date = '' self.date_from_target = 0 + self.is_open = True def get_issue_body(self) -> List[str]: return [i for i in self.issue_package.issue.body.split("\n") if i] @@ -293,10 +295,11 @@ class Common: file_out_name = '' # file that storages issue status """ - def __init__(self, issues_package: List[IssuePackage], assignee_token: Dict[str, str], language_owner: Set[str]): + def __init__(self, issues_package: List[IssuePackage], language_owner: Set[str], assignee_token=_ASSIGNEE_TOKEN): self.issues_package = issues_package - self.assignee_candidates = set(assignee_token.keys()) self.language_owner = language_owner + language_owner.discard(_BOT_NAME) + self.assignee_candidates = language_owner # arguments add to language.md self.file_out_name = 'common.md' self.target_release_date = '' @@ -306,18 +309,18 @@ def __init__(self, issues_package: List[IssuePackage], assignee_token: Dict[str, self.request_repo_dict = {} self.issue_process_function = IssueProcess - for assignee in assignee_token: - self.request_repo_dict[assignee] = Github(assignee_token[assignee]).get_repo(REQUEST_REPO) + for assignee in self.assignee_candidates: + self.request_repo_dict[assignee] = Github(assignee_token).get_repo(REQUEST_REPO) def output(self): with open(self.file_out_name, 'w') as file_out: file_out.write('| issue | author | package | assignee | bot advice | created date of issue | target release date | date from target |\n') file_out.write('| ------ | ------ | ------ | ------ | ------ | ------ | ------ | :-----: |\n') for item in self.result: - print(f'**** item: {item.issue_package.issue.number}') try: - item_status = Common.output_md(item) - file_out.write(item_status) + if item.is_open: + item_status = Common.output_md(item) + file_out.write(item_status) except Exception as e: _LOG.error(f'Error happened during output result of handled issue {item.issue_package.issue.number}: {e}') @@ -354,5 +357,5 @@ def run(self): def common_process(issues: List[IssuePackage]): - instance = Common(issues, _ASSIGNEE_TOKEN, _LANGUAGE_OWNER) + instance = Common(issues, _ASSIGNEE_TOKEN, _LANGUAGE_OWNER) instance.run() diff --git a/scripts/release_helper/go.py b/scripts/release_helper/go.py index eca89c5cd5c3..bbb013b4f230 100644 --- a/scripts/release_helper/go.py +++ b/scripts/release_helper/go.py @@ -3,10 +3,7 @@ import os # assignee dict which will be assigned to handle issues -_GO_OWNER = {'ArcturusZhang', 'Alancere'} - -# 'github assignee': 'token' -_ASSIGNEE_TOKEN_GO = {'Alancere': os.getenv('AZURESDK_BOT_TOKEN')} +_GO_OWNER = {'ArcturusZhang', 'Alancere', 'azure-sdk'} class IssueProcessGo(IssueProcess): @@ -14,11 +11,11 @@ class IssueProcessGo(IssueProcess): class Go(Common): - def __init__(self, issues, assignee_token, language_owner): - super(Go, self).__init__(issues, assignee_token, language_owner) + def __init__(self, issues, language_owner): + super(Go, self).__init__(issues, language_owner) self.file_out_name = 'release_go_status.md' def go_process(issues: List[Any]): - instance = Go(issues, _ASSIGNEE_TOKEN_GO, _GO_OWNER) + instance = Go(issues, _GO_OWNER) instance.run() diff --git a/scripts/release_helper/java.py b/scripts/release_helper/java.py index 65b84f38c601..121620a2fcf4 100644 --- a/scripts/release_helper/java.py +++ b/scripts/release_helper/java.py @@ -4,26 +4,19 @@ import os # assignee dict which will be assigned to handle issues -_JAVA_OWNER = {'weidongxu-microsoft', 'haolingdong-msft', 'XiaofeiCao'} - -# 'github assignee': 'token' -_ASSIGNEE_TOKEN_JAVA = { - 'weidongxu-microsoft': os.getenv('AZURESDK_BOT_TOKEN'), - 'haolingdong-msft': os.getenv('AZURESDK_BOT_TOKEN'), - 'XiaofeiCao': os.getenv('AZURESDK_BOT_TOKEN'), -} +_JAVA_OWNER = {'weidongxu-microsoft', 'haolingdong-msft', 'XiaofeiCao', 'azure-sdk'} class IssueProcessJava(IssueProcess): pass class Java(Common): - def __init__(self, issues, assignee_token, language_owner): - super(Java, self).__init__(issues, assignee_token, language_owner) + def __init__(self, issues, language_owner): + super(Java, self).__init__(issues, language_owner) self.file_out_name = 'release_java_status.md' def java_process(issues: List[Any]): - instance = Java(issues, _ASSIGNEE_TOKEN_JAVA, _JAVA_OWNER) + instance = Java(issues, _JAVA_OWNER) instance.run() diff --git a/scripts/release_helper/js.py b/scripts/release_helper/js.py index 12495205d993..7bcdcdcf460a 100644 --- a/scripts/release_helper/js.py +++ b/scripts/release_helper/js.py @@ -4,10 +4,7 @@ import os # assignee dict which will be assigned to handle issues -_JS_OWNER = {'qiaozha', 'lirenhe', 'MaryGao'} - -# 'github assignee': 'token' -_ASSIGNEE_TOKEN_JS = {'qiaozha': os.getenv('AZURESDK_BOT_TOKEN'), 'MaryGao': os.getenv('AZURESDK_BOT_TOKEN')} +_JS_OWNER = {'qiaozha', 'lirenhe', 'MaryGao', 'azure-sdk'} class IssueProcessJs(IssueProcess): @@ -20,11 +17,11 @@ def auto_assign_policy(self) -> str: class Js(Common): - def __init__(self, issues, assignee_token, language_owner): - super(Js, self).__init__(issues, assignee_token, language_owner) + def __init__(self, issues, language_owner): + super(Js, self).__init__(issues, language_owner) self.file_out_name = 'release_js_status.md' self.issue_process_function = IssueProcessJs def js_process(issues: List[Any]): - instance = Js(issues, _ASSIGNEE_TOKEN_JS, _JS_OWNER) + instance = Js(issues, _JS_OWNER) instance.run() diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index fa27564aac76..1443c785a177 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -9,10 +9,7 @@ _PYTHON_OWNER = {'BigCat20196', 'msyyc', 'azure-sdk'} # 'github assignee': 'token' -_ASSIGNEE_TOKEN_PYTHON = { - 'BigCat20196': os.getenv('PYTHON_BIGCAT_TOKEN'), - 'msyyc': os.getenv('PYTHON_MSYYC_TOKEN'), -} +_ASSIGNEE_TOKEN_PYTHON = os.getenv('AZURESDK_BOT_TOKEN') # record published issues _FILE_OUT = 'published_issues_python.csv' @@ -36,7 +33,6 @@ def get_package_name(self) -> None: contents = str(self.issue_package.rest_repo.get_contents(readme_python_path).decoded_content) pattern_package = re.compile(r'package-name: [\w+-.]+') self.package_name = pattern_package.search(contents).group().split(':')[-1].strip() - print(f'*** package_name: {self.package_name}') def get_edit_content(self) -> None: self.edit_content = f'\n{self.readme_link.replace("/readme.md", "")}\n{self.package_name}' @@ -50,7 +46,8 @@ def auto_close(self) -> None: self.issue_package.issue.create_comment(body=comment) self.issue_package.issue.edit(state='closed') self.issue_package.issue.add_to_labels('auto-closed') - self.log("has been closed!") + self.is_open = False + self.log(f"{self.issue_package.issue.number} has been closed!") record_release(self.package_name, self.issue_package.issue, _FILE_OUT) def run(self) -> None: From 7a32e05262e449c12061486d167d6bd0aa7ce6ef Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Mon, 20 Jun 2022 17:35:25 +0800 Subject: [PATCH 064/103] fix --- scripts/release_helper/common.py | 2 +- scripts/release_helper/python.py | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index 82e3edf5fa11..e28e402d8396 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -357,5 +357,5 @@ def run(self): def common_process(issues: List[IssuePackage]): - instance = Common(issues, _ASSIGNEE_TOKEN, _LANGUAGE_OWNER) + instance = Common(issues, _LANGUAGE_OWNER) instance.run() diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index 1443c785a177..131c337a2485 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -8,8 +8,6 @@ # assignee dict which will be assigned to handle issues _PYTHON_OWNER = {'BigCat20196', 'msyyc', 'azure-sdk'} -# 'github assignee': 'token' -_ASSIGNEE_TOKEN_PYTHON = os.getenv('AZURESDK_BOT_TOKEN') # record published issues _FILE_OUT = 'published_issues_python.csv' @@ -56,12 +54,12 @@ def run(self) -> None: self.auto_close() class Python(Common): - def __init__(self, issues, assignee_token, language_owner): - super(Python, self).__init__(issues, assignee_token, language_owner) + def __init__(self, issues, language_owner): + super(Python, self).__init__(issues, language_owner) self.file_out_name = 'release_python_status.md' self.issue_process_function = IssueProcessPython def python_process(issues: List[Any]): - instance = Python(issues, _ASSIGNEE_TOKEN_PYTHON, _PYTHON_OWNER) + instance = Python(issues, _PYTHON_OWNER) instance.run() From 4cacd5fc60e1f392cd6a89aa59bb6bd399b41afc Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Tue, 21 Jun 2022 11:14:56 +0800 Subject: [PATCH 065/103] debug --- scripts/release_helper/common.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index e28e402d8396..c194012a36b7 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -64,6 +64,7 @@ def __init__(self, issue_package: IssuePackage, request_repo_dict: Dict[str, Rep self.target_date = '' self.date_from_target = 0 self.is_open = True + print(f'**** issue {self.issue_package.issue.number}, language owner: {self.language_owner}, assignee_candidates: {self.assignee_candidates}') def get_issue_body(self) -> List[str]: return [i for i in self.issue_package.issue.body.split("\n") if i] From 081e2ad58635b8da37cdb3ff05cf03020db80d57 Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Tue, 21 Jun 2022 13:24:16 +0800 Subject: [PATCH 066/103] fix --- scripts/release_helper/common.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index c194012a36b7..37e6fbfaec37 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -64,7 +64,6 @@ def __init__(self, issue_package: IssuePackage, request_repo_dict: Dict[str, Rep self.target_date = '' self.date_from_target = 0 self.is_open = True - print(f'**** issue {self.issue_package.issue.number}, language owner: {self.language_owner}, assignee_candidates: {self.assignee_candidates}') def get_issue_body(self) -> List[str]: return [i for i in self.issue_package.issue.body.split("\n") if i] @@ -298,7 +297,7 @@ class Common: def __init__(self, issues_package: List[IssuePackage], language_owner: Set[str], assignee_token=_ASSIGNEE_TOKEN): self.issues_package = issues_package - self.language_owner = language_owner + self.language_owner = language_owner.copy() language_owner.discard(_BOT_NAME) self.assignee_candidates = language_owner # arguments add to language.md From b07eb2eb9e2381bb783a58614aab406d73062253 Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Tue, 21 Jun 2022 16:43:19 +0800 Subject: [PATCH 067/103] auto-reply --- scripts/release_helper/python.py | 70 +++++++++++++++++++++++++++----- scripts/release_helper/utils.py | 66 ++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+), 11 deletions(-) diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index 131c337a2485..cbd11a3c010c 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -1,20 +1,29 @@ -import os import re -from typing import Any, List +from typing import Any, List, Dict, Set -from common import IssueProcess, Common, get_origin_link_and_tag -from utils import AUTO_CLOSE_LABEL, get_last_released_date, record_release - -# assignee dict which will be assigned to handle issues -_PYTHON_OWNER = {'BigCat20196', 'msyyc', 'azure-sdk'} +from github.Repository import Repository +from common import IssueProcess, Common, get_origin_link_and_tag, IssuePackage +from utils import AUTO_CLOSE_LABEL, get_last_released_date, record_release, get_python_release_pipeline, run_pipeline +# assignee dict which will be assigned to handle issues +_PYTHON_OWNER = {'BigCat20196', 'msyyc', 'Wzb123456789', 'azure-sdk'} +# labels +_CONFIGURED = 'Configured' +_AUTO_ASK_FOR_CHECK = 'auto-ask-check' # record published issues _FILE_OUT = 'published_issues_python.csv' class IssueProcessPython(IssueProcess): + def __init__(self, issue_package: IssuePackage, request_repo_dict: Dict[str, Repository], + assignee_candidates: Set[str], language_owner: Set[str]): + IssueProcess.__init__(issue_package, request_repo_dict, assignee_candidates, language_owner) + self.output_folder = '' + self.is_multiapi = False + self.pattern_resource_manager = re.compile(r'/specification/([\w-]+/)+resource-manager') + def init_readme_link(self) -> None: issue_body_list = self.get_issue_body() @@ -24,17 +33,54 @@ def init_readme_link(self) -> None: # get readme_link self.get_readme_link(origin_link) - def get_package_name(self) -> None: + def get_package_and_output(self) -> None: self.init_readme_link() - pattern_resource_manager = re.compile(r'/specification/([\w-]+/)+resource-manager') - readme_python_path = pattern_resource_manager.search(self.readme_link).group() + '/readme.python.md' + readme_python_path = self.pattern_resource_manager.search(self.readme_link).group() + '/readme.python.md' contents = str(self.issue_package.rest_repo.get_contents(readme_python_path).decoded_content) pattern_package = re.compile(r'package-name: [\w+-.]+') + pattern_output = re.compile(r'\$\(python-sdks-folder\)/(.*?)/azure-') self.package_name = pattern_package.search(contents).group().split(':')[-1].strip() + self.output_folder = pattern_output.search(contents).group().split('/')[1] + self.is_multiapi = ('MultiAPI' in self.issue_package.issue.labels) or ('multi-api' in contents) def get_edit_content(self) -> None: self.edit_content = f'\n{self.readme_link.replace("/readme.md", "")}\n{self.package_name}' + @property + def readme_comparison(self) -> bool: + # to see whether need change readme + if 'package-' not in self.target_readme_tag: + return True + if _CONFIGURED in self.issue_package.issue.labels: + return False + readme_path = self.pattern_resource_manager.search(self.readme_link).group() + contents = str(self.issue_package.rest_repo.get_contents(readme_path).decoded_content) + pattern_tag = re.compile(r'tag: package-[\w+-.]+') + package_tags = pattern_tag.findall(contents) + whether_same_tag = self.target_readme_tag in package_tags + whether_change_readme = not whether_same_tag or self.is_multiapi + return whether_change_readme + + def auto_reply(self) -> None: + if self.issue_package.issue.comments == 0 or _CONFIGURED in self.issue_package.labels_name: + issue_number = self.issue_package.issue.number + if not self.readme_comparison: + issue_link = self.issue_package.issue.html_url + release_pipeline_url = get_python_release_pipeline(self.output_folder) + res_run = run_pipeline(issue_link=issue_link, + pipeline_url=release_pipeline_url, + spec_readme=self.readme_link + ) + if res_run: + self.log(f'{issue_number} run pipeline successfully') + if _CONFIGURED in self.issue_package.labels_name: + self.issue_package.issue.remove_from_labels(_CONFIGURED) + else: + self.log(f'{issue_number} run pipeline fail') + self.issue_package.issue.add_to_labels(_AUTO_ASK_FOR_CHECK) + else: + self.log(f'issue {issue_number} need config readme') + def auto_close(self) -> None: if AUTO_CLOSE_LABEL in self.issue_package.labels_name: return @@ -49,10 +95,12 @@ def auto_close(self) -> None: record_release(self.package_name, self.issue_package.issue, _FILE_OUT) def run(self) -> None: - self.get_package_name() + self.get_package_and_output() super().run() + self.auto_reply() self.auto_close() + class Python(Common): def __init__(self, issues, language_owner): super(Python, self).__init__(issues, language_owner) diff --git a/scripts/release_helper/utils.py b/scripts/release_helper/utils.py index 17ce9bc7285e..ebcd1db62cf0 100644 --- a/scripts/release_helper/utils.py +++ b/scripts/release_helper/utils.py @@ -1,11 +1,16 @@ import datetime import logging +import os +import re from typing import List, Any from bs4 import BeautifulSoup from github.Issue import Issue from github.Repository import Repository import requests +from azure.devops.v6_0.pipelines.pipelines_client import PipelinesClient +from azure.devops.v6_0.pipelines import models +from msrest.authentication import BasicAuthentication REQUEST_REPO = 'Azure/sdk-release-request' REST_REPO = 'Azure/azure-rest-api-specs' @@ -49,6 +54,67 @@ def get_last_released_date(package_name: str) -> (str, str): return last_version, last_version_date +# get python release pipeline link from web +def get_python_release_pipeline(output_folder): + pipeline_client = PipelinesClient(base_url='https://dev.azure.com/azure-sdk', + creds=BasicAuthentication(os.getenv('PIPELINE_TOKEN'), '')) + pipelines = pipeline_client.list_pipelines(project='internal') + for pipeline in pipelines: + if re.findall('^python - \w*$', pipeline.name): + key = pipeline.name.replace('python - ', '') + if key == output_folder: + pipeline_url = 'https://dev.azure.com/azure-sdk/internal/_build?definitionId={}'.format(pipeline.id) + return pipeline_url + else: + _LOG.info('Cannot find definitionId, Do not display pipeline_url') + return '' + + +# Run sdk-auto-release(main) to generate SDK +def run_pipeline(issue_link, pipeline_url, spec_readme): + paramaters = { + "stages_to_skip": [], + "resources": { + "repositories": { + "self": { + "refName": "refs/heads/main" + } + } + }, + "variables": { + "BASE_BRANCH": { + "value": "", + "isSecret": False + }, + "ISSUE_LINK": { + "value": issue_link, + "isSecret": False + }, + "PIPELINE_LINK": { + "value": pipeline_url, + "isSecret": False + }, + "SPEC_README": { + "value": spec_readme, + "isSecret": False + } + } + } + # Fill in with your personal access token and org URL + personal_access_token = os.getenv('PIPELINE_TOKEN') + organization_url = 'https://dev.azure.com/azure-sdk' + + # Create a connection to the org + credentials = BasicAuthentication('', personal_access_token) + run_parameters = models.RunPipelineParameters(**paramaters) + client = PipelinesClient(base_url=organization_url, creds=credentials) + result = client.run_pipeline(project='internal', pipeline_id=2500, run_parameters=run_parameters) + if result.state == 'inProgress': + return True + else: + return False + + def record_release(package_name: str, issue_info: Any, file: str) -> None: created_at = issue_info.created_at.strftime('%Y-%m-%d') closed_at = issue_info.closed_at.strftime('%Y-%m-%d') From f8e47192437b4b3504ff3c4df978e176e8f2c346 Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Tue, 21 Jun 2022 16:55:49 +0800 Subject: [PATCH 068/103] fix --- scripts/release_helper/python.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index cbd11a3c010c..36199f48a41f 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -19,7 +19,7 @@ class IssueProcessPython(IssueProcess): def __init__(self, issue_package: IssuePackage, request_repo_dict: Dict[str, Repository], assignee_candidates: Set[str], language_owner: Set[str]): - IssueProcess.__init__(issue_package, request_repo_dict, assignee_candidates, language_owner) + IssueProcess.__init__(self, issue_package, request_repo_dict, assignee_candidates, language_owner) self.output_folder = '' self.is_multiapi = False self.pattern_resource_manager = re.compile(r'/specification/([\w-]+/)+resource-manager') From aef194746db9bb4ffaa36012b1044edb68f4671c Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Tue, 21 Jun 2022 17:03:23 +0800 Subject: [PATCH 069/103] debug --- scripts/release_helper/python.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index 36199f48a41f..27761a2c9019 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -79,6 +79,7 @@ def auto_reply(self) -> None: self.log(f'{issue_number} run pipeline fail') self.issue_package.issue.add_to_labels(_AUTO_ASK_FOR_CHECK) else: + print(f'*** issue {issue_number} need config readme') self.log(f'issue {issue_number} need config readme') def auto_close(self) -> None: From b0b63ef214aca8fec8225f811d23db85b9406c43 Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Tue, 21 Jun 2022 17:20:38 +0800 Subject: [PATCH 070/103] fix --- scripts/release_helper/python.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index 27761a2c9019..4fc69398c6f8 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -53,7 +53,7 @@ def readme_comparison(self) -> bool: return True if _CONFIGURED in self.issue_package.issue.labels: return False - readme_path = self.pattern_resource_manager.search(self.readme_link).group() + readme_path = self.pattern_resource_manager.search(self.readme_link).group() + '/readme.md' contents = str(self.issue_package.rest_repo.get_contents(readme_path).decoded_content) pattern_tag = re.compile(r'tag: package-[\w+-.]+') package_tags = pattern_tag.findall(contents) From d1d4799d66a6c80b522692c568afb0c374ee0aef Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Wed, 22 Jun 2022 11:00:35 +0800 Subject: [PATCH 071/103] debug --- scripts/release_helper/python.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index 4fc69398c6f8..87021ae8e621 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -49,6 +49,7 @@ def get_edit_content(self) -> None: @property def readme_comparison(self) -> bool: # to see whether need change readme + self.log(f'**** target_readme_tag: {self.target_readme_tag}') if 'package-' not in self.target_readme_tag: return True if _CONFIGURED in self.issue_package.issue.labels: From d74825f6503ee2c85b4b0837b8463208877105dc Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Wed, 22 Jun 2022 11:06:32 +0800 Subject: [PATCH 072/103] debug --- scripts/release_helper/python.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index 87021ae8e621..693b0afe81e4 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -60,6 +60,7 @@ def readme_comparison(self) -> bool: package_tags = pattern_tag.findall(contents) whether_same_tag = self.target_readme_tag in package_tags whether_change_readme = not whether_same_tag or self.is_multiapi + self.log(f'**** whether_change_readme: {whether_change_readme}') return whether_change_readme def auto_reply(self) -> None: From a8f43084b74a0220e0db58ca34ee178bc39476b1 Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Wed, 22 Jun 2022 11:13:14 +0800 Subject: [PATCH 073/103] fix --- scripts/release_helper/python.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index 693b0afe81e4..5728d689b048 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -41,7 +41,7 @@ def get_package_and_output(self) -> None: pattern_output = re.compile(r'\$\(python-sdks-folder\)/(.*?)/azure-') self.package_name = pattern_package.search(contents).group().split(':')[-1].strip() self.output_folder = pattern_output.search(contents).group().split('/')[1] - self.is_multiapi = ('MultiAPI' in self.issue_package.issue.labels) or ('multi-api' in contents) + self.is_multiapi = ('MultiAPI' in self.issue_package.labels_name) or ('multi-api' in contents) def get_edit_content(self) -> None: self.edit_content = f'\n{self.readme_link.replace("/readme.md", "")}\n{self.package_name}' @@ -49,10 +49,10 @@ def get_edit_content(self) -> None: @property def readme_comparison(self) -> bool: # to see whether need change readme - self.log(f'**** target_readme_tag: {self.target_readme_tag}') + self.log(f'**** issue_package.labels_name: {self.issue_package.labels_name}') if 'package-' not in self.target_readme_tag: return True - if _CONFIGURED in self.issue_package.issue.labels: + if _CONFIGURED in self.issue_package.labels_name: return False readme_path = self.pattern_resource_manager.search(self.readme_link).group() + '/readme.md' contents = str(self.issue_package.rest_repo.get_contents(readme_path).decoded_content) @@ -60,7 +60,6 @@ def readme_comparison(self) -> bool: package_tags = pattern_tag.findall(contents) whether_same_tag = self.target_readme_tag in package_tags whether_change_readme = not whether_same_tag or self.is_multiapi - self.log(f'**** whether_change_readme: {whether_change_readme}') return whether_change_readme def auto_reply(self) -> None: From 87f2ebef2404586c102d4d98677483447b637ae3 Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Wed, 22 Jun 2022 11:24:16 +0800 Subject: [PATCH 074/103] debugg --- scripts/release_helper/python.py | 2 +- scripts/release_helper/utils.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index 5728d689b048..f1c5671c9cbd 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -70,7 +70,7 @@ def auto_reply(self) -> None: release_pipeline_url = get_python_release_pipeline(self.output_folder) res_run = run_pipeline(issue_link=issue_link, pipeline_url=release_pipeline_url, - spec_readme=self.readme_link + spec_readme=self.readme_link + '/readme.md' ) if res_run: self.log(f'{issue_number} run pipeline successfully') diff --git a/scripts/release_helper/utils.py b/scripts/release_helper/utils.py index ebcd1db62cf0..5dd03324d223 100644 --- a/scripts/release_helper/utils.py +++ b/scripts/release_helper/utils.py @@ -59,11 +59,13 @@ def get_python_release_pipeline(output_folder): pipeline_client = PipelinesClient(base_url='https://dev.azure.com/azure-sdk', creds=BasicAuthentication(os.getenv('PIPELINE_TOKEN'), '')) pipelines = pipeline_client.list_pipelines(project='internal') + _LOG.info('**** list pipelines successfully') for pipeline in pipelines: if re.findall('^python - \w*$', pipeline.name): key = pipeline.name.replace('python - ', '') if key == output_folder: pipeline_url = 'https://dev.azure.com/azure-sdk/internal/_build?definitionId={}'.format(pipeline.id) + _LOG.info(f'**** find pepeline.id: {pipeline.id} successfully') return pipeline_url else: _LOG.info('Cannot find definitionId, Do not display pipeline_url') @@ -100,6 +102,7 @@ def run_pipeline(issue_link, pipeline_url, spec_readme): } } } + _LOG.info(f'**** parameters: {paramaters}') # Fill in with your personal access token and org URL personal_access_token = os.getenv('PIPELINE_TOKEN') organization_url = 'https://dev.azure.com/azure-sdk' From 4fce70c4d0f047e2623d9b0ca67ac98796a1bc5d Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Thu, 23 Jun 2022 10:17:25 +0800 Subject: [PATCH 075/103] update yaml --- scripts/release_helper/release_helper.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/release_helper/release_helper.yml b/scripts/release_helper/release_helper.yml index 1eaac9e3c486..9d231db952f9 100644 --- a/scripts/release_helper/release_helper.yml +++ b/scripts/release_helper/release_helper.yml @@ -54,10 +54,8 @@ jobs: # import env variable export TOKEN=$(Yuchao-GitToken) - export PYTHON_BIGCAT_TOKEN=$(Jiefeng-GitToken) - export PYTHON_ZED_TOKEN=$(Zed-GitToken) - export PYTHON_MSYYC_TOKEN=$(Yuchao-GitToken) export AZURESDK_BOT_TOKEN=$(azuresdk-github-pat) + export PIPELINE_TOKEN=$(PIPELINE-TOKEN) export LANGUAGE=$(RUN_LANGUAGE) From b01e55db6f447c6a4b6e66cb4365ef972296cf8b Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Thu, 23 Jun 2022 17:15:47 +0800 Subject: [PATCH 076/103] change to add_label --- scripts/release_helper/python.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index f1c5671c9cbd..e864852adf2a 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -49,7 +49,6 @@ def get_edit_content(self) -> None: @property def readme_comparison(self) -> bool: # to see whether need change readme - self.log(f'**** issue_package.labels_name: {self.issue_package.labels_name}') if 'package-' not in self.target_readme_tag: return True if _CONFIGURED in self.issue_package.labels_name: @@ -78,9 +77,8 @@ def auto_reply(self) -> None: self.issue_package.issue.remove_from_labels(_CONFIGURED) else: self.log(f'{issue_number} run pipeline fail') - self.issue_package.issue.add_to_labels(_AUTO_ASK_FOR_CHECK) + self.add_label(_AUTO_ASK_FOR_CHECK) else: - print(f'*** issue {issue_number} need config readme') self.log(f'issue {issue_number} need config readme') def auto_close(self) -> None: @@ -91,7 +89,7 @@ def auto_close(self) -> None: comment = f'Hi @{self.owner}, pypi link: https://pypi.org/project/{self.package_name}/{last_version}/' self.issue_package.issue.create_comment(body=comment) self.issue_package.issue.edit(state='closed') - self.issue_package.issue.add_to_labels('auto-closed') + self.add_label('auto-closed') self.is_open = False self.log(f"{self.issue_package.issue.number} has been closed!") record_release(self.package_name, self.issue_package.issue, _FILE_OUT) From 9d18dfeb15620fb7141a97879de92900f52f9649 Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Thu, 23 Jun 2022 17:16:41 +0800 Subject: [PATCH 077/103] format --- scripts/release_helper/python.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index e864852adf2a..8d11123557c3 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -89,7 +89,7 @@ def auto_close(self) -> None: comment = f'Hi @{self.owner}, pypi link: https://pypi.org/project/{self.package_name}/{last_version}/' self.issue_package.issue.create_comment(body=comment) self.issue_package.issue.edit(state='closed') - self.add_label('auto-closed') + self.add_label(AUTO_CLOSE_LABEL) self.is_open = False self.log(f"{self.issue_package.issue.number} has been closed!") record_release(self.package_name, self.issue_package.issue, _FILE_OUT) From 2f28e57df49e5f3d27f31786ea9de502611fe3ac Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Fri, 24 Jun 2022 13:46:25 +0800 Subject: [PATCH 078/103] add attention policy and remind policy --- scripts/release_helper/python.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index 8d11123557c3..298c3c00c7b2 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -1,3 +1,4 @@ +from datetime import datetime import re from typing import Any, List, Dict, Set @@ -11,6 +12,8 @@ # labels _CONFIGURED = 'Configured' _AUTO_ASK_FOR_CHECK = 'auto-ask-check' +_BRANCH_ATTENTION = 'base-branch-attention' +_7_DAY_ATTENTION = '7days attention' # record published issues _FILE_OUT = 'published_issues_python.csv' @@ -23,6 +26,13 @@ def __init__(self, issue_package: IssuePackage, request_repo_dict: Dict[str, Rep self.output_folder = '' self.is_multiapi = False self.pattern_resource_manager = re.compile(r'/specification/([\w-]+/)+resource-manager') + self.delay_time = self.get_delay_time() + + def get_delay_time(self): + q = [comment.updated_at + for comment in self.issue_package.issue.get_comments() if comment.user.login not in _PYTHON_OWNER] + q.sort() + return (datetime.now() - (self.created_time if not q else q[-1])).days def init_readme_link(self) -> None: issue_body_list = self.get_issue_body() @@ -81,6 +91,27 @@ def auto_reply(self) -> None: else: self.log(f'issue {issue_number} need config readme') + def attention_policy(self): + if _BRANCH_ATTENTION in self.issue_package.labels_name: + self.bot_advice.append('new version is 0.0.0, please check base branch!') + + def remind_policy(self): + if self.delay_time >= 15 and _7_DAY_ATTENTION in self.issue_package.labels_name and self.date_from_target < 0: + self.comment( + f'hi @{self.owner}, the issue is closed since there is no reply for a long time. ' + 'Please reopen it if necessary or create new one.') + self.issue_package.issue.edit(state='close') + elif self.delay_time >= 7 and _7_DAY_ATTENTION not in self.issue_package.labels_name and self.date_from_target < 7: + self.comment( + f'hi @{self.owner}, this release-request has been delayed more than 7 days,' + ' please deal with it ASAP. We will close the issue if there is still no response after 7 days!') + self.add_label(_7_DAY_ATTENTION) + + def auto_bot_advice(self): + super().auto_bot_advice() + self.attention_policy() + self.remind_policy() + def auto_close(self) -> None: if AUTO_CLOSE_LABEL in self.issue_package.labels_name: return From 85330b5718487405ccc743bbc7986dc79b0006d7 Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Mon, 27 Jun 2022 13:48:10 +0800 Subject: [PATCH 079/103] add duplicated policy --- scripts/release_helper/common.py | 17 +++++++++++------ scripts/release_helper/python.py | 12 ++++++++++++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index 37e6fbfaec37..97d6c48f5f4a 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -312,6 +312,9 @@ def __init__(self, issues_package: List[IssuePackage], language_owner: Set[str], for assignee in self.assignee_candidates: self.request_repo_dict[assignee] = Github(assignee_token).get_repo(REQUEST_REPO) + def log_error(self, message: str) -> None: + _LOG.error(message) + def output(self): with open(self.file_out_name, 'w') as file_out: file_out.write('| issue | author | package | assignee | bot advice | created date of issue | target release date | date from target |\n') @@ -322,7 +325,7 @@ def output(self): item_status = Common.output_md(item) file_out.write(item_status) except Exception as e: - _LOG.error(f'Error happened during output result of handled issue {item.issue_package.issue.number}: {e}') + self.log_error(f'Error happened during output result of handled issue {item.issue_package.issue.number}: {e}') @staticmethod def output_md(item: IssueProcess): @@ -344,17 +347,19 @@ def output_md(item: IssueProcess): item.print_date_from_target_date() ) - def run(self): - items = [] + def get_result(self): for item in self.issues_package: - issue = self.issue_process_function(item, self.request_repo_dict, self.assignee_candidates, self.language_owner) + issue = self.issue_process_function(item, self.request_repo_dict, self.assignee_candidates, + self.language_owner) try: issue.run() self.result.append(issue) except Exception as e: - _LOG.error(f'Error happened during handling issue {item.issue.number}: {e}') - self.output() + self.log_error(f'Error happened during handling issue {item.issue.number}: {e}') + def run(self): + self.get_result() + self.output() def common_process(issues: List[IssuePackage]): instance = Common(issues, _LANGUAGE_OWNER) diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index 298c3c00c7b2..ff0727e15711 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -1,4 +1,5 @@ from datetime import datetime +from collections import Counter import re from typing import Any, List, Dict, Set @@ -138,6 +139,17 @@ def __init__(self, issues, language_owner): self.file_out_name = 'release_python_status.md' self.issue_process_function = IssueProcessPython + def duplicated_policy(self): + count = Counter([item.package_name for item in self.result]) + for item in self.result: + if count[item.package_name] > 1: + item.bot_advice.insert(0, 'duplicated issue
') + + def run(self): + self.get_result() + self.duplicated_policy() + self.output() + def python_process(issues: List[Any]): instance = Python(issues, _PYTHON_OWNER) From 65e5deb7f954f8b692145c08cd079569ee95c779 Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Mon, 27 Jun 2022 14:10:00 +0800 Subject: [PATCH 080/103] delete uesless code --- scripts/release_helper/utils.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/release_helper/utils.py b/scripts/release_helper/utils.py index 5dd03324d223..ebcd1db62cf0 100644 --- a/scripts/release_helper/utils.py +++ b/scripts/release_helper/utils.py @@ -59,13 +59,11 @@ def get_python_release_pipeline(output_folder): pipeline_client = PipelinesClient(base_url='https://dev.azure.com/azure-sdk', creds=BasicAuthentication(os.getenv('PIPELINE_TOKEN'), '')) pipelines = pipeline_client.list_pipelines(project='internal') - _LOG.info('**** list pipelines successfully') for pipeline in pipelines: if re.findall('^python - \w*$', pipeline.name): key = pipeline.name.replace('python - ', '') if key == output_folder: pipeline_url = 'https://dev.azure.com/azure-sdk/internal/_build?definitionId={}'.format(pipeline.id) - _LOG.info(f'**** find pepeline.id: {pipeline.id} successfully') return pipeline_url else: _LOG.info('Cannot find definitionId, Do not display pipeline_url') @@ -102,7 +100,6 @@ def run_pipeline(issue_link, pipeline_url, spec_readme): } } } - _LOG.info(f'**** parameters: {paramaters}') # Fill in with your personal access token and org URL personal_access_token = os.getenv('PIPELINE_TOKEN') organization_url = 'https://dev.azure.com/azure-sdk' From 788a451a4a572514c7df17d5ecc434e3d6ab5b6f Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Tue, 28 Jun 2022 10:04:15 +0800 Subject: [PATCH 081/103] Update scripts/release_helper/utils.py Co-authored-by: Yuchao Yan --- scripts/release_helper/utils.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/release_helper/utils.py b/scripts/release_helper/utils.py index ebcd1db62cf0..9da67f75c7e2 100644 --- a/scripts/release_helper/utils.py +++ b/scripts/release_helper/utils.py @@ -109,10 +109,7 @@ def run_pipeline(issue_link, pipeline_url, spec_readme): run_parameters = models.RunPipelineParameters(**paramaters) client = PipelinesClient(base_url=organization_url, creds=credentials) result = client.run_pipeline(project='internal', pipeline_id=2500, run_parameters=run_parameters) - if result.state == 'inProgress': - return True - else: - return False + return result.state == 'inProgress': def record_release(package_name: str, issue_info: Any, file: str) -> None: From d1fc2334a26ac2d87f0f2abc827ef54dee61c229 Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Tue, 28 Jun 2022 10:37:23 +0800 Subject: [PATCH 082/103] update --- scripts/release_helper/common.py | 12 ++++++------ scripts/release_helper/go.py | 7 ++++--- scripts/release_helper/python.py | 6 +++--- scripts/release_helper/release_helper.yml | 1 - scripts/release_helper/requirement.txt | 11 +++++------ scripts/release_helper/utils.py | 2 +- 6 files changed, 19 insertions(+), 20 deletions(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index 97d6c48f5f4a..6000a52e9016 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -295,11 +295,11 @@ class Common: file_out_name = '' # file that storages issue status """ - def __init__(self, issues_package: List[IssuePackage], language_owner: Set[str], assignee_token=_ASSIGNEE_TOKEN): + def __init__(self, issues_package: List[IssuePackage], language_owner: Set[str], + skipped_assignees: Set[str]={_BOT_NAME}, assignee_token=_ASSIGNEE_TOKEN): self.issues_package = issues_package - self.language_owner = language_owner.copy() - language_owner.discard(_BOT_NAME) - self.assignee_candidates = language_owner + self.language_owner = language_owner + self.assignee_candidates = language_owner - skipped_assignees # arguments add to language.md self.file_out_name = 'common.md' self.target_release_date = '' @@ -347,7 +347,7 @@ def output_md(item: IssueProcess): item.print_date_from_target_date() ) - def get_result(self): + def proc_issue(self): for item in self.issues_package: issue = self.issue_process_function(item, self.request_repo_dict, self.assignee_candidates, self.language_owner) @@ -358,7 +358,7 @@ def get_result(self): self.log_error(f'Error happened during handling issue {item.issue.number}: {e}') def run(self): - self.get_result() + self.proc_issue() self.output() def common_process(issues: List[IssuePackage]): diff --git a/scripts/release_helper/go.py b/scripts/release_helper/go.py index bbb013b4f230..2b242cbd1c63 100644 --- a/scripts/release_helper/go.py +++ b/scripts/release_helper/go.py @@ -4,6 +4,7 @@ # assignee dict which will be assigned to handle issues _GO_OWNER = {'ArcturusZhang', 'Alancere', 'azure-sdk'} +_SKIPPED_ASSIGNEES = {'ArcturusZhang', 'azure-sdk'} class IssueProcessGo(IssueProcess): @@ -11,11 +12,11 @@ class IssueProcessGo(IssueProcess): class Go(Common): - def __init__(self, issues, language_owner): - super(Go, self).__init__(issues, language_owner) + def __init__(self, issues, language_owner, skipped_assignees): + super(Go, self).__init__(issues, language_owner, skipped_assignees) self.file_out_name = 'release_go_status.md' def go_process(issues: List[Any]): - instance = Go(issues, _GO_OWNER) + instance = Go(issues, _GO_OWNER, _SKIPPED_ASSIGNEES) instance.run() diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index ff0727e15711..dd296da5e17c 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -140,13 +140,13 @@ def __init__(self, issues, language_owner): self.issue_process_function = IssueProcessPython def duplicated_policy(self): - count = Counter([item.package_name for item in self.result]) + counter = Counter([item.package_name for item in self.result]) for item in self.result: - if count[item.package_name] > 1: + if counter[item.package_name] > 1: item.bot_advice.insert(0, 'duplicated issue
') def run(self): - self.get_result() + self.proc_issue() self.duplicated_policy() self.output() diff --git a/scripts/release_helper/release_helper.yml b/scripts/release_helper/release_helper.yml index 9d231db952f9..6f4762a0023a 100644 --- a/scripts/release_helper/release_helper.yml +++ b/scripts/release_helper/release_helper.yml @@ -53,7 +53,6 @@ jobs: git clone ${FILE_REPO:0:8}$(USR_NAME):$(Yuchao-GitToken)@${FILE_REPO:8} $(pwd)/file-storage # import env variable - export TOKEN=$(Yuchao-GitToken) export AZURESDK_BOT_TOKEN=$(azuresdk-github-pat) export PIPELINE_TOKEN=$(PIPELINE-TOKEN) export LANGUAGE=$(RUN_LANGUAGE) diff --git a/scripts/release_helper/requirement.txt b/scripts/release_helper/requirement.txt index 95f800db46db..db29417ad6ee 100644 --- a/scripts/release_helper/requirement.txt +++ b/scripts/release_helper/requirement.txt @@ -1,6 +1,5 @@ -PyGithub -datetime -requests -bs4 -azure-devops -msrest +PyGithub==1.55 +requests==2.28.0 +beautifulsoup4==4.11.1 +azure-devops==6.0.0b4 +msrest==0.7.1 diff --git a/scripts/release_helper/utils.py b/scripts/release_helper/utils.py index 9da67f75c7e2..a336a55d7b30 100644 --- a/scripts/release_helper/utils.py +++ b/scripts/release_helper/utils.py @@ -109,7 +109,7 @@ def run_pipeline(issue_link, pipeline_url, spec_readme): run_parameters = models.RunPipelineParameters(**paramaters) client = PipelinesClient(base_url=organization_url, creds=credentials) result = client.run_pipeline(project='internal', pipeline_id=2500, run_parameters=run_parameters) - return result.state == 'inProgress': + return result.state == 'inProgress' def record_release(package_name: str, issue_info: Any, file: str) -> None: From 7e2ddb5c32ff22c67d41ec04b11491246770ddbe Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Tue, 28 Jun 2022 10:48:44 +0800 Subject: [PATCH 083/103] fix dependence version --- scripts/release_helper/requirement.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release_helper/requirement.txt b/scripts/release_helper/requirement.txt index db29417ad6ee..496b2cd3ba34 100644 --- a/scripts/release_helper/requirement.txt +++ b/scripts/release_helper/requirement.txt @@ -2,4 +2,4 @@ PyGithub==1.55 requests==2.28.0 beautifulsoup4==4.11.1 azure-devops==6.0.0b4 -msrest==0.7.1 +msrest==0.7.0 From 388b37341b6ff6de9ef088c37bbd0057be91683d Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Tue, 28 Jun 2022 10:53:05 +0800 Subject: [PATCH 084/103] fix dependence version --- scripts/release_helper/requirement.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release_helper/requirement.txt b/scripts/release_helper/requirement.txt index 496b2cd3ba34..6e304533109b 100644 --- a/scripts/release_helper/requirement.txt +++ b/scripts/release_helper/requirement.txt @@ -2,4 +2,4 @@ PyGithub==1.55 requests==2.28.0 beautifulsoup4==4.11.1 azure-devops==6.0.0b4 -msrest==0.7.0 +msrest>=0.6.21 From b7eb450f98fbd2b177356813163014c3e0df9613 Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Tue, 28 Jun 2022 10:57:55 +0800 Subject: [PATCH 085/103] fix env --- scripts/release_helper/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release_helper/main.py b/scripts/release_helper/main.py index 2f382a601dac..941fb7f0ade1 100644 --- a/scripts/release_helper/main.py +++ b/scripts/release_helper/main.py @@ -34,7 +34,7 @@ def collect_open_issues() -> List[IssuePackage]: - hub = Github(os.getenv('TOKEN')) + hub = Github(os.getenv('AZURESDK_BOT_TOKEN')) request_repo = hub.get_repo(REQUEST_REPO) mgmt_label = request_repo.get_label('ManagementPlane') open_issues = request_repo.get_issues(state='open', labels=[mgmt_label]) From 2ee48d1d138c73463b3d62110e6839ab85e99f56 Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Tue, 28 Jun 2022 11:10:29 +0800 Subject: [PATCH 086/103] update js assignee --- scripts/release_helper/js.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/release_helper/js.py b/scripts/release_helper/js.py index 7bcdcdcf460a..d3d192225571 100644 --- a/scripts/release_helper/js.py +++ b/scripts/release_helper/js.py @@ -5,6 +5,7 @@ # assignee dict which will be assigned to handle issues _JS_OWNER = {'qiaozha', 'lirenhe', 'MaryGao', 'azure-sdk'} +_SKIPPED_ASSIGNEES = {'lirenhe', 'kazrael2119', 'azure-sdk'} class IssueProcessJs(IssueProcess): @@ -17,11 +18,11 @@ def auto_assign_policy(self) -> str: class Js(Common): - def __init__(self, issues, language_owner): - super(Js, self).__init__(issues, language_owner) + def __init__(self, issues, language_owner, skipped_assignees): + super(Js, self).__init__(issues, language_owner, skipped_assignees) self.file_out_name = 'release_js_status.md' self.issue_process_function = IssueProcessJs def js_process(issues: List[Any]): - instance = Js(issues, _JS_OWNER) + instance = Js(issues, _JS_OWNER, _SKIPPED_ASSIGNEES) instance.run() From 07509ade034b43ac465e31639a5bec83f88a293d Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Tue, 28 Jun 2022 11:17:02 +0800 Subject: [PATCH 087/103] update js assignee --- scripts/release_helper/js.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release_helper/js.py b/scripts/release_helper/js.py index d3d192225571..a21286533c3c 100644 --- a/scripts/release_helper/js.py +++ b/scripts/release_helper/js.py @@ -4,7 +4,7 @@ import os # assignee dict which will be assigned to handle issues -_JS_OWNER = {'qiaozha', 'lirenhe', 'MaryGao', 'azure-sdk'} +_JS_OWNER = {'qiaozha', 'lirenhe', 'MaryGao', 'kazrael2119', 'azure-sdk'} _SKIPPED_ASSIGNEES = {'lirenhe', 'kazrael2119', 'azure-sdk'} From 1d5f58a9ec4881fe4da3708cdda59dafa363d6c7 Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Wed, 29 Jun 2022 09:40:07 +0800 Subject: [PATCH 088/103] fix find pr number bug --- scripts/release_helper/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index 6000a52e9016..20504af80417 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -80,7 +80,7 @@ def comment(self, message: str) -> None: self.issue_package.issue.create_comment(message) def get_readme_from_pr_link(self, link: str) -> str: - pr_number = int(link.replace(f"{_SWAGGER_PULL}/", "").strip('/')) + pr_number = int(link.replace(f"{_SWAGGER_PULL}/", "").split('/')[0]) # Get Readme link pr_info = self.issue_package.rest_repo.get_pull(number=pr_number) From 603e3a761b81175d23ef9f2de8185ddc12965569 Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Wed, 29 Jun 2022 10:15:06 +0800 Subject: [PATCH 089/103] update assignee logic --- scripts/release_helper/common.py | 6 +++--- scripts/release_helper/go.py | 10 +++++----- scripts/release_helper/java.py | 10 +++++----- scripts/release_helper/js.py | 10 +++++----- scripts/release_helper/python.py | 9 +++++---- 5 files changed, 23 insertions(+), 22 deletions(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index 20504af80417..7a960f5df2a9 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -296,10 +296,10 @@ class Common: """ def __init__(self, issues_package: List[IssuePackage], language_owner: Set[str], - skipped_assignees: Set[str]={_BOT_NAME}, assignee_token=_ASSIGNEE_TOKEN): + sdk_assignees: Set[str], assignee_token=_ASSIGNEE_TOKEN): self.issues_package = issues_package - self.language_owner = language_owner - self.assignee_candidates = language_owner - skipped_assignees + self.language_owner = language_owner | sdk_assignees + self.assignee_candidates = sdk_assignees # arguments add to language.md self.file_out_name = 'common.md' self.target_release_date = '' diff --git a/scripts/release_helper/go.py b/scripts/release_helper/go.py index 2b242cbd1c63..1825520aa4dc 100644 --- a/scripts/release_helper/go.py +++ b/scripts/release_helper/go.py @@ -3,8 +3,8 @@ import os # assignee dict which will be assigned to handle issues -_GO_OWNER = {'ArcturusZhang', 'Alancere', 'azure-sdk'} -_SKIPPED_ASSIGNEES = {'ArcturusZhang', 'azure-sdk'} +_GO_OWNER = {'ArcturusZhang', 'azure-sdk'} +_GO_ASSIGNEE = {'Alancere'} class IssueProcessGo(IssueProcess): @@ -12,11 +12,11 @@ class IssueProcessGo(IssueProcess): class Go(Common): - def __init__(self, issues, language_owner, skipped_assignees): - super(Go, self).__init__(issues, language_owner, skipped_assignees) + def __init__(self, issues, language_owner, sdk_assignees): + super(Go, self).__init__(issues, language_owner, sdk_assignees) self.file_out_name = 'release_go_status.md' def go_process(issues: List[Any]): - instance = Go(issues, _GO_OWNER, _SKIPPED_ASSIGNEES) + instance = Go(issues, _GO_OWNER, _GO_ASSIGNEE) instance.run() diff --git a/scripts/release_helper/java.py b/scripts/release_helper/java.py index 121620a2fcf4..a5b6e0260387 100644 --- a/scripts/release_helper/java.py +++ b/scripts/release_helper/java.py @@ -4,19 +4,19 @@ import os # assignee dict which will be assigned to handle issues -_JAVA_OWNER = {'weidongxu-microsoft', 'haolingdong-msft', 'XiaofeiCao', 'azure-sdk'} - +_JAVA_OWNER = {'azure-sdk'} +_JS_ASSIGNEE = {'weidongxu-microsoft', 'haolingdong-msft', 'XiaofeiCao'} class IssueProcessJava(IssueProcess): pass class Java(Common): - def __init__(self, issues, language_owner): - super(Java, self).__init__(issues, language_owner) + def __init__(self, issues, language_owner, sdk_assignees): + super(Java, self).__init__(issues, language_owner, sdk_assignees) self.file_out_name = 'release_java_status.md' def java_process(issues: List[Any]): - instance = Java(issues, _JAVA_OWNER) + instance = Java(issues, _JAVA_OWNER, _JS_ASSIGNEE) instance.run() diff --git a/scripts/release_helper/js.py b/scripts/release_helper/js.py index a21286533c3c..1713c5315005 100644 --- a/scripts/release_helper/js.py +++ b/scripts/release_helper/js.py @@ -4,8 +4,8 @@ import os # assignee dict which will be assigned to handle issues -_JS_OWNER = {'qiaozha', 'lirenhe', 'MaryGao', 'kazrael2119', 'azure-sdk'} -_SKIPPED_ASSIGNEES = {'lirenhe', 'kazrael2119', 'azure-sdk'} +_JS_OWNER = {'lirenhe', 'kazrael2119', 'azure-sdk'} +_JS_ASSIGNEE = {'qiaozha', 'MaryGao'} class IssueProcessJs(IssueProcess): @@ -18,11 +18,11 @@ def auto_assign_policy(self) -> str: class Js(Common): - def __init__(self, issues, language_owner, skipped_assignees): - super(Js, self).__init__(issues, language_owner, skipped_assignees) + def __init__(self, issues, language_owner, sdk_assignees): + super(Js, self).__init__(issues, language_owner, sdk_assignees) self.file_out_name = 'release_js_status.md' self.issue_process_function = IssueProcessJs def js_process(issues: List[Any]): - instance = Js(issues, _JS_OWNER, _SKIPPED_ASSIGNEES) + instance = Js(issues, _JS_OWNER, _JS_ASSIGNEE) instance.run() diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index dd296da5e17c..8f8e19fee511 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -9,7 +9,8 @@ from utils import AUTO_CLOSE_LABEL, get_last_released_date, record_release, get_python_release_pipeline, run_pipeline # assignee dict which will be assigned to handle issues -_PYTHON_OWNER = {'BigCat20196', 'msyyc', 'Wzb123456789', 'azure-sdk'} +_PYTHON_OWNER = {'msyyc', 'azure-sdk'} +_PYTHON_ASSIGNEE = {'BigCat20196', 'Wzb123456789'} # labels _CONFIGURED = 'Configured' _AUTO_ASK_FOR_CHECK = 'auto-ask-check' @@ -134,8 +135,8 @@ def run(self) -> None: class Python(Common): - def __init__(self, issues, language_owner): - super(Python, self).__init__(issues, language_owner) + def __init__(self, issues, language_owner, sdk_assignees): + super(Python, self).__init__(issues, language_owner, sdk_assignees) self.file_out_name = 'release_python_status.md' self.issue_process_function = IssueProcessPython @@ -152,5 +153,5 @@ def run(self): def python_process(issues: List[Any]): - instance = Python(issues, _PYTHON_OWNER) + instance = Python(issues, _PYTHON_OWNER, _PYTHON_ASSIGNEE) instance.run() From 942565590c58d33139cc7f5c820186927ef95453 Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Wed, 29 Jun 2022 10:39:49 +0800 Subject: [PATCH 090/103] debug --- scripts/release_helper/common.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index 7a960f5df2a9..a25581e340b0 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -299,6 +299,7 @@ def __init__(self, issues_package: List[IssuePackage], language_owner: Set[str], sdk_assignees: Set[str], assignee_token=_ASSIGNEE_TOKEN): self.issues_package = issues_package self.language_owner = language_owner | sdk_assignees + print(f"*** language owner:{self.language_owner}") self.assignee_candidates = sdk_assignees # arguments add to language.md self.file_out_name = 'common.md' @@ -362,5 +363,5 @@ def run(self): self.output() def common_process(issues: List[IssuePackage]): - instance = Common(issues, _LANGUAGE_OWNER) + instance = Common(issues, _LANGUAGE_OWNER, _LANGUAGE_OWNER) instance.run() From e8afcf3e4035ce2918a12009d79dc96577e27da5 Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Wed, 29 Jun 2022 11:22:27 +0800 Subject: [PATCH 091/103] debug --- scripts/release_helper/common.py | 3 ++- scripts/release_helper/python.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index a25581e340b0..c54db047ee71 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -213,7 +213,9 @@ def auto_assign_policy(self) -> str: def auto_assign(self) -> None: if AUTO_ASSIGN_LABEL in self.issue_package.labels_name: self.update_issue_instance() + print(f"*** {self.issue_package.issue.number} has assign label") return + print(f"*** {self.issue_package.issue.number} has not assign label") # assign averagely assignee = self.auto_assign_policy() @@ -299,7 +301,6 @@ def __init__(self, issues_package: List[IssuePackage], language_owner: Set[str], sdk_assignees: Set[str], assignee_token=_ASSIGNEE_TOKEN): self.issues_package = issues_package self.language_owner = language_owner | sdk_assignees - print(f"*** language owner:{self.language_owner}") self.assignee_candidates = sdk_assignees # arguments add to language.md self.file_out_name = 'common.md' diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index 8f8e19fee511..55011a69537b 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -32,7 +32,7 @@ def __init__(self, issue_package: IssuePackage, request_repo_dict: Dict[str, Rep def get_delay_time(self): q = [comment.updated_at - for comment in self.issue_package.issue.get_comments() if comment.user.login not in _PYTHON_OWNER] + for comment in self.issue_package.issue.get_comments() if comment.user.login not in self.language_owner] q.sort() return (datetime.now() - (self.created_time if not q else q[-1])).days From 9a89bbe7196f5da4be2bd779cc51b068531be22e Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Wed, 29 Jun 2022 14:31:33 +0800 Subject: [PATCH 092/103] update python assignee --- scripts/release_helper/common.py | 2 -- scripts/release_helper/python.py | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index c54db047ee71..360580a6a059 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -213,9 +213,7 @@ def auto_assign_policy(self) -> str: def auto_assign(self) -> None: if AUTO_ASSIGN_LABEL in self.issue_package.labels_name: self.update_issue_instance() - print(f"*** {self.issue_package.issue.number} has assign label") return - print(f"*** {self.issue_package.issue.number} has not assign label") # assign averagely assignee = self.auto_assign_policy() diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index 55011a69537b..e73244d43647 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -9,8 +9,8 @@ from utils import AUTO_CLOSE_LABEL, get_last_released_date, record_release, get_python_release_pipeline, run_pipeline # assignee dict which will be assigned to handle issues -_PYTHON_OWNER = {'msyyc', 'azure-sdk'} -_PYTHON_ASSIGNEE = {'BigCat20196', 'Wzb123456789'} +_PYTHON_OWNER = {'azure-sdk'} +_PYTHON_ASSIGNEE = {'msyyc', 'BigCat20196', 'Wzb123456789'} # labels _CONFIGURED = 'Configured' _AUTO_ASK_FOR_CHECK = 'auto-ask-check' From 9290c646f4f1712ed4195362dfb2c42e031371a2 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Thu, 30 Jun 2022 10:36:13 +0800 Subject: [PATCH 093/103] Update python.py --- scripts/release_helper/python.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index e73244d43647..d2dff53b633e 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -9,8 +9,8 @@ from utils import AUTO_CLOSE_LABEL, get_last_released_date, record_release, get_python_release_pipeline, run_pipeline # assignee dict which will be assigned to handle issues -_PYTHON_OWNER = {'azure-sdk'} -_PYTHON_ASSIGNEE = {'msyyc', 'BigCat20196', 'Wzb123456789'} +_PYTHON_OWNER = {'azure-sdk', 'msyyc'} +_PYTHON_ASSIGNEE = {'BigCat20196', 'Wzb123456789'} # labels _CONFIGURED = 'Configured' _AUTO_ASK_FOR_CHECK = 'auto-ask-check' From 055c2e72f28eac038cf45d8cfefb69955cf22fb5 Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Wed, 6 Jul 2022 11:18:25 +0800 Subject: [PATCH 094/103] debug --- scripts/release_helper/python.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index d2dff53b633e..e378d5243bd5 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -69,6 +69,8 @@ def readme_comparison(self) -> bool: contents = str(self.issue_package.rest_repo.get_contents(readme_path).decoded_content) pattern_tag = re.compile(r'tag: package-[\w+-.]+') package_tags = pattern_tag.findall(contents) + print(f"*** self.target_readme_tag: {self.target_readme_tag}") + print(f"*** package_tags: {package_tags}") whether_same_tag = self.target_readme_tag in package_tags whether_change_readme = not whether_same_tag or self.is_multiapi return whether_change_readme From 0c7744f874f52505744bf573d6d5c18eadb03b90 Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Wed, 6 Jul 2022 11:34:45 +0800 Subject: [PATCH 095/103] debug --- scripts/release_helper/python.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index e378d5243bd5..0d18ded0bd7a 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -71,7 +71,8 @@ def readme_comparison(self) -> bool: package_tags = pattern_tag.findall(contents) print(f"*** self.target_readme_tag: {self.target_readme_tag}") print(f"*** package_tags: {package_tags}") - whether_same_tag = self.target_readme_tag in package_tags + whether_same_tag = f'tag: {self.target_readme_tag}' in package_tags + print(f'whether_same_tag: {whether_same_tag}') whether_change_readme = not whether_same_tag or self.is_multiapi return whether_change_readme From 5642eab9143ae7f21c286fd1986dce373d445704 Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Wed, 6 Jul 2022 11:45:43 +0800 Subject: [PATCH 096/103] delete useless code --- scripts/release_helper/python.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index 0d18ded0bd7a..64b4d2055c9d 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -69,10 +69,7 @@ def readme_comparison(self) -> bool: contents = str(self.issue_package.rest_repo.get_contents(readme_path).decoded_content) pattern_tag = re.compile(r'tag: package-[\w+-.]+') package_tags = pattern_tag.findall(contents) - print(f"*** self.target_readme_tag: {self.target_readme_tag}") - print(f"*** package_tags: {package_tags}") whether_same_tag = f'tag: {self.target_readme_tag}' in package_tags - print(f'whether_same_tag: {whether_same_tag}') whether_change_readme = not whether_same_tag or self.is_multiapi return whether_change_readme From 4918eee32949498e897b0beddfe2c510bf853a50 Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Wed, 6 Jul 2022 12:52:55 +0800 Subject: [PATCH 097/103] Update scripts/release_helper/python.py Co-authored-by: Yuchao Yan --- scripts/release_helper/python.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index 64b4d2055c9d..2dabea9a960a 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -69,7 +69,7 @@ def readme_comparison(self) -> bool: contents = str(self.issue_package.rest_repo.get_contents(readme_path).decoded_content) pattern_tag = re.compile(r'tag: package-[\w+-.]+') package_tags = pattern_tag.findall(contents) - whether_same_tag = f'tag: {self.target_readme_tag}' in package_tags + whether_same_tag = self.target_readme_tag in package_tags[0] whether_change_readme = not whether_same_tag or self.is_multiapi return whether_change_readme From c5d19c8dd7a323021b34f04a409294f69af0fdf5 Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Thu, 7 Jul 2022 14:17:16 +0800 Subject: [PATCH 098/103] add multi api policy --- scripts/release_helper/python.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index 2dabea9a960a..013448bb802f 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -16,6 +16,7 @@ _AUTO_ASK_FOR_CHECK = 'auto-ask-check' _BRANCH_ATTENTION = 'base-branch-attention' _7_DAY_ATTENTION = '7days attention' +_MULTI_API = 'MultiAPI' # record published issues _FILE_OUT = 'published_issues_python.csv' @@ -45,6 +46,12 @@ def init_readme_link(self) -> None: # get readme_link self.get_readme_link(origin_link) + def multi_api_policy(self) -> None: + if self.is_multiapi: + self.bot_advice.append('It is a MultiAPI') + if _MULTI_API not in self.issue_package.labels_name: + self.add_label(_MULTI_API) + def get_package_and_output(self) -> None: self.init_readme_link() readme_python_path = self.pattern_resource_manager.search(self.readme_link).group() + '/readme.python.md' @@ -53,7 +60,7 @@ def get_package_and_output(self) -> None: pattern_output = re.compile(r'\$\(python-sdks-folder\)/(.*?)/azure-') self.package_name = pattern_package.search(contents).group().split(':')[-1].strip() self.output_folder = pattern_output.search(contents).group().split('/')[1] - self.is_multiapi = ('MultiAPI' in self.issue_package.labels_name) or ('multi-api' in contents) + self.is_multiapi = (_MULTI_API in self.issue_package.labels_name) or ('multi-api' in contents) def get_edit_content(self) -> None: self.edit_content = f'\n{self.readme_link.replace("/readme.md", "")}\n{self.package_name}' @@ -111,6 +118,7 @@ def remind_policy(self): def auto_bot_advice(self): super().auto_bot_advice() + self.multi_api_policy() self.attention_policy() self.remind_policy() From 53d15db37c9fbd2e866e4808c3346b5e3c33a671 Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Fri, 8 Jul 2022 16:21:01 +0800 Subject: [PATCH 099/103] add tag inconsystency --- scripts/release_helper/python.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index 013448bb802f..8c662c7ff977 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -17,6 +17,7 @@ _BRANCH_ATTENTION = 'base-branch-attention' _7_DAY_ATTENTION = '7days attention' _MULTI_API = 'MultiAPI' +_INCONSISTENT_TAG = 'Inconsistent tag' # record published issues _FILE_OUT = 'published_issues_python.csv' @@ -46,6 +47,11 @@ def init_readme_link(self) -> None: # get readme_link self.get_readme_link(origin_link) + def check_tag_consistency(self) -> None: + super().check_tag_consistency() + if self.default_readme_tag != self.target_readme_tag: + self.add_label(_INCONSISTENT_TAG) + def multi_api_policy(self) -> None: if self.is_multiapi: self.bot_advice.append('It is a MultiAPI') @@ -104,6 +110,9 @@ def attention_policy(self): if _BRANCH_ATTENTION in self.issue_package.labels_name: self.bot_advice.append('new version is 0.0.0, please check base branch!') + if _INCONSISTENT_TAG in self.issue_package.labels_name: + self.bot_advice.append('Attention to inconsistent tag') + def remind_policy(self): if self.delay_time >= 15 and _7_DAY_ATTENTION in self.issue_package.labels_name and self.date_from_target < 0: self.comment( @@ -122,6 +131,7 @@ def auto_bot_advice(self): self.attention_policy() self.remind_policy() + def auto_close(self) -> None: if AUTO_CLOSE_LABEL in self.issue_package.labels_name: return From 8483a4d4205a35908a7fca4290594ff27c97de3a Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Mon, 11 Jul 2022 14:02:34 +0800 Subject: [PATCH 100/103] add specified tag --- scripts/release_helper/common.py | 3 ++- scripts/release_helper/python.py | 10 ++++++++-- scripts/release_helper/utils.py | 6 +++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index 360580a6a059..1861c8b0af27 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -174,7 +174,8 @@ def auto_parse(self) -> None: issue_body_list = self.get_issue_body() # Get the origin link and readme tag in issue body - origin_link, self.target_readme_tag = get_origin_link_and_tag(issue_body_list) + origin_link, target_readme_tag = get_origin_link_and_tag(issue_body_list) + self.target_readme_tag = target_readme_tag if not self.target_readme_tag else self.target_readme_tag # get readme_link self.get_readme_link(origin_link) diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index 8c662c7ff977..47352594e928 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -31,6 +31,7 @@ def __init__(self, issue_package: IssuePackage, request_repo_dict: Dict[str, Rep self.is_multiapi = False self.pattern_resource_manager = re.compile(r'/specification/([\w-]+/)+resource-manager') self.delay_time = self.get_delay_time() + self.is_specified_tag = False def get_delay_time(self): q = [comment.updated_at @@ -43,11 +44,13 @@ def init_readme_link(self) -> None: # Get the origin link and readme tag in issue body origin_link, self.target_readme_tag = get_origin_link_and_tag(issue_body_list) + self.is_specified_tag = any('->Readme Tag:' in line for line in issue_body_list) # get readme_link self.get_readme_link(origin_link) def check_tag_consistency(self) -> None: + self.target_readme_tag = self.target_readme_tag.replace('tag-', '') super().check_tag_consistency() if self.default_readme_tag != self.target_readme_tag: self.add_label(_INCONSISTENT_TAG) @@ -69,7 +72,8 @@ def get_package_and_output(self) -> None: self.is_multiapi = (_MULTI_API in self.issue_package.labels_name) or ('multi-api' in contents) def get_edit_content(self) -> None: - self.edit_content = f'\n{self.readme_link.replace("/readme.md", "")}\n{self.package_name}' + self.edit_content = f'\n{self.readme_link.replace("/readme.md", "")}\n{self.package_name}' \ + f'\nReadme Tag: {self.target_readme_tag}' @property def readme_comparison(self) -> bool: @@ -92,9 +96,11 @@ def auto_reply(self) -> None: if not self.readme_comparison: issue_link = self.issue_package.issue.html_url release_pipeline_url = get_python_release_pipeline(self.output_folder) + python_tag = self.target_readme_tag if self.is_specified_tag else "" res_run = run_pipeline(issue_link=issue_link, pipeline_url=release_pipeline_url, - spec_readme=self.readme_link + '/readme.md' + spec_readme=self.readme_link + '/readme.md', + python_tag=python_tag ) if res_run: self.log(f'{issue_number} run pipeline successfully') diff --git a/scripts/release_helper/utils.py b/scripts/release_helper/utils.py index a336a55d7b30..a26d4c1fbe51 100644 --- a/scripts/release_helper/utils.py +++ b/scripts/release_helper/utils.py @@ -71,7 +71,7 @@ def get_python_release_pipeline(output_folder): # Run sdk-auto-release(main) to generate SDK -def run_pipeline(issue_link, pipeline_url, spec_readme): +def run_pipeline(issue_link, pipeline_url, spec_readme, python_tag=""): paramaters = { "stages_to_skip": [], "resources": { @@ -97,6 +97,10 @@ def run_pipeline(issue_link, pipeline_url, spec_readme): "SPEC_README": { "value": spec_readme, "isSecret": False + }, + "PYTHON_TAG": { + "value": python_tag, + "isSecret": False } } } From 891784b75d6c34439eda6a2e6a462310df635866 Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Tue, 12 Jul 2022 10:13:26 +0800 Subject: [PATCH 101/103] Update scripts/release_helper/python.py Co-authored-by: Yuchao Yan --- scripts/release_helper/python.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index 47352594e928..99f381367b2a 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -57,7 +57,7 @@ def check_tag_consistency(self) -> None: def multi_api_policy(self) -> None: if self.is_multiapi: - self.bot_advice.append('It is a MultiAPI') + self.bot_advice.append('MultiAPI') if _MULTI_API not in self.issue_package.labels_name: self.add_label(_MULTI_API) From 069def5dc35e082b5d738ca78d92582b318053e8 Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Tue, 12 Jul 2022 10:26:52 +0800 Subject: [PATCH 102/103] update --- scripts/release_helper/common.py | 9 ++++++++- scripts/release_helper/python.py | 18 ++++-------------- scripts/release_helper/utils.py | 1 + 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index 1861c8b0af27..562ddd615916 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -11,7 +11,7 @@ from github.Repository import Repository from utils import IssuePackage, REQUEST_REPO, AUTO_ASSIGN_LABEL, AUTO_PARSE_LABEL, get_origin_link_and_tag,\ - MULTI_LINK_LABEL + MULTI_LINK_LABEL, INCONSISTENT_TAG _LOG = logging.getLogger(__name__) @@ -159,7 +159,9 @@ def edit_issue_body(self) -> None: self.issue_package.issue.edit(body=issue_body_up) def check_tag_consistency(self) -> None: + self.target_readme_tag = self.target_readme_tag.replace('tag-', '') if self.default_readme_tag != self.target_readme_tag: + self.add_label(INCONSISTENT_TAG) self.comment(f'Hi, @{self.owner}, according to [rule](https://github.com/Azure/azure-rest-api-specs/blob/' f'main/documentation/release-request/rules-for-release-request.md#3-readme-tag-to-be-released),' f' your **Readme Tag** is `{self.target_readme_tag}`, but in [readme.md]({self.readme_link}#basic-information) ' @@ -253,6 +255,10 @@ def multi_link_policy(self): if MULTI_LINK_LABEL in self.issue_package.labels_name: self.bot_advice.append('multi readme link!') + def inconsistent_tag_policy(self): + if INCONSISTENT_TAG in self.issue_package.labels_name: + self.bot_advice.append('Attention to inconsistent tag') + def remind_logic(self) -> bool: return abs(self.date_from_target) <= 2 @@ -268,6 +274,7 @@ def auto_bot_advice(self): self.new_comment_policy() self.multi_link_policy() self.date_remind_policy() + self.inconsistent_tag_policy() def get_target_date(self): body = self.get_issue_body() diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index 99f381367b2a..55f02daad100 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -16,8 +16,7 @@ _AUTO_ASK_FOR_CHECK = 'auto-ask-check' _BRANCH_ATTENTION = 'base-branch-attention' _7_DAY_ATTENTION = '7days attention' -_MULTI_API = 'MultiAPI' -_INCONSISTENT_TAG = 'Inconsistent tag' +_MultiAPI = 'MultiAPI' # record published issues _FILE_OUT = 'published_issues_python.csv' @@ -49,17 +48,11 @@ def init_readme_link(self) -> None: # get readme_link self.get_readme_link(origin_link) - def check_tag_consistency(self) -> None: - self.target_readme_tag = self.target_readme_tag.replace('tag-', '') - super().check_tag_consistency() - if self.default_readme_tag != self.target_readme_tag: - self.add_label(_INCONSISTENT_TAG) - def multi_api_policy(self) -> None: if self.is_multiapi: self.bot_advice.append('MultiAPI') - if _MULTI_API not in self.issue_package.labels_name: - self.add_label(_MULTI_API) + if _MultiAPI not in self.issue_package.labels_name: + self.add_label(_MultiAPI) def get_package_and_output(self) -> None: self.init_readme_link() @@ -69,7 +62,7 @@ def get_package_and_output(self) -> None: pattern_output = re.compile(r'\$\(python-sdks-folder\)/(.*?)/azure-') self.package_name = pattern_package.search(contents).group().split(':')[-1].strip() self.output_folder = pattern_output.search(contents).group().split('/')[1] - self.is_multiapi = (_MULTI_API in self.issue_package.labels_name) or ('multi-api' in contents) + self.is_multiapi = (_MultiAPI in self.issue_package.labels_name) or ('multi-api' in contents) def get_edit_content(self) -> None: self.edit_content = f'\n{self.readme_link.replace("/readme.md", "")}\n{self.package_name}' \ @@ -116,9 +109,6 @@ def attention_policy(self): if _BRANCH_ATTENTION in self.issue_package.labels_name: self.bot_advice.append('new version is 0.0.0, please check base branch!') - if _INCONSISTENT_TAG in self.issue_package.labels_name: - self.bot_advice.append('Attention to inconsistent tag') - def remind_policy(self): if self.delay_time >= 15 and _7_DAY_ATTENTION in self.issue_package.labels_name and self.date_from_target < 0: self.comment( diff --git a/scripts/release_helper/utils.py b/scripts/release_helper/utils.py index a26d4c1fbe51..4c3172310a4c 100644 --- a/scripts/release_helper/utils.py +++ b/scripts/release_helper/utils.py @@ -18,6 +18,7 @@ AUTO_PARSE_LABEL = 'auto-link' AUTO_CLOSE_LABEL = 'auto-close' MULTI_LINK_LABEL = 'MultiLink' +INCONSISTENT_TAG = 'Inconsistent tag' _LOG = logging.getLogger(__name__) From a71985649c165a2ea5eadee6d82d84b0ab0f866d Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Tue, 12 Jul 2022 10:36:49 +0800 Subject: [PATCH 103/103] update multiapi policy --- scripts/release_helper/python.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index 55f02daad100..f444063ed165 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -50,7 +50,8 @@ def init_readme_link(self) -> None: def multi_api_policy(self) -> None: if self.is_multiapi: - self.bot_advice.append('MultiAPI') + if _AUTO_ASK_FOR_CHECK not in self.issue_package.labels_name: + self.bot_advice.append(_MultiAPI) if _MultiAPI not in self.issue_package.labels_name: self.add_label(_MultiAPI)