Skip to content

Commit

Permalink
[Script] Release helper (Azure#25122)
Browse files Browse the repository at this point in the history
* update for Go

* check tag consistency and optize reply

* add write.md

* update go js readme

* update

* Update common.py

* Update common.py

* update assignee for JS

* update

* update

* Update common.py

* Update common.py

* Update release_helper.yml for Azure Pipelines

* Update common.py

* update

* Update common.py

* Update common.py

* Update main.py

* update

* update bot advice

* update

* update

* update excel

* update output function

* add exception handle for bad credential

* fix static varaible in class

* update auto_assignee algorithm

* update bot token to have a try

* update bot token

* force to single process

* test

* test

* test

* test

* fix bug

* fix

* update release_helper/js

* update release_helper/js

* fix bug

* update release helper

* Update js.py

* Update js.py

* Update js.py

* urldecode

* format

* add python

* fix

* add package name

* update package name

* update package name

* fix bug

* update get edit_content

* auto-close

* record release

* debug

* debug

* debug

* override run

* init readme link

* fix

* fix

* fix

* update assignee_token and auto-close

* fix

* debug

* fix

* auto-reply

* fix

* debug

* fix

* debug

* debug

* fix

* debugg

* update yaml

* change to add_label

* format

* add attention policy and remind policy

* add duplicated policy

* delete uesless code

* Update scripts/release_helper/utils.py

Co-authored-by: Yuchao Yan <yuchaoyan@microsoft.com>

* update

* fix dependence version

* fix dependence version

* fix env

* update js assignee

* update js assignee

* fix find pr number bug

* update assignee logic

* debug

* debug

* update python assignee

* Update python.py

* debug

* debug

* delete useless code

* Update scripts/release_helper/python.py

Co-authored-by: Yuchao Yan <yuchaoyan@microsoft.com>

* add multi api policy

* add tag inconsystency

* add specified tag

* Update scripts/release_helper/python.py

Co-authored-by: Yuchao Yan <yuchaoyan@microsoft.com>

* update

* update multiapi policy

Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
Co-authored-by: Zed <601306339@qq.com>
Co-authored-by: Yiming Lei <59104634+RAY-316@users.noreply.github.com>
Co-authored-by: Yuchao Yan <yuchaoyan@microsoft.com>
  • Loading branch information
5 people authored Jul 13, 2022
1 parent da9039e commit ceb8d15
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
12 changes: 10 additions & 2 deletions scripts/release_helper/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -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) '
Expand All @@ -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)
Expand Down Expand Up @@ -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

Expand All @@ -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()
Expand Down
21 changes: 18 additions & 3 deletions scripts/release_helper/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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
Expand All @@ -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'
Expand All @@ -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:
Expand All @@ -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')
Expand Down Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion scripts/release_helper/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -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": {
Expand All @@ -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
}
}
}
Expand Down

0 comments on commit ceb8d15

Please sign in to comment.