Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
a4c6645
update for Go
msyyc Nov 26, 2021
d96f9e1
check tag consistency and optize reply
msyyc Nov 26, 2021
29dcc3b
add write.md
RAY-316 Nov 30, 2021
7c41af8
update go js readme
RAY-316 Nov 30, 2021
971b310
Merge pull request #27 from msyyc/helper-update-1
RAY-316 Nov 30, 2021
bdeabc3
update
RAY-316 Nov 30, 2021
3d466ae
Merge pull request #28 from msyyc/helper-update-1
RAY-316 Nov 30, 2021
c0ab72f
Update common.py
RAY-316 Nov 30, 2021
ba7d785
Update common.py
RAY-316 Dec 1, 2021
6231625
update assignee for JS
msyyc Dec 1, 2021
41190c6
update
RAY-316 Dec 1, 2021
46c273e
Merge pull request #29 from RAY-316/helper-update-2
RAY-316 Dec 1, 2021
d5ca1dc
update
RAY-316 Dec 1, 2021
8a44300
Merge pull request #30 from RAY-316/helper-update-2
RAY-316 Dec 1, 2021
7110dbb
Update common.py
RAY-316 Dec 1, 2021
32bc8ef
Update common.py
RAY-316 Dec 1, 2021
e76d3ab
Update release_helper.yml for Azure Pipelines
RAY-316 Dec 1, 2021
5c4b139
Update common.py
RAY-316 Dec 1, 2021
9230cc8
update
RAY-316 Dec 1, 2021
65cd109
Merge branch 'release-helper' into helper-update-2
RAY-316 Dec 1, 2021
e901ee2
Merge pull request #31 from RAY-316/helper-update-2
RAY-316 Dec 1, 2021
0708059
Update common.py
RAY-316 Dec 1, 2021
3ae9739
Update common.py
RAY-316 Dec 1, 2021
4726a30
Update main.py
RAY-316 Dec 1, 2021
910e856
update
RAY-316 Dec 2, 2021
a97639a
Merge branch 'release-helper' into helper-update-2
RAY-316 Dec 2, 2021
da2b248
Merge pull request #32 from msyyc/helper-update-2
RAY-316 Dec 2, 2021
6053c72
update bot advice
RAY-316 Dec 2, 2021
672f312
Merge branch 'helper-update-2' of https://github.com/msyyc/azure-sdk-…
RAY-316 Dec 2, 2021
be9e9bc
update
RAY-316 Dec 2, 2021
73ac481
Merge pull request #33 from msyyc/helper-update-2
RAY-316 Dec 2, 2021
3ca7f91
Merge branch 'main' into release-helper
RAY-316 Dec 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 58 additions & 1 deletion scripts/release_helper/common.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -6,6 +7,7 @@
import time
from github import Github
from github.Repository import Repository
import subprocess as sp

_LOG = logging.getLogger(__name__)

Expand All @@ -15,6 +17,9 @@
# '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'


_SWAGGER_URL = 'https://github.com/Azure/azure-rest-api-specs/blob/main/specification'
_SWAGGER_PULL = 'https://github.com/Azure/azure-rest-api-specs/pull'
Expand Down Expand Up @@ -75,7 +80,9 @@ 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}"')

Expand Down Expand Up @@ -196,10 +203,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 ! <br>'
elif latest_comments not in self.language_owner:
self.bot = 'new comment. <br>'

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:
Expand All @@ -213,16 +233,53 @@ 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.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_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.issue_package.issue.created_at.timestamp()).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,
create_date,
self.target_release_date,
self.date_from_target
)

@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]

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_md(items)



def common_process(issues: List[IssuePackage]):
Expand Down
4 changes: 3 additions & 1 deletion scripts/release_helper/go.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ class IssueProcessGo(IssueProcess):


class Go(Common):
pass
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'


def go_process(issues: List[Any]):
Expand Down
5 changes: 4 additions & 1 deletion scripts/release_helper/java.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ 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]):
Expand Down
4 changes: 3 additions & 1 deletion scripts/release_helper/js.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ class IssueProcessJs(IssueProcess):


class Js(Common):
pass
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'


def js_process(issues: List[Any]):
Expand Down
4 changes: 3 additions & 1 deletion scripts/release_helper/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
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
Expand Down Expand Up @@ -54,6 +55,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__':
Expand Down
8 changes: 4 additions & 4 deletions scripts/release_helper/release_helper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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