diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index 360580a6a0592..562ddd615916d 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) ' @@ -174,7 +176,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) @@ -252,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 @@ -267,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 2dabea9a960af..f444063ed1651 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' +_MultiAPI = 'MultiAPI' # record published issues _FILE_OUT = 'published_issues_python.csv' @@ -29,6 +30,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 @@ -41,10 +43,18 @@ 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 multi_api_policy(self) -> None: + if self.is_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) + 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,10 +63,11 @@ 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 = (_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}' + 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: @@ -79,9 +90,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') @@ -111,9 +124,11 @@ def remind_policy(self): def auto_bot_advice(self): super().auto_bot_advice() + self.multi_api_policy() self.attention_policy() self.remind_policy() + def auto_close(self) -> None: if AUTO_CLOSE_LABEL in self.issue_package.labels_name: return diff --git a/scripts/release_helper/utils.py b/scripts/release_helper/utils.py index a336a55d7b300..4c3172310a4cb 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__) @@ -71,7 +72,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 +98,10 @@ def run_pipeline(issue_link, pipeline_url, spec_readme): "SPEC_README": { "value": spec_readme, "isSecret": False + }, + "PYTHON_TAG": { + "value": python_tag, + "isSecret": False } } }