From 7d0765a7a82723ef5d24383b7132bde8d9bf5517 Mon Sep 17 00:00:00 2001 From: msyyc <70930885+msyyc@users.noreply.github.com> Date: Fri, 25 Jun 2021 14:48:01 +0800 Subject: [PATCH 01/58] version auto-calculation rule --- scripts/auto_release/main.py | 114 ++++++++++++++++++++++------------- 1 file changed, 71 insertions(+), 43 deletions(-) diff --git a/scripts/auto_release/main.py b/scripts/auto_release/main.py index adaadc9f99f7..cdd827d37bb2 100644 --- a/scripts/auto_release/main.py +++ b/scripts/auto_release/main.py @@ -78,8 +78,34 @@ def create_changelog_content(): return add_content -def edit_version(add_content): - global VERSION_NEW, VERSION_LAST_RELEASE +def judge_tag(): + path = f'{os.getcwd()}/sdk/{SDK_FOLDER}/azure-mgmt-{SERVICE_NAME}' + files = [] + all_files(path, files) + default_api_version = '' # for multi-api + api_version = '' # for single-api + for file in files: + with open(file, 'r') as file_in: + list_in = file_in.readlines() + for line in list_in: + if line.find('DEFAULT_API_VERSION = ') > -1: + default_api_version += line.split('=')[-1].strip('\n') # collect all default api version + if default_api_version == '' and line.find('self.api_version = ') > -1: + api_version += line.split('=')[-1].strip('\n') # collect all single api version + if default_api_version != '': + my_print(f'find default api version:{default_api_version}') + return 'preview' in default_api_version + my_print(f'find single api version:{api_version}') + return 'preview' in api_version + + +def preview_version_plus(preview_label): + num = VERSION_LAST_RELEASE.split(preview_label) + num[1] = str(int(num[1]) + 1) + return f'{num[0]}{preview_label}{num[1]}' + + +def stable_version_plus(add_content): flag = [False, False, False] # breaking, feature, bugfix for line in add_content: if line.find('**Breaking changes**') > -1: @@ -89,36 +115,34 @@ def edit_version(add_content): flag[1] = True elif line.find('**Bugfixes**') > -1: flag[2] = True - - path = f'sdk/{SDK_FOLDER}/azure-mgmt-{SERVICE_NAME}/azure/mgmt/{SERVICE_NAME}' - file_name = 'version.py' if TRACK == '1' else '_version.py' - with open(f'{path}/{file_name}', 'r') as file_in: - list_in = file_in.readlines() - num = VERSION_LAST_RELEASE.split('.') - if TRACK == '1' and num[0] == '0': - VERSION_NEW = f'0.{str(int(num[1]) + 1)}.0' - elif VERSION_LAST_RELEASE.find('b') > -1: - lastnum = num[2].split('b') - lastnum[1] = str(int(lastnum[1]) + 1) - VERSION_NEW = f'{num[0]}.{num[1]}.{lastnum[0]}b{lastnum[1]}' - elif VERSION_LAST_RELEASE.find('rc') > -1: - lastnum = num[2].split('rc') - lastnum[1] = str(int(lastnum[1]) + 1) - VERSION_NEW = f'{num[0]}.{num[1]}.{lastnum[0]}rc{lastnum[1]}' - elif flag[0]: - VERSION_NEW = f'{int(num[0]) + 1}.0.0' + if flag[0]: + return f'{int(num[0]) + 1}.0.0' elif flag[1]: - VERSION_NEW = f'{num[0]}.{int(num[1]) + 1}.0' + return f'{num[0]}.{int(num[1]) + 1}.0' elif flag[2]: - VERSION_NEW = f'{num[0]}.{num[1]}.{int(num[2]) + 1}' + return f'{num[0]}.{num[1]}.{int(num[2]) + 1}' - for i in range(0, len(list_in)): - if list_in[i].find('VERSION ') > -1: - list_in[i] = f'VERSION = "{VERSION_NEW}"\n' - break - with open(f'{path}/{file_name}', 'w') as file_out: - file_out.writelines(list_in) + +def edit_version(add_content): + global VERSION_NEW + + preview_tag = judge_tag() + preview_version = 'rc' in VERSION_LAST_RELEASE or 'b' in VERSION_LAST_RELEASE + # | preview tag | stable tag + # preview version(1.0.0rc1/1.0.0b1) | 1.0.0rc2(track1)/1.0.0b2(track2) | 1.0.0 + # stable version (1.0.0) (breaking change) | 2.0.0rc1(track1)/2.0.0b1(track2) | 2.0.0 + # stable version (1.0.0) (feature) | 1.1.0rc1(track1)/1.1.0b1(track2) | 1.1.0 + # stable version (1.0.0) (bugfix) | 1.0.1rc1(track1)/1.0.1b1(track2) | 1.0.1 + preview_label = 'rc' if TRACK == '1' else 'b' + if preview_version and preview_tag: + VERSION_NEW = preview_version_plus(preview_label) + elif preview_version and not preview_tag: + VERSION_NEW = VERSION_LAST_RELEASE.split(preview_label)[0] + elif not preview_version and preview_tag: + VERSION_NEW = stable_version_plus(add_content) + preview_label + '1' + else: + VERSION_NEW = stable_version_plus(add_content) def edit_changelog(add_content): @@ -279,26 +303,30 @@ def run_live_test(): my_print('live test run done, do not find failure !!!') -def edit_recursion(path, file): +# find all the files of one folder, including files in subdirectory +def all_files(path, files): all_folder = os.listdir(path) for folder in all_folder: - if file == folder: - tmp_file = f'{path}/{file}' - with open(tmp_file, 'r') as file_in: - list_in = file_in.readlines() - for i in range(0, len(list_in)): - if list_in[i].find('VERSION') > -1: - list_in[i] = f'VERSION = "{VERSION_NEW}"\n' - with open(tmp_file, 'w') as file_out: - file_out.writelines(list_in) - elif os.path.isdir(f'{path}/{folder}'): - edit_recursion(f'{path}/{folder}', file) + if os.path.isdir(f'{path}/{folder}'): + all_files(f'{path}/{folder}', files) + else: + files.append(f'{path}/{folder}') def edit_useless_file(): - file = 'version.py' if TRACK == '1' else '_version.py' + target_file = 'version.py' path = f'{os.getcwd()}/sdk/{SDK_FOLDER}/azure-mgmt-{SERVICE_NAME}' - edit_recursion(path, file) + files = [] + all_files(path, files) + for file in files: + if target_file in file: + with open(file, 'r') as file_in: + list_in = file_in.readlines() + for i in range(0, len(list_in)): + if list_in[i].find('VERSION') > -1: + list_in[i] = f'VERSION = "{VERSION_NEW}"\n' + with open(file, 'w') as file_output: + file_output.writelines(list_in) def commit_test(): @@ -318,7 +346,7 @@ def check_pprint_name(): for file in os.listdir(path): file_path = f'{path}/{file}' if os.path.isfile(file_path): - with open(file_path, 'r') as file_in: + with open(file_path, 'r', encoding="utf-8") as file_in: list_in = file_in.readlines() for i in range(0, len(list_in)): list_in[i] = list_in[i].replace('MyService', pprint_name) From dfda752d9d66267bce2afc9b96e7fb2dc0b837a2 Mon Sep 17 00:00:00 2001 From: msyyc <70930885+msyyc@users.noreply.github.com> Date: Fri, 25 Jun 2021 14:58:17 +0800 Subject: [PATCH 02/58] single api version rule --- scripts/auto_release/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/auto_release/main.py b/scripts/auto_release/main.py index cdd827d37bb2..fd1e167812ce 100644 --- a/scripts/auto_release/main.py +++ b/scripts/auto_release/main.py @@ -90,7 +90,7 @@ def judge_tag(): for line in list_in: if line.find('DEFAULT_API_VERSION = ') > -1: default_api_version += line.split('=')[-1].strip('\n') # collect all default api version - if default_api_version == '' and line.find('self.api_version = ') > -1: + if default_api_version == '' and line.find('api_version = ') > -1: api_version += line.split('=')[-1].strip('\n') # collect all single api version if default_api_version != '': my_print(f'find default api version:{default_api_version}') From 7dbf15d5065514bdc0dc93b442cd66d88b282294 Mon Sep 17 00:00:00 2001 From: msyyc <70930885+msyyc@users.noreply.github.com> Date: Fri, 25 Jun 2021 15:17:19 +0800 Subject: [PATCH 03/58] Update main.py --- scripts/auto_release/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/auto_release/main.py b/scripts/auto_release/main.py index fd1e167812ce..fea917cc887f 100644 --- a/scripts/auto_release/main.py +++ b/scripts/auto_release/main.py @@ -85,7 +85,7 @@ def judge_tag(): default_api_version = '' # for multi-api api_version = '' # for single-api for file in files: - with open(file, 'r') as file_in: + with open(file, 'r', encoding="utf-8") as file_in: list_in = file_in.readlines() for line in list_in: if line.find('DEFAULT_API_VERSION = ') > -1: From b9390bee1d51d578ac42d937c3da429e4d7aafc2 Mon Sep 17 00:00:00 2001 From: msyyc <70930885+msyyc@users.noreply.github.com> Date: Fri, 25 Jun 2021 15:35:32 +0800 Subject: [PATCH 04/58] additional rule for track1 --- scripts/auto_release/main.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/scripts/auto_release/main.py b/scripts/auto_release/main.py index fea917cc887f..0825fd149d77 100644 --- a/scripts/auto_release/main.py +++ b/scripts/auto_release/main.py @@ -85,8 +85,15 @@ def judge_tag(): default_api_version = '' # for multi-api api_version = '' # for single-api for file in files: - with open(file, 'r', encoding="utf-8") as file_in: - list_in = file_in.readlines() + if '.py' not in file: + continue + try: + with open(file, 'r') as file_in: + list_in = file_in.readlines() + except: + _LOG.info(f'can not open {file}') + continue + for line in list_in: if line.find('DEFAULT_API_VERSION = ') > -1: default_api_version += line.split('=')[-1].strip('\n') # collect all default api version @@ -144,6 +151,11 @@ def edit_version(add_content): else: VERSION_NEW = stable_version_plus(add_content) + # additional rule for track1: if version is 0.x.x, next version is 0.x+1.0 + if TRACK == '1' and VERSION_LAST_RELEASE[0] == '0': + num = VERSION_LAST_RELEASE.split('.') + VERSION_NEW = f'{num[0]}.{int(num[1]) + 1}.0' + def edit_changelog(add_content): path = f'sdk/{SDK_FOLDER}/azure-mgmt-{SERVICE_NAME}' From 603b68201cc7516ccd5313935427f0e588754e86 Mon Sep 17 00:00:00 2001 From: msyyc <70930885+msyyc@users.noreply.github.com> Date: Fri, 25 Jun 2021 16:20:35 +0800 Subject: [PATCH 05/58] when changelog is null --- scripts/auto_release/main.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/auto_release/main.py b/scripts/auto_release/main.py index 0825fd149d77..d8a923ceea16 100644 --- a/scripts/auto_release/main.py +++ b/scripts/auto_release/main.py @@ -129,6 +129,8 @@ def stable_version_plus(add_content): return f'{num[0]}.{int(num[1]) + 1}.0' elif flag[2]: return f'{num[0]}.{num[1]}.{int(num[2]) + 1}' + else: + return '0.0.0' def edit_version(add_content): From fde226eacd19835fcb77116cb92d25dfe7b64f28 Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Fri, 30 Jul 2021 14:58:17 +0800 Subject: [PATCH 06/58] Update PythonSdkLiveTest.yml for Azure Pipelines Add `ISSUE_LINK` --- scripts/auto_release/PythonSdkLiveTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index 65d13c0a1ffb..f0f877f423f1 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -72,7 +72,7 @@ jobs: --user "anything:$(USR_TOKEN)" \ -d "{\ \"title\":\"[AutoRelease] $new_branch(Do not merge)\",\ - \"body\":\"$test_result Please Add the link issue \",\ + \"body\":\"$test_result $(ISSUE_LINK) \",\ \"head\":\"$(USR_NAME):$new_branch\",\ \"base\":\"$target_branch\"\ }" \ From 3b6d90716be70997cfdf822fb4615e960ed05f90 Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Fri, 30 Jul 2021 16:53:12 +0800 Subject: [PATCH 07/58] Update PythonSdkLiveTest.yml for Azure Pipelines --- scripts/auto_release/PythonSdkLiveTest.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index f0f877f423f1..0eca3f254e26 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -23,6 +23,11 @@ jobs: addToPath: true architecture: 'x64' - bash: | + # verify $ISSUE_LINK and $BASE_BRANCH is not null + if [ ! "$BASE_BRANCH" || "$ISSUE_LINK" ]; then + echo "$ISSUE_LINK or $BASE_BRANCH do not exist, pipeline fail!!!" + exit 1 + fi script_path=$(pwd)/scripts/auto_release cd .. git config --global user.email "PythonSdkPipelines" @@ -82,6 +87,6 @@ jobs: # if test fail, still push and crete PR. But pipeline would fail to remind user if [ -f "$output_path/live_test_fail.txt" ]; then - echo "please fix failure test!!! \'[AutoRelease] $new_branch \' has been created!!!" + echo "please fix failure test $(ISSUE_LINK)!!! \'[AutoRelease] $new_branch \' has been created!!!" exit 1 fi \ No newline at end of file From 168e62758e83778de084ece20fd3285f2fa4162a Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Fri, 30 Jul 2021 17:06:20 +0800 Subject: [PATCH 08/58] Update PythonSdkLiveTest.yml for Azure Pipelines --- scripts/auto_release/PythonSdkLiveTest.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index 0eca3f254e26..ddc48738e679 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -24,8 +24,8 @@ jobs: architecture: 'x64' - bash: | # verify $ISSUE_LINK and $BASE_BRANCH is not null - if [ ! "$BASE_BRANCH" || "$ISSUE_LINK" ]; then - echo "$ISSUE_LINK or $BASE_BRANCH do not exist, pipeline fail!!!" + if [! "$BASE_BRANCH" || ! "$ISSUE_LINK" ]; then + echo "ISSUE_LINK or BASE_BRANCH do not exist, pipeline fail!!!" exit 1 fi script_path=$(pwd)/scripts/auto_release From ca785239f6032687f6d6884d3f12f2f6853f4914 Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Fri, 30 Jul 2021 17:32:43 +0800 Subject: [PATCH 09/58] Update PythonSdkLiveTest.yml for Azure Pipelines --- scripts/auto_release/PythonSdkLiveTest.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index ddc48738e679..6089171aa982 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -25,9 +25,11 @@ jobs: - bash: | # verify $ISSUE_LINK and $BASE_BRANCH is not null if [! "$BASE_BRANCH" || ! "$ISSUE_LINK" ]; then + echo "$BASE_BRANCH ++ $ISSUE_LINK" echo "ISSUE_LINK or BASE_BRANCH do not exist, pipeline fail!!!" exit 1 fi + script_path=$(pwd)/scripts/auto_release cd .. git config --global user.email "PythonSdkPipelines" From 07003453e5869083aed5cd73e1a8e057c9661dc7 Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Fri, 30 Jul 2021 17:37:32 +0800 Subject: [PATCH 10/58] Update PythonSdkLiveTest.yml for Azure Pipelines --- scripts/auto_release/PythonSdkLiveTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index 6089171aa982..a85d2851094e 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -24,7 +24,7 @@ jobs: architecture: 'x64' - bash: | # verify $ISSUE_LINK and $BASE_BRANCH is not null - if [! "$BASE_BRANCH" || ! "$ISSUE_LINK" ]; then + if [(!"$BASE_BRANCH") || (!"$ISSUE_LINK") ]; then echo "$BASE_BRANCH ++ $ISSUE_LINK" echo "ISSUE_LINK or BASE_BRANCH do not exist, pipeline fail!!!" exit 1 From 3dab4e055d56051e92d0ad416b075c68ce50b69b Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Fri, 30 Jul 2021 17:48:23 +0800 Subject: [PATCH 11/58] Update PythonSdkLiveTest.yml for Azure Pipelines --- scripts/auto_release/PythonSdkLiveTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index a85d2851094e..fe15a883caa2 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -24,7 +24,7 @@ jobs: architecture: 'x64' - bash: | # verify $ISSUE_LINK and $BASE_BRANCH is not null - if [(!"$BASE_BRANCH") || (!"$ISSUE_LINK") ]; then + if [[!"$BASE_BRANCH"] || [!"$ISSUE_LINK"]]; then echo "$BASE_BRANCH ++ $ISSUE_LINK" echo "ISSUE_LINK or BASE_BRANCH do not exist, pipeline fail!!!" exit 1 From e2632a6a8fec5a07a966af267fab124354d3aaac Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Mon, 2 Aug 2021 09:33:56 +0800 Subject: [PATCH 12/58] Update PythonSdkLiveTest.yml for Azure Pipelines --- scripts/auto_release/PythonSdkLiveTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index fe15a883caa2..fadd3d7b57a9 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -24,7 +24,7 @@ jobs: architecture: 'x64' - bash: | # verify $ISSUE_LINK and $BASE_BRANCH is not null - if [[!"$BASE_BRANCH"] || [!"$ISSUE_LINK"]]; then + if [[! -n "$BASE_BRANCH"] || [! -n "$ISSUE_LINK"]]; then echo "$BASE_BRANCH ++ $ISSUE_LINK" echo "ISSUE_LINK or BASE_BRANCH do not exist, pipeline fail!!!" exit 1 From 89948fc2ca84ca4eed80cacb15f9f700fea5adaf Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Mon, 2 Aug 2021 09:40:08 +0800 Subject: [PATCH 13/58] Update PythonSdkLiveTest.yml for Azure Pipelines --- scripts/auto_release/PythonSdkLiveTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index fadd3d7b57a9..9fb26b875d30 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -24,7 +24,7 @@ jobs: architecture: 'x64' - bash: | # verify $ISSUE_LINK and $BASE_BRANCH is not null - if [[! -n "$BASE_BRANCH"] || [! -n "$ISSUE_LINK"]]; then + if [[ -z "$BASE_BRANCH" ] || [ -z "$ISSUE_LINK" ]]; then echo "$BASE_BRANCH ++ $ISSUE_LINK" echo "ISSUE_LINK or BASE_BRANCH do not exist, pipeline fail!!!" exit 1 From 0121ce6f25c5e8176fb2fc534364d24d14639435 Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Mon, 2 Aug 2021 09:51:06 +0800 Subject: [PATCH 14/58] Update PythonSdkLiveTest.yml for Azure Pipelines --- scripts/auto_release/PythonSdkLiveTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index 9fb26b875d30..a2011606b59a 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -24,7 +24,7 @@ jobs: architecture: 'x64' - bash: | # verify $ISSUE_LINK and $BASE_BRANCH is not null - if [[ -z "$BASE_BRANCH" ] || [ -z "$ISSUE_LINK" ]]; then + if [[ ! $BASE_BRANCH ] || [ ! $ISSUE_LINK ]]; then echo "$BASE_BRANCH ++ $ISSUE_LINK" echo "ISSUE_LINK or BASE_BRANCH do not exist, pipeline fail!!!" exit 1 From 9f7fc8156f085d726807e2174efaa99b48814d7e Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Mon, 2 Aug 2021 09:55:09 +0800 Subject: [PATCH 15/58] Update PythonSdkLiveTest.yml for Azure Pipelines --- scripts/auto_release/PythonSdkLiveTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index a2011606b59a..ef3aa1356ddb 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -24,7 +24,7 @@ jobs: architecture: 'x64' - bash: | # verify $ISSUE_LINK and $BASE_BRANCH is not null - if [[ ! $BASE_BRANCH ] || [ ! $ISSUE_LINK ]]; then + if [[ "$BASE_BRANCH"=="" ] || [ $ISSUE_LINK=="" ]]; then echo "$BASE_BRANCH ++ $ISSUE_LINK" echo "ISSUE_LINK or BASE_BRANCH do not exist, pipeline fail!!!" exit 1 From a583a2c2a084d8f37abee1e9e7efa88cf74707c0 Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Mon, 2 Aug 2021 10:00:02 +0800 Subject: [PATCH 16/58] Update PythonSdkLiveTest.yml for Azure Pipelines --- scripts/auto_release/PythonSdkLiveTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index ef3aa1356ddb..f3418d2c3059 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -24,7 +24,7 @@ jobs: architecture: 'x64' - bash: | # verify $ISSUE_LINK and $BASE_BRANCH is not null - if [[ "$BASE_BRANCH"=="" ] || [ $ISSUE_LINK=="" ]]; then + if [[ "$BASE_BRANCH" == "" ] || [ $ISSUE_LINK == "" ]]; then echo "$BASE_BRANCH ++ $ISSUE_LINK" echo "ISSUE_LINK or BASE_BRANCH do not exist, pipeline fail!!!" exit 1 From 0180ebcb3f4df50cb0be2e29b48219bf3d2b97a4 Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Mon, 2 Aug 2021 10:04:57 +0800 Subject: [PATCH 17/58] Update PythonSdkLiveTest.yml for Azure Pipelines --- scripts/auto_release/PythonSdkLiveTest.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index f3418d2c3059..90cc40a77b06 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -24,8 +24,8 @@ jobs: architecture: 'x64' - bash: | # verify $ISSUE_LINK and $BASE_BRANCH is not null - if [[ "$BASE_BRANCH" == "" ] || [ $ISSUE_LINK == "" ]]; then - echo "$BASE_BRANCH ++ $ISSUE_LINK" + if [[ "$(BASE_BRANCH)" == "" ] || [ $(ISSUE_LINK) == "" ]]; then + echo "$(BASE_BRANCH) ++ $(ISSUE_LINK)" echo "ISSUE_LINK or BASE_BRANCH do not exist, pipeline fail!!!" exit 1 fi From 1e52eb83038a079cf51f847b772ee091fe2e65ff Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Mon, 2 Aug 2021 10:08:09 +0800 Subject: [PATCH 18/58] Update PythonSdkLiveTest.yml for Azure Pipelines --- scripts/auto_release/PythonSdkLiveTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index 90cc40a77b06..075622c1ac6e 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -24,7 +24,7 @@ jobs: architecture: 'x64' - bash: | # verify $ISSUE_LINK and $BASE_BRANCH is not null - if [[ "$(BASE_BRANCH)" == "" ] || [ $(ISSUE_LINK) == "" ]]; then + if [[ -z $(BASE_BRANCH) ] || [ -z $(ISSUE_LINK) ]]; then echo "$(BASE_BRANCH) ++ $(ISSUE_LINK)" echo "ISSUE_LINK or BASE_BRANCH do not exist, pipeline fail!!!" exit 1 From 1207e83134a5d45cca7a89b167774f385504851c Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Mon, 2 Aug 2021 10:14:50 +0800 Subject: [PATCH 19/58] Update PythonSdkLiveTest.yml for Azure Pipelines --- scripts/auto_release/PythonSdkLiveTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index 075622c1ac6e..1a32bc0e6fb0 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -24,7 +24,7 @@ jobs: architecture: 'x64' - bash: | # verify $ISSUE_LINK and $BASE_BRANCH is not null - if [[ -z $(BASE_BRANCH) ] || [ -z $(ISSUE_LINK) ]]; then + if [[ "$(BASE_BRANCH)" = "" ] || [ "$(ISSUE_LINK)" = "" ]]; then echo "$(BASE_BRANCH) ++ $(ISSUE_LINK)" echo "ISSUE_LINK or BASE_BRANCH do not exist, pipeline fail!!!" exit 1 From a97138155326bbad8d60f189373a3e8fd7dcf542 Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Mon, 2 Aug 2021 10:19:00 +0800 Subject: [PATCH 20/58] Update PythonSdkLiveTest.yml for Azure Pipelines --- scripts/auto_release/PythonSdkLiveTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index 1a32bc0e6fb0..aec1edab1957 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -24,7 +24,7 @@ jobs: architecture: 'x64' - bash: | # verify $ISSUE_LINK and $BASE_BRANCH is not null - if [[ "$(BASE_BRANCH)" = "" ] || [ "$(ISSUE_LINK)" = "" ]]; then + if [ "$(BASE_BRANCH)" = "" -o "$(ISSUE_LINK)" = "" ]; then echo "$(BASE_BRANCH) ++ $(ISSUE_LINK)" echo "ISSUE_LINK or BASE_BRANCH do not exist, pipeline fail!!!" exit 1 From 687521d50b483ec1fd4f3d316d4a3153f5551c80 Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Mon, 2 Aug 2021 10:23:30 +0800 Subject: [PATCH 21/58] Update PythonSdkLiveTest.yml for Azure Pipelines --- scripts/auto_release/PythonSdkLiveTest.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index aec1edab1957..89f6e3939223 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -24,8 +24,7 @@ jobs: architecture: 'x64' - bash: | # verify $ISSUE_LINK and $BASE_BRANCH is not null - if [ "$(BASE_BRANCH)" = "" -o "$(ISSUE_LINK)" = "" ]; then - echo "$(BASE_BRANCH) ++ $(ISSUE_LINK)" + if [ -z "$(BASE_BRANCH)" -o -z "$(ISSUE_LINK)" ]; then echo "ISSUE_LINK or BASE_BRANCH do not exist, pipeline fail!!!" exit 1 fi From d17a10dd1f885dc167232b298aeb6d1c83e47abb Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Mon, 2 Aug 2021 11:05:06 +0800 Subject: [PATCH 22/58] Update PythonSdkLiveTest.yml for Azure Pipelines --- scripts/auto_release/PythonSdkLiveTest.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index 89f6e3939223..162a8ebd8451 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -71,6 +71,7 @@ jobs: test_result="Live test fail, detailed info is in pipeline log(search keyword FAILED)!!!\n" fi + echo "--- $output_path/output.txt" # create PR new_branch=`sed -n '1p' $output_path/output.txt` target_branch=`sed -n '2p' $output_path/output.txt` From cdcb633036018f3a001c538c13c15f9d65fe0050 Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Mon, 2 Aug 2021 13:25:22 +0800 Subject: [PATCH 23/58] Update PythonSdkLiveTest.yml for Azure Pipelines --- scripts/auto_release/PythonSdkLiveTest.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index 162a8ebd8451..672442b10934 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -72,6 +72,8 @@ jobs: fi echo "--- $output_path/output.txt" + echo $output_path/output.txt + echo "---" # create PR new_branch=`sed -n '1p' $output_path/output.txt` target_branch=`sed -n '2p' $output_path/output.txt` @@ -86,6 +88,7 @@ jobs: https://api.github.com/repos/Azure/azure-sdk-for-python/pulls echo "\'[AutoRelease] $new_branch \' has been created!!!" + echo "+++ $target_branch" # if test fail, still push and crete PR. But pipeline would fail to remind user if [ -f "$output_path/live_test_fail.txt" ]; then From 8fc128d3323ba3ca7d480483f10a117d75f032ed Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Mon, 2 Aug 2021 13:32:15 +0800 Subject: [PATCH 24/58] Update PythonSdkLiveTest.yml for Azure Pipelines --- scripts/auto_release/PythonSdkLiveTest.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index 672442b10934..8e8cc247cb36 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -72,7 +72,7 @@ jobs: fi echo "--- $output_path/output.txt" - echo $output_path/output.txt + more $output_path/output.txt echo "---" # create PR new_branch=`sed -n '1p' $output_path/output.txt` @@ -88,7 +88,6 @@ jobs: https://api.github.com/repos/Azure/azure-sdk-for-python/pulls echo "\'[AutoRelease] $new_branch \' has been created!!!" - echo "+++ $target_branch" # if test fail, still push and crete PR. But pipeline would fail to remind user if [ -f "$output_path/live_test_fail.txt" ]; then From 0f082422e3e63581157a5dfefaeec068923c04f9 Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Mon, 2 Aug 2021 14:05:01 +0800 Subject: [PATCH 25/58] Update PythonSdkLiveTest.yml for Azure Pipelines --- scripts/auto_release/PythonSdkLiveTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index 8e8cc247cb36..5e5c493c498d 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -72,7 +72,7 @@ jobs: fi echo "--- $output_path/output.txt" - more $output_path/output.txt + tail -n 300 $output_path/output.txt echo "---" # create PR new_branch=`sed -n '1p' $output_path/output.txt` From e2338e0323b3e11352a05bde8acb9846fb9a8906 Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Tue, 3 Aug 2021 11:37:41 +0800 Subject: [PATCH 26/58] Update PythonSdkLiveTest.yml for Azure Pipelines --- scripts/auto_release/PythonSdkLiveTest.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index 5e5c493c498d..99969e6704fa 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -81,7 +81,8 @@ jobs: --user "anything:$(USR_TOKEN)" \ -d "{\ \"title\":\"[AutoRelease] $new_branch(Do not merge)\",\ - \"body\":\"$test_result $(ISSUE_LINK) \",\ + # \"body\":\"$test_result $(ISSUE_LINK) \",\ + \"body\":\"$(ISSUE_LINK)\",\ \"head\":\"$(USR_NAME):$new_branch\",\ \"base\":\"$target_branch\"\ }" \ From ee09e27fab6494559040332fad204e79f964fcaf Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Wed, 4 Aug 2021 14:06:44 +0800 Subject: [PATCH 27/58] Update PythonSdkLiveTest.yml for Azure Pipelines --- scripts/auto_release/PythonSdkLiveTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index 99969e6704fa..95bf23634022 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -82,7 +82,7 @@ jobs: -d "{\ \"title\":\"[AutoRelease] $new_branch(Do not merge)\",\ # \"body\":\"$test_result $(ISSUE_LINK) \",\ - \"body\":\"$(ISSUE_LINK)\",\ + \"body\":\"[$(ISSUE_LINK)](url)\",\ \"head\":\"$(USR_NAME):$new_branch\",\ \"base\":\"$target_branch\"\ }" \ From 659c8b0daa237e9254d1f4c66c0fcf91cf8c3cc4 Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Wed, 4 Aug 2021 14:23:36 +0800 Subject: [PATCH 28/58] Update PythonSdkLiveTest.yml for Azure Pipelines --- scripts/auto_release/PythonSdkLiveTest.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index 95bf23634022..d6efaf4f5f1d 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -71,9 +71,6 @@ jobs: test_result="Live test fail, detailed info is in pipeline log(search keyword FAILED)!!!\n" fi - echo "--- $output_path/output.txt" - tail -n 300 $output_path/output.txt - echo "---" # create PR new_branch=`sed -n '1p' $output_path/output.txt` target_branch=`sed -n '2p' $output_path/output.txt` @@ -82,7 +79,7 @@ jobs: -d "{\ \"title\":\"[AutoRelease] $new_branch(Do not merge)\",\ # \"body\":\"$test_result $(ISSUE_LINK) \",\ - \"body\":\"[$(ISSUE_LINK)](url)\",\ + \"body\":\"issue link \" [$(ISSUE_LINK)](url),\ \"head\":\"$(USR_NAME):$new_branch\",\ \"base\":\"$target_branch\"\ }" \ From 5e347852eaea74582d579e4af0e344ff2407a3d6 Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Wed, 4 Aug 2021 15:09:11 +0800 Subject: [PATCH 29/58] Update PythonSdkLiveTest.yml for Azure Pipelines --- scripts/auto_release/PythonSdkLiveTest.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index d6efaf4f5f1d..41af4909b5e6 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -78,14 +78,14 @@ jobs: --user "anything:$(USR_TOKEN)" \ -d "{\ \"title\":\"[AutoRelease] $new_branch(Do not merge)\",\ - # \"body\":\"$test_result $(ISSUE_LINK) \",\ - \"body\":\"issue link \" [$(ISSUE_LINK)](url),\ + \"body\":\"issue link $(ISSUE_LINK) \",\ \"head\":\"$(USR_NAME):$new_branch\",\ \"base\":\"$target_branch\"\ }" \ https://api.github.com/repos/Azure/azure-sdk-for-python/pulls echo "\'[AutoRelease] $new_branch \' has been created!!!" + # if test fail, still push and crete PR. But pipeline would fail to remind user if [ -f "$output_path/live_test_fail.txt" ]; then From 13ad08529b49bd731fcf83708cc80a683bf1fcdd Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Wed, 4 Aug 2021 17:17:13 +0800 Subject: [PATCH 30/58] Update livetest_package.txt --- scripts/auto_release/livetest_package.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/auto_release/livetest_package.txt b/scripts/auto_release/livetest_package.txt index 74fd8517c3fa..de12d164ad16 100644 --- a/scripts/auto_release/livetest_package.txt +++ b/scripts/auto_release/livetest_package.txt @@ -1,2 +1,2 @@ azure-identity -python-dotenv==0.15.0 \ No newline at end of file +python-dotenv==0.15.0 From 649fd15ed02c686d5e19b720eaf02546d54ffeb5 Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Wed, 4 Aug 2021 17:37:25 +0800 Subject: [PATCH 31/58] Create create_pr.py --- scripts/auto_release/livetest_package.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/auto_release/livetest_package.txt b/scripts/auto_release/livetest_package.txt index de12d164ad16..91e9a0d7efe3 100644 --- a/scripts/auto_release/livetest_package.txt +++ b/scripts/auto_release/livetest_package.txt @@ -1,2 +1,3 @@ azure-identity python-dotenv==0.15.0 +ghapi \ No newline at end of file From 79316272769f2a0f339e750097e3d15d396b72e7 Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Wed, 4 Aug 2021 17:45:32 +0800 Subject: [PATCH 32/58] Update PythonSdkLiveTest.yml for Azure Pipelines use python script tu create pr --- scripts/auto_release/PythonSdkLiveTest.yml | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index 41af4909b5e6..75e63e3c1bb1 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -74,18 +74,21 @@ jobs: # create PR new_branch=`sed -n '1p' $output_path/output.txt` target_branch=`sed -n '2p' $output_path/output.txt` - curl \ - --user "anything:$(USR_TOKEN)" \ - -d "{\ - \"title\":\"[AutoRelease] $new_branch(Do not merge)\",\ - \"body\":\"issue link $(ISSUE_LINK) \",\ - \"head\":\"$(USR_NAME):$new_branch\",\ - \"base\":\"$target_branch\"\ - }" \ - https://api.github.com/repos/Azure/azure-sdk-for-python/pulls + # curl \ + # --user "anything:$(USR_TOKEN)" \ + # -d "{\ + # \"title\":\"[AutoRelease] $new_branch(Do not merge)\",\ + # \"body\":\"issue link $(ISSUE_LINK) \",\ + # \"head\":\"$(USR_NAME):$new_branch\",\ + # \"base\":\"$target_branch\"\ + # }" \ + # https://api.github.com/repos/Azure/azure-sdk-for-python/pulls + + python $script_path/create_auto_release_pr.py "$(new_branch)" "$(target_branch)" $(USER_NAME) $(ISSUE_LINK) + echo "\'[AutoRelease] $new_branch \' has been created!!!" - + # if test fail, still push and crete PR. But pipeline would fail to remind user if [ -f "$output_path/live_test_fail.txt" ]; then From 6223585e59460eef32f74605db0800ef4f5ef7f5 Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Thu, 5 Aug 2021 09:33:00 +0800 Subject: [PATCH 33/58] Update PythonSdkLiveTest.yml for Azure Pipelines --- scripts/auto_release/PythonSdkLiveTest.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index 75e63e3c1bb1..4058db46523b 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -84,7 +84,11 @@ jobs: # }" \ # https://api.github.com/repos/Azure/azure-sdk-for-python/pulls - python $script_path/create_auto_release_pr.py "$(new_branch)" "$(target_branch)" $(USER_NAME) $(ISSUE_LINK) + python $script_path/create_auto_release_pr.py "$new_branch" "$target_branch" $USER_NAME $(ISSUE_LINK) + echo "new_branch: $new_branch" + echo "target_branch: $target_branch" + echo "USER_NAME: $USER_NAME" + echo "ISSUE_LINK: $(ISSUE_LINK)" echo "\'[AutoRelease] $new_branch \' has been created!!!" From bb9479ec30a781eb4a5d0816ad8fa2190861c8a4 Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Thu, 5 Aug 2021 09:43:34 +0800 Subject: [PATCH 34/58] create py --- .../auto_release/create_auto_release_pr.py | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 scripts/auto_release/create_auto_release_pr.py diff --git a/scripts/auto_release/create_auto_release_pr.py b/scripts/auto_release/create_auto_release_pr.py new file mode 100644 index 000000000000..db62b08f1ca1 --- /dev/null +++ b/scripts/auto_release/create_auto_release_pr.py @@ -0,0 +1,64 @@ +import os +import argparse +import logging + +from ghapi.all import GhApi + + +ISSUE_LINK = '' +PULL_NUMBER = 0 +NEW_BRANCH = '' +TARGET_BRANCH = '' + +_LOG = logging.getLogger() +USER_TOKEN = os.getenv('USER_TOKEN', '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') + + +def create_auto_release_pr(api): + pr_title = "[AutoRelease] {}(Do not merge)".format(NEW_BRANCH) + pr_head = "{}:{}".format(USER_NAME, NEW_BRANCH) + pr_base = TARGET_BRANCH + pr_body = "issue link {}".format(ISSUE_LINK) + + res_create = api.pulls.create(pr_title, pr_head, pr_base, pr_body) + print(res_create) + + +def get_pr_number(): + pass + + +def main(): + api = GhApi(owner='Azure', repo='azure-sdk-for-python', token=USER_TOKEN) + + pr = create_auto_release_pr(api) + return + + api.pulls.update(pull_number=20050, body='https://github.com/Azure/sdk-release-request/issues/1739') + # api.pulls.update(pull_number=PULL_NUMBER, body=ISSUE_LINK) + + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description='Add Issue link', + formatter_class=argparse.RawTextHelpFormatter) + + parser.add_argument("new_branch", help="new branch for SDK") + parser.add_argument("target_branch", help="target branch for SDK") + parser.add_argument("user_name", help="user name") + parser.add_argument("issue_link", help="issue link") + args = parser.parse_args() + + main_logger = logging.getLogger() + logging.basicConfig() + main_logger.setLevel(logging.INFO) + + NEW_BRANCH = args.new_branch + TARGET_BRANCH = args.target_branch + USER_NAME = args.user_name + ISSUE_LINK = args.issue_link + + + main() +# python create_auto_release_pr.py "$(new_branch)" "$(target_branch)" $USER_NAME $ISSUE_LINK From a4ef616a5af862df9ac22fab775db7f6b7e06810 Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Thu, 5 Aug 2021 09:51:12 +0800 Subject: [PATCH 35/58] Update PythonSdkLiveTest.yml for Azure Pipelines --- scripts/auto_release/PythonSdkLiveTest.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index 4058db46523b..3e9de94f0cef 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -84,10 +84,10 @@ jobs: # }" \ # https://api.github.com/repos/Azure/azure-sdk-for-python/pulls - python $script_path/create_auto_release_pr.py "$new_branch" "$target_branch" $USER_NAME $(ISSUE_LINK) + python $script_path/create_auto_release_pr.py "$new_branch" "$target_branch" $USR_NAME $(ISSUE_LINK) echo "new_branch: $new_branch" echo "target_branch: $target_branch" - echo "USER_NAME: $USER_NAME" + echo "USER_NAME: $USR_NAME" echo "ISSUE_LINK: $(ISSUE_LINK)" From 29a7d79aedbe654441f85fc6ab6c0a82430b65f9 Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Thu, 5 Aug 2021 10:10:00 +0800 Subject: [PATCH 36/58] Update token --- scripts/auto_release/create_auto_release_pr.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/auto_release/create_auto_release_pr.py b/scripts/auto_release/create_auto_release_pr.py index db62b08f1ca1..3b090b48aed8 100644 --- a/scripts/auto_release/create_auto_release_pr.py +++ b/scripts/auto_release/create_auto_release_pr.py @@ -4,14 +4,13 @@ from ghapi.all import GhApi - ISSUE_LINK = '' PULL_NUMBER = 0 NEW_BRANCH = '' TARGET_BRANCH = '' _LOG = logging.getLogger() -USER_TOKEN = os.getenv('USER_TOKEN', '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') +USER_TOKEN = os.getenv('USR_ TOKEN') def create_auto_release_pr(api): @@ -38,7 +37,6 @@ def main(): # api.pulls.update(pull_number=PULL_NUMBER, body=ISSUE_LINK) - if __name__ == '__main__': parser = argparse.ArgumentParser( description='Add Issue link', @@ -59,6 +57,5 @@ def main(): USER_NAME = args.user_name ISSUE_LINK = args.issue_link - main() # python create_auto_release_pr.py "$(new_branch)" "$(target_branch)" $USER_NAME $ISSUE_LINK From cd99e89502e96489cbcf9ed7321b793a94476031 Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Thu, 5 Aug 2021 10:23:56 +0800 Subject: [PATCH 37/58] Update token --- scripts/auto_release/create_auto_release_pr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/auto_release/create_auto_release_pr.py b/scripts/auto_release/create_auto_release_pr.py index 3b090b48aed8..29f223d9a117 100644 --- a/scripts/auto_release/create_auto_release_pr.py +++ b/scripts/auto_release/create_auto_release_pr.py @@ -10,7 +10,7 @@ TARGET_BRANCH = '' _LOG = logging.getLogger() -USER_TOKEN = os.getenv('USR_ TOKEN') +USER_TOKEN = os.getenv('USR_TOKEN') def create_auto_release_pr(api): From e94db39681f458437466e3ac0db4d60fe7daa473 Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Thu, 5 Aug 2021 11:01:12 +0800 Subject: [PATCH 38/58] test create_pr --- scripts/auto_release/create_auto_release_pr.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/auto_release/create_auto_release_pr.py b/scripts/auto_release/create_auto_release_pr.py index 29f223d9a117..0fa379ccce40 100644 --- a/scripts/auto_release/create_auto_release_pr.py +++ b/scripts/auto_release/create_auto_release_pr.py @@ -1,6 +1,7 @@ import os import argparse import logging +import sys from ghapi.all import GhApi From 0c078654523037e7830e4bdba7a637f3336fb5e2 Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Thu, 5 Aug 2021 14:52:49 +0800 Subject: [PATCH 39/58] Update PythonSdkLiveTest.yml for Azure Pipelines --- scripts/auto_release/PythonSdkLiveTest.yml | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index 3e9de94f0cef..0c224fbde9ff 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -74,21 +74,21 @@ jobs: # create PR new_branch=`sed -n '1p' $output_path/output.txt` target_branch=`sed -n '2p' $output_path/output.txt` - # curl \ - # --user "anything:$(USR_TOKEN)" \ - # -d "{\ - # \"title\":\"[AutoRelease] $new_branch(Do not merge)\",\ - # \"body\":\"issue link $(ISSUE_LINK) \",\ - # \"head\":\"$(USR_NAME):$new_branch\",\ - # \"base\":\"$target_branch\"\ - # }" \ - # https://api.github.com/repos/Azure/azure-sdk-for-python/pulls - - python $script_path/create_auto_release_pr.py "$new_branch" "$target_branch" $USR_NAME $(ISSUE_LINK) - echo "new_branch: $new_branch" - echo "target_branch: $target_branch" - echo "USER_NAME: $USR_NAME" - echo "ISSUE_LINK: $(ISSUE_LINK)" + curl \ + --user "anything:$(UPDATE_TOKEN)" \ + -d "{\ + \"title\":\"[AutoRelease] $new_branch(Do not merge)\",\ + \"body\":\"issue link $(ISSUE_LINK) \",\ + \"head\":\"$(USR_NAME):$new_branch\",\ + \"base\":\"$target_branch\"\ + }" \ + https://api.github.com/repos/Azure/azure-sdk-for-python/pulls + + # python $script_path/create_auto_release_pr.py "$new_branch" "$target_branch" $USR_NAME $(ISSUE_LINK) + # echo "new_branch: $new_branch" + # echo "target_branch: $target_branch" + # echo "USER_NAME: $USR_NAME" + # echo "ISSUE_LINK: $(ISSUE_LINK)" echo "\'[AutoRelease] $new_branch \' has been created!!!" From 65c40db6c17c7ec34d240ede1214225529221bca Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Thu, 5 Aug 2021 15:46:12 +0800 Subject: [PATCH 40/58] Update create_pr.py --- .../auto_release/create_auto_release_pr.py | 58 +++++-------------- 1 file changed, 14 insertions(+), 44 deletions(-) diff --git a/scripts/auto_release/create_auto_release_pr.py b/scripts/auto_release/create_auto_release_pr.py index 0fa379ccce40..e38ff6de0b18 100644 --- a/scripts/auto_release/create_auto_release_pr.py +++ b/scripts/auto_release/create_auto_release_pr.py @@ -1,62 +1,32 @@ import os -import argparse -import logging -import sys from ghapi.all import GhApi -ISSUE_LINK = '' -PULL_NUMBER = 0 -NEW_BRANCH = '' -TARGET_BRANCH = '' - -_LOG = logging.getLogger() -USER_TOKEN = os.getenv('USR_TOKEN') - +NEW_BRANCH = os.getenv('NEW_BRANCH') +TARGET_BRANCH = os.getenv('TARGET_BRANCH') +ISSUE_LINK = os.getenv('ISSUE_LINK') +# Generate PR for auto release SDK def create_auto_release_pr(api): pr_title = "[AutoRelease] {}(Do not merge)".format(NEW_BRANCH) - pr_head = "{}:{}".format(USER_NAME, NEW_BRANCH) + pr_head = "{}:{}".format(os.getenv('USR_NAME'), NEW_BRANCH) pr_base = TARGET_BRANCH - pr_body = "issue link {}".format(ISSUE_LINK) - + pr_body = "issue link:" res_create = api.pulls.create(pr_title, pr_head, pr_base, pr_body) - print(res_create) + return res_create.number -def get_pr_number(): - pass +# Change the PR body to the issue link +def update_auto_release_pr(api, pr_number): + api.pulls.update(pull_number=pr_number, body='issue link:{}'.format(ISSUE_LINK)) def main(): - api = GhApi(owner='Azure', repo='azure-sdk-for-python', token=USER_TOKEN) - - pr = create_auto_release_pr(api) - return - - api.pulls.update(pull_number=20050, body='https://github.com/Azure/sdk-release-request/issues/1739') - # api.pulls.update(pull_number=PULL_NUMBER, body=ISSUE_LINK) + api = GhApi(owner='Azure', repo='azure-sdk-for-python', token=os.getenv('USR_TOKEN')) + pr_number = create_auto_release_pr(api) + api = GhApi(owner='Azure', repo='azure-sdk-for-python', token=os.getenv('UPDATE_TOKEN')) + update_auto_release_pr(api, pr_number) if __name__ == '__main__': - parser = argparse.ArgumentParser( - description='Add Issue link', - formatter_class=argparse.RawTextHelpFormatter) - - parser.add_argument("new_branch", help="new branch for SDK") - parser.add_argument("target_branch", help="target branch for SDK") - parser.add_argument("user_name", help="user name") - parser.add_argument("issue_link", help="issue link") - args = parser.parse_args() - - main_logger = logging.getLogger() - logging.basicConfig() - main_logger.setLevel(logging.INFO) - - NEW_BRANCH = args.new_branch - TARGET_BRANCH = args.target_branch - USER_NAME = args.user_name - ISSUE_LINK = args.issue_link - main() -# python create_auto_release_pr.py "$(new_branch)" "$(target_branch)" $USER_NAME $ISSUE_LINK From 9c6bd40d64563c10651c2995037e90b2d280712f Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Thu, 5 Aug 2021 15:49:18 +0800 Subject: [PATCH 41/58] Update PythonSdkLiveTest.yml for Azure Pipelines --- scripts/auto_release/PythonSdkLiveTest.yml | 38 ++++++++++++---------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index 0c224fbde9ff..a2ad06e857f5 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -72,23 +72,27 @@ jobs: fi # create PR - new_branch=`sed -n '1p' $output_path/output.txt` - target_branch=`sed -n '2p' $output_path/output.txt` - curl \ - --user "anything:$(UPDATE_TOKEN)" \ - -d "{\ - \"title\":\"[AutoRelease] $new_branch(Do not merge)\",\ - \"body\":\"issue link $(ISSUE_LINK) \",\ - \"head\":\"$(USR_NAME):$new_branch\",\ - \"base\":\"$target_branch\"\ - }" \ - https://api.github.com/repos/Azure/azure-sdk-for-python/pulls - - # python $script_path/create_auto_release_pr.py "$new_branch" "$target_branch" $USR_NAME $(ISSUE_LINK) - # echo "new_branch: $new_branch" - # echo "target_branch: $target_branch" - # echo "USER_NAME: $USR_NAME" - # echo "ISSUE_LINK: $(ISSUE_LINK)" + export NEW_BRANCH=`sed -n '1p' $output_path/output.txt` + export TARGET_BRANCH=`sed -n '2p' $output_path/output.txt` + export ISSUE_LINK=$(ISSUE_LINK) + export USR_NAME=$(USR_NAME) + export USR_TOKEN=$(USR_TOKEN) + export UPDATE_TOKEN=$(UPDATE_TOKEN) + # curl \ + # --user "anything:$(UPDATE_TOKEN)" \ + # -d "{\ + # \"title\":\"[AutoRelease] $new_branch(Do not merge)\",\ + # \"body\":\"issue link $(ISSUE_LINK) \",\ + # \"head\":\"$(USR_NAME):$new_branch\",\ + # \"base\":\"$target_branch\"\ + # }" \ + # https://api.github.com/repos/Azure/azure-sdk-for-python/pulls + + python $script_path/create_auto_release_pr.py + echo "new_branch: $new_branch" + echo "target_branch: $target_branch" + echo "USER_NAME: $USR_NAME" + echo "ISSUE_LINK: $(ISSUE_LINK)" echo "\'[AutoRelease] $new_branch \' has been created!!!" From 9b1e845db5785aec8c4310b345f27721ff778601 Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Thu, 5 Aug 2021 15:57:10 +0800 Subject: [PATCH 42/58] Update PythonSdkLiveTest.yml for Azure Pipelines --- scripts/auto_release/PythonSdkLiveTest.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index a2ad06e857f5..e808aa7900a4 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -24,10 +24,10 @@ jobs: architecture: 'x64' - bash: | # verify $ISSUE_LINK and $BASE_BRANCH is not null - if [ -z "$(BASE_BRANCH)" -o -z "$(ISSUE_LINK)" ]; then - echo "ISSUE_LINK or BASE_BRANCH do not exist, pipeline fail!!!" - exit 1 - fi + # if [ -z "$(BASE_BRANCH)" -o -z "$(ISSUE_LINK)" ]; then + # echo "ISSUE_LINK or BASE_BRANCH do not exist, pipeline fail!!!" + # exit 1 + # fi script_path=$(pwd)/scripts/auto_release cd .. From 9d770831033aa58c7a632a7ea46faf26792b487c Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Thu, 5 Aug 2021 17:06:49 +0800 Subject: [PATCH 43/58] Update PythonSdkLiveTest.yml for Azure Pipelines --- scripts/auto_release/PythonSdkLiveTest.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index e808aa7900a4..0905d0beecd3 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -23,11 +23,11 @@ jobs: addToPath: true architecture: 'x64' - bash: | - # verify $ISSUE_LINK and $BASE_BRANCH is not null - # if [ -z "$(BASE_BRANCH)" -o -z "$(ISSUE_LINK)" ]; then - # echo "ISSUE_LINK or BASE_BRANCH do not exist, pipeline fail!!!" - # exit 1 - # fi + verify $ISSUE_LINK and $BASE_BRANCH is not null + if [ -z "$(BASE_BRANCH)" -o -z "$(ISSUE_LINK)" ]; then + echo "ISSUE_LINK or BASE_BRANCH do not exist, pipeline fail!!!" + exit 1 + fi script_path=$(pwd)/scripts/auto_release cd .. From 9ca5f21390293193fe1214f0c89f436bd85635e8 Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Fri, 6 Aug 2021 10:40:44 +0800 Subject: [PATCH 44/58] add_comment --- scripts/auto_release/create_auto_release_pr.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/auto_release/create_auto_release_pr.py b/scripts/auto_release/create_auto_release_pr.py index e38ff6de0b18..051cf4173b1c 100644 --- a/scripts/auto_release/create_auto_release_pr.py +++ b/scripts/auto_release/create_auto_release_pr.py @@ -5,20 +5,21 @@ NEW_BRANCH = os.getenv('NEW_BRANCH') TARGET_BRANCH = os.getenv('TARGET_BRANCH') ISSUE_LINK = os.getenv('ISSUE_LINK') +TEST_RESULT = os.getenv('TEST_RESULT') # Generate PR for auto release SDK def create_auto_release_pr(api): pr_title = "[AutoRelease] {}(Do not merge)".format(NEW_BRANCH) pr_head = "{}:{}".format(os.getenv('USR_NAME'), NEW_BRANCH) pr_base = TARGET_BRANCH - pr_body = "issue link:" + pr_body = TEST_RESULT res_create = api.pulls.create(pr_title, pr_head, pr_base, pr_body) return res_create.number -# Change the PR body to the issue link -def update_auto_release_pr(api, pr_number): - api.pulls.update(pull_number=pr_number, body='issue link:{}'.format(ISSUE_LINK)) +# Add issue link on PR +def add_comment(api, pr_number): + api.issues.create_comment(pull_number=pr_number, body='issue link:{}'.format(ISSUE_LINK)) def main(): @@ -26,7 +27,7 @@ def main(): pr_number = create_auto_release_pr(api) api = GhApi(owner='Azure', repo='azure-sdk-for-python', token=os.getenv('UPDATE_TOKEN')) - update_auto_release_pr(api, pr_number) + add_comment(api, pr_number) if __name__ == '__main__': main() From 15022188944f366da8672d347c6a4895a328fea2 Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Fri, 6 Aug 2021 11:24:55 +0800 Subject: [PATCH 45/58] update by jf --- scripts/auto_release/create_auto_release_pr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/auto_release/create_auto_release_pr.py b/scripts/auto_release/create_auto_release_pr.py index 051cf4173b1c..70821516e9a0 100644 --- a/scripts/auto_release/create_auto_release_pr.py +++ b/scripts/auto_release/create_auto_release_pr.py @@ -19,7 +19,7 @@ def create_auto_release_pr(api): # Add issue link on PR def add_comment(api, pr_number): - api.issues.create_comment(pull_number=pr_number, body='issue link:{}'.format(ISSUE_LINK)) + api.issues.create_comment(issue_number=pr_number, body='issue link:{}'.format(ISSUE_LINK)) def main(): From 19aca39842c27c7754b8e68d9817d8805aa6b9db Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Fri, 6 Aug 2021 11:50:11 +0800 Subject: [PATCH 46/58] Update PythonSdkLiveTest.yml --- scripts/auto_release/PythonSdkLiveTest.yml | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index 0905d0beecd3..d8b899664611 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -66,7 +66,7 @@ jobs: exit 1 fi - test_result="" + test_result="Live test success" if [ -f "$output_path/live_test_fail.txt" ]; then test_result="Live test fail, detailed info is in pipeline log(search keyword FAILED)!!!\n" fi @@ -78,28 +78,14 @@ jobs: export USR_NAME=$(USR_NAME) export USR_TOKEN=$(USR_TOKEN) export UPDATE_TOKEN=$(UPDATE_TOKEN) - # curl \ - # --user "anything:$(UPDATE_TOKEN)" \ - # -d "{\ - # \"title\":\"[AutoRelease] $new_branch(Do not merge)\",\ - # \"body\":\"issue link $(ISSUE_LINK) \",\ - # \"head\":\"$(USR_NAME):$new_branch\",\ - # \"base\":\"$target_branch\"\ - # }" \ - # https://api.github.com/repos/Azure/azure-sdk-for-python/pulls + export TEST_RESULT=$test_result python $script_path/create_auto_release_pr.py - echo "new_branch: $new_branch" - echo "target_branch: $target_branch" - echo "USER_NAME: $USR_NAME" - echo "ISSUE_LINK: $(ISSUE_LINK)" - echo "\'[AutoRelease] $new_branch \' has been created!!!" - # if test fail, still push and crete PR. But pipeline would fail to remind user if [ -f "$output_path/live_test_fail.txt" ]; then echo "please fix failure test $(ISSUE_LINK)!!! \'[AutoRelease] $new_branch \' has been created!!!" exit 1 - fi \ No newline at end of file + fi From ecf0c4f1aacd4d4dd64018d2a17073e0872aa82c Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Fri, 6 Aug 2021 14:16:57 +0800 Subject: [PATCH 47/58] Update create_auto_release_pr --- scripts/auto_release/PythonSdkLiveTest.yml | 27 +++++++-------- .../auto_release/create_auto_release_pr.py | 33 +++++++++++++++++++ scripts/auto_release/livetest_package.txt | 3 +- 3 files changed, 47 insertions(+), 16 deletions(-) create mode 100644 scripts/auto_release/create_auto_release_pr.py diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index c57509e2776f..2d92b2a4d70f 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -23,12 +23,12 @@ jobs: addToPath: true architecture: 'x64' - bash: | - # verify $ISSUE_LINK and $BASE_BRANCH is not null + # verify $ISSUE_LINK and $BASE_BRANCH are not null if [ -z "$(BASE_BRANCH)" -o -z "$(ISSUE_LINK)" ]; then echo "ISSUE_LINK or BASE_BRANCH do not exist, pipeline fail!!!" exit 1 fi - + script_path=$(pwd)/scripts/auto_release cd .. git config --global user.email "PythonSdkPipelines" @@ -66,28 +66,25 @@ jobs: exit 1 fi - test_result="" + test_result="Live test success" if [ -f "$output_path/live_test_fail.txt" ]; then test_result="Live test fail, detailed info is in pipeline log(search keyword FAILED)!!!\n" fi # create PR - new_branch=`sed -n '1p' $output_path/output.txt` - target_branch=`sed -n '2p' $output_path/output.txt` - curl \ - --user "anything:$(USR_TOKEN)" \ - -d "{\ - \"title\":\"[AutoRelease] $new_branch(Do not merge)\",\ - \"body\":\"$test_result $(ISSUE_LINK) \",\ - \"head\":\"$(USR_NAME):$new_branch\",\ - \"base\":\"$target_branch\"\ - }" \ - https://api.github.com/repos/Azure/azure-sdk-for-python/pulls + export NEW_BRANCH=`sed -n '1p' $output_path/output.txt` + export TARGET_BRANCH=`sed -n '2p' $output_path/output.txt` + export ISSUE_LINK=$(ISSUE_LINK) + export USR_NAME=$(USR_NAME) + export USR_TOKEN=$(USR_TOKEN) + export UPDATE_TOKEN=$(UPDATE_TOKEN) + export TEST_RESULT=$test_result + python $script_path/create_auto_release_pr.py echo "\'[AutoRelease] $new_branch \' has been created!!!" # if test fail, still push and crete PR. But pipeline would fail to remind user if [ -f "$output_path/live_test_fail.txt" ]; then - echo "please fix failure test!!! $(ISSUE_LINK) \'[AutoRelease] $new_branch \' has been created!!!" + echo "please fix failure test $(ISSUE_LINK)!!! \'[AutoRelease] $new_branch \' has been created!!!" exit 1 fi diff --git a/scripts/auto_release/create_auto_release_pr.py b/scripts/auto_release/create_auto_release_pr.py new file mode 100644 index 000000000000..70821516e9a0 --- /dev/null +++ b/scripts/auto_release/create_auto_release_pr.py @@ -0,0 +1,33 @@ +import os + +from ghapi.all import GhApi + +NEW_BRANCH = os.getenv('NEW_BRANCH') +TARGET_BRANCH = os.getenv('TARGET_BRANCH') +ISSUE_LINK = os.getenv('ISSUE_LINK') +TEST_RESULT = os.getenv('TEST_RESULT') + +# Generate PR for auto release SDK +def create_auto_release_pr(api): + pr_title = "[AutoRelease] {}(Do not merge)".format(NEW_BRANCH) + pr_head = "{}:{}".format(os.getenv('USR_NAME'), NEW_BRANCH) + pr_base = TARGET_BRANCH + pr_body = TEST_RESULT + res_create = api.pulls.create(pr_title, pr_head, pr_base, pr_body) + + return res_create.number + +# Add issue link on PR +def add_comment(api, pr_number): + api.issues.create_comment(issue_number=pr_number, body='issue link:{}'.format(ISSUE_LINK)) + + +def main(): + api = GhApi(owner='Azure', repo='azure-sdk-for-python', token=os.getenv('USR_TOKEN')) + pr_number = create_auto_release_pr(api) + + api = GhApi(owner='Azure', repo='azure-sdk-for-python', token=os.getenv('UPDATE_TOKEN')) + add_comment(api, pr_number) + +if __name__ == '__main__': + main() diff --git a/scripts/auto_release/livetest_package.txt b/scripts/auto_release/livetest_package.txt index 74fd8517c3fa..91e9a0d7efe3 100644 --- a/scripts/auto_release/livetest_package.txt +++ b/scripts/auto_release/livetest_package.txt @@ -1,2 +1,3 @@ azure-identity -python-dotenv==0.15.0 \ No newline at end of file +python-dotenv==0.15.0 +ghapi \ No newline at end of file From 440fac1dab39bfa427b9e732124a90e3268a6119 Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Fri, 6 Aug 2021 14:50:10 +0800 Subject: [PATCH 48/58] Update create_auto_release_pr.py --- .../auto_release/create_auto_release_pr.py | 31 ++++++------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/scripts/auto_release/create_auto_release_pr.py b/scripts/auto_release/create_auto_release_pr.py index 70821516e9a0..3cac143f20ee 100644 --- a/scripts/auto_release/create_auto_release_pr.py +++ b/scripts/auto_release/create_auto_release_pr.py @@ -2,32 +2,19 @@ from ghapi.all import GhApi -NEW_BRANCH = os.getenv('NEW_BRANCH') -TARGET_BRANCH = os.getenv('TARGET_BRANCH') -ISSUE_LINK = os.getenv('ISSUE_LINK') -TEST_RESULT = os.getenv('TEST_RESULT') - -# Generate PR for auto release SDK -def create_auto_release_pr(api): - pr_title = "[AutoRelease] {}(Do not merge)".format(NEW_BRANCH) - pr_head = "{}:{}".format(os.getenv('USR_NAME'), NEW_BRANCH) - pr_base = TARGET_BRANCH - pr_body = TEST_RESULT - res_create = api.pulls.create(pr_title, pr_head, pr_base, pr_body) - - return res_create.number - -# Add issue link on PR -def add_comment(api, pr_number): - api.issues.create_comment(issue_number=pr_number, body='issue link:{}'.format(ISSUE_LINK)) - - def main(): + # Generate PR for auto release SDK api = GhApi(owner='Azure', repo='azure-sdk-for-python', token=os.getenv('USR_TOKEN')) - pr_number = create_auto_release_pr(api) + pr_title = "[AutoRelease] {}(Do not merge)".format(os.getenv('NEW_BRANCH')) + pr_head = "{}:{}".format(os.getenv('USR_NAME'), os.getenv('NEW_BRANCH')) + pr_base = os.getenv('TARGET_BRANCH') + pr_body = "{} {}".format(os.getenv('TEST_RESULT'), os.getenv('ISSUE_LINK')) + res_create = api.pulls.create(pr_title, pr_head, pr_base, pr_body) + pr_number = res_create.number + # Add issue link on PR api = GhApi(owner='Azure', repo='azure-sdk-for-python', token=os.getenv('UPDATE_TOKEN')) - add_comment(api, pr_number) + api.issues.create_comment(issue_number=pr_number, body='issue link:{}'.format(os.getenv('ISSUE_LINK'))) if __name__ == '__main__': main() From 6f822e8aab33ae48d726a33330a0771c4f8c3c8a Mon Sep 17 00:00:00 2001 From: msyyc <70930885+msyyc@users.noreply.github.com> Date: Fri, 6 Aug 2021 14:54:43 +0800 Subject: [PATCH 49/58] Update create_auto_release_pr.py --- scripts/auto_release/create_auto_release_pr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/auto_release/create_auto_release_pr.py b/scripts/auto_release/create_auto_release_pr.py index 3cac143f20ee..332ab6de7813 100644 --- a/scripts/auto_release/create_auto_release_pr.py +++ b/scripts/auto_release/create_auto_release_pr.py @@ -8,7 +8,7 @@ def main(): pr_title = "[AutoRelease] {}(Do not merge)".format(os.getenv('NEW_BRANCH')) pr_head = "{}:{}".format(os.getenv('USR_NAME'), os.getenv('NEW_BRANCH')) pr_base = os.getenv('TARGET_BRANCH') - pr_body = "{} {}".format(os.getenv('TEST_RESULT'), os.getenv('ISSUE_LINK')) + pr_body = "{} \n {}".format(os.getenv('ISSUE_LINK'), os.getenv('TEST_RESULT')) res_create = api.pulls.create(pr_title, pr_head, pr_base, pr_body) pr_number = res_create.number From 0828e76c9f77cedc341edb6cc362ebd4feba0b5d Mon Sep 17 00:00:00 2001 From: BigCat20196 <1095260342@qq.com> Date: Fri, 6 Aug 2021 15:12:41 +0800 Subject: [PATCH 50/58] Update yaml and py --- scripts/auto_release/PythonSdkLiveTest.yml | 23 +++----------- .../auto_release/create_auto_release_pr.py | 31 ++++++------------- 2 files changed, 13 insertions(+), 41 deletions(-) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index 0905d0beecd3..2d92b2a4d70f 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -23,7 +23,7 @@ jobs: addToPath: true architecture: 'x64' - bash: | - verify $ISSUE_LINK and $BASE_BRANCH is not null + # verify $ISSUE_LINK and $BASE_BRANCH are not null if [ -z "$(BASE_BRANCH)" -o -z "$(ISSUE_LINK)" ]; then echo "ISSUE_LINK or BASE_BRANCH do not exist, pipeline fail!!!" exit 1 @@ -66,7 +66,7 @@ jobs: exit 1 fi - test_result="" + test_result="Live test success" if [ -f "$output_path/live_test_fail.txt" ]; then test_result="Live test fail, detailed info is in pipeline log(search keyword FAILED)!!!\n" fi @@ -78,28 +78,13 @@ jobs: export USR_NAME=$(USR_NAME) export USR_TOKEN=$(USR_TOKEN) export UPDATE_TOKEN=$(UPDATE_TOKEN) - # curl \ - # --user "anything:$(UPDATE_TOKEN)" \ - # -d "{\ - # \"title\":\"[AutoRelease] $new_branch(Do not merge)\",\ - # \"body\":\"issue link $(ISSUE_LINK) \",\ - # \"head\":\"$(USR_NAME):$new_branch\",\ - # \"base\":\"$target_branch\"\ - # }" \ - # https://api.github.com/repos/Azure/azure-sdk-for-python/pulls + export TEST_RESULT=$test_result python $script_path/create_auto_release_pr.py - echo "new_branch: $new_branch" - echo "target_branch: $target_branch" - echo "USER_NAME: $USR_NAME" - echo "ISSUE_LINK: $(ISSUE_LINK)" - - echo "\'[AutoRelease] $new_branch \' has been created!!!" - # if test fail, still push and crete PR. But pipeline would fail to remind user if [ -f "$output_path/live_test_fail.txt" ]; then echo "please fix failure test $(ISSUE_LINK)!!! \'[AutoRelease] $new_branch \' has been created!!!" exit 1 - fi \ No newline at end of file + fi diff --git a/scripts/auto_release/create_auto_release_pr.py b/scripts/auto_release/create_auto_release_pr.py index 70821516e9a0..3cac143f20ee 100644 --- a/scripts/auto_release/create_auto_release_pr.py +++ b/scripts/auto_release/create_auto_release_pr.py @@ -2,32 +2,19 @@ from ghapi.all import GhApi -NEW_BRANCH = os.getenv('NEW_BRANCH') -TARGET_BRANCH = os.getenv('TARGET_BRANCH') -ISSUE_LINK = os.getenv('ISSUE_LINK') -TEST_RESULT = os.getenv('TEST_RESULT') - -# Generate PR for auto release SDK -def create_auto_release_pr(api): - pr_title = "[AutoRelease] {}(Do not merge)".format(NEW_BRANCH) - pr_head = "{}:{}".format(os.getenv('USR_NAME'), NEW_BRANCH) - pr_base = TARGET_BRANCH - pr_body = TEST_RESULT - res_create = api.pulls.create(pr_title, pr_head, pr_base, pr_body) - - return res_create.number - -# Add issue link on PR -def add_comment(api, pr_number): - api.issues.create_comment(issue_number=pr_number, body='issue link:{}'.format(ISSUE_LINK)) - - def main(): + # Generate PR for auto release SDK api = GhApi(owner='Azure', repo='azure-sdk-for-python', token=os.getenv('USR_TOKEN')) - pr_number = create_auto_release_pr(api) + pr_title = "[AutoRelease] {}(Do not merge)".format(os.getenv('NEW_BRANCH')) + pr_head = "{}:{}".format(os.getenv('USR_NAME'), os.getenv('NEW_BRANCH')) + pr_base = os.getenv('TARGET_BRANCH') + pr_body = "{} {}".format(os.getenv('TEST_RESULT'), os.getenv('ISSUE_LINK')) + res_create = api.pulls.create(pr_title, pr_head, pr_base, pr_body) + pr_number = res_create.number + # Add issue link on PR api = GhApi(owner='Azure', repo='azure-sdk-for-python', token=os.getenv('UPDATE_TOKEN')) - add_comment(api, pr_number) + api.issues.create_comment(issue_number=pr_number, body='issue link:{}'.format(os.getenv('ISSUE_LINK'))) if __name__ == '__main__': main() From de25f146d70c0d0e23761b5069afbbcac08bcef2 Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Fri, 6 Aug 2021 15:46:46 +0800 Subject: [PATCH 51/58] Update create_auto_release_pr.py --- scripts/auto_release/create_auto_release_pr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/auto_release/create_auto_release_pr.py b/scripts/auto_release/create_auto_release_pr.py index 332ab6de7813..d981459b6ee0 100644 --- a/scripts/auto_release/create_auto_release_pr.py +++ b/scripts/auto_release/create_auto_release_pr.py @@ -8,7 +8,7 @@ def main(): pr_title = "[AutoRelease] {}(Do not merge)".format(os.getenv('NEW_BRANCH')) pr_head = "{}:{}".format(os.getenv('USR_NAME'), os.getenv('NEW_BRANCH')) pr_base = os.getenv('TARGET_BRANCH') - pr_body = "{} \n {}".format(os.getenv('ISSUE_LINK'), os.getenv('TEST_RESULT')) + pr_body = "{} {}".format(os.getenv('ISSUE_LINK'), os.getenv('TEST_RESULT')) res_create = api.pulls.create(pr_title, pr_head, pr_base, pr_body) pr_number = res_create.number From 5446fd8fbbc3a83801263d9cc0d0eb3a4dcf604a Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Fri, 6 Aug 2021 15:55:37 +0800 Subject: [PATCH 52/58] Update create_auto_release_pr.py --- scripts/auto_release/create_auto_release_pr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/auto_release/create_auto_release_pr.py b/scripts/auto_release/create_auto_release_pr.py index d981459b6ee0..99391623fe25 100644 --- a/scripts/auto_release/create_auto_release_pr.py +++ b/scripts/auto_release/create_auto_release_pr.py @@ -8,7 +8,7 @@ def main(): pr_title = "[AutoRelease] {}(Do not merge)".format(os.getenv('NEW_BRANCH')) pr_head = "{}:{}".format(os.getenv('USR_NAME'), os.getenv('NEW_BRANCH')) pr_base = os.getenv('TARGET_BRANCH') - pr_body = "{} {}".format(os.getenv('ISSUE_LINK'), os.getenv('TEST_RESULT')) + pr_body = "{} \n{}".format(os.getenv('ISSUE_LINK'), os.getenv('TEST_RESULT')) res_create = api.pulls.create(pr_title, pr_head, pr_base, pr_body) pr_number = res_create.number From 26f0dd0a8eda6f3416e5db0d60018466fda05d52 Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Mon, 9 Aug 2021 10:14:03 +0800 Subject: [PATCH 53/58] Update create_auto_release_pr.py --- scripts/auto_release/create_auto_release_pr.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/scripts/auto_release/create_auto_release_pr.py b/scripts/auto_release/create_auto_release_pr.py index 99391623fe25..9f1ef8f0d2ad 100644 --- a/scripts/auto_release/create_auto_release_pr.py +++ b/scripts/auto_release/create_auto_release_pr.py @@ -9,12 +9,7 @@ def main(): pr_head = "{}:{}".format(os.getenv('USR_NAME'), os.getenv('NEW_BRANCH')) pr_base = os.getenv('TARGET_BRANCH') pr_body = "{} \n{}".format(os.getenv('ISSUE_LINK'), os.getenv('TEST_RESULT')) - res_create = api.pulls.create(pr_title, pr_head, pr_base, pr_body) - pr_number = res_create.number - - # Add issue link on PR - api = GhApi(owner='Azure', repo='azure-sdk-for-python', token=os.getenv('UPDATE_TOKEN')) - api.issues.create_comment(issue_number=pr_number, body='issue link:{}'.format(os.getenv('ISSUE_LINK'))) + api.pulls.create(pr_title, pr_head, pr_base, pr_body) if __name__ == '__main__': main() From d7f2405c815d5d57ecf7e07a3e8d441eb55ed2c3 Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Mon, 9 Aug 2021 10:15:31 +0800 Subject: [PATCH 54/58] Update PythonSdkLiveTest.yml --- scripts/auto_release/PythonSdkLiveTest.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index 2d92b2a4d70f..d5fab7b46809 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -77,7 +77,6 @@ jobs: export ISSUE_LINK=$(ISSUE_LINK) export USR_NAME=$(USR_NAME) export USR_TOKEN=$(USR_TOKEN) - export UPDATE_TOKEN=$(UPDATE_TOKEN) export TEST_RESULT=$test_result python $script_path/create_auto_release_pr.py From b44daf8b241bf159e2d6d7b8afcf8bbd4eb01bba Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Mon, 9 Aug 2021 14:55:10 +0800 Subject: [PATCH 55/58] Update create_auto_release_pr.py --- scripts/auto_release/create_auto_release_pr.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/auto_release/create_auto_release_pr.py b/scripts/auto_release/create_auto_release_pr.py index 9f1ef8f0d2ad..99391623fe25 100644 --- a/scripts/auto_release/create_auto_release_pr.py +++ b/scripts/auto_release/create_auto_release_pr.py @@ -9,7 +9,12 @@ def main(): pr_head = "{}:{}".format(os.getenv('USR_NAME'), os.getenv('NEW_BRANCH')) pr_base = os.getenv('TARGET_BRANCH') pr_body = "{} \n{}".format(os.getenv('ISSUE_LINK'), os.getenv('TEST_RESULT')) - api.pulls.create(pr_title, pr_head, pr_base, pr_body) + res_create = api.pulls.create(pr_title, pr_head, pr_base, pr_body) + pr_number = res_create.number + + # Add issue link on PR + api = GhApi(owner='Azure', repo='azure-sdk-for-python', token=os.getenv('UPDATE_TOKEN')) + api.issues.create_comment(issue_number=pr_number, body='issue link:{}'.format(os.getenv('ISSUE_LINK'))) if __name__ == '__main__': main() From 2c7639cc688f69aa5c9dabae9e31fc82e8c07bc9 Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Mon, 9 Aug 2021 14:56:11 +0800 Subject: [PATCH 56/58] Update PythonSdkLiveTest.yml --- scripts/auto_release/PythonSdkLiveTest.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index d5fab7b46809..0930961468d3 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -78,6 +78,7 @@ jobs: export USR_NAME=$(USR_NAME) export USR_TOKEN=$(USR_TOKEN) export TEST_RESULT=$test_result + export UPDATE_TOKEN=$(UPDATE_TOKEN) python $script_path/create_auto_release_pr.py echo "\'[AutoRelease] $new_branch \' has been created!!!" From 0a683d6807cdd17df0aedb62be51a4f89fb07a82 Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Tue, 7 Sep 2021 16:51:28 +0800 Subject: [PATCH 57/58] Update PythonSdkLiveTest.yml for Azure Pipelines --- scripts/auto_release/PythonSdkLiveTest.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index 0930961468d3..433ecaa81a4d 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -75,6 +75,7 @@ jobs: export NEW_BRANCH=`sed -n '1p' $output_path/output.txt` export TARGET_BRANCH=`sed -n '2p' $output_path/output.txt` export ISSUE_LINK=$(ISSUE_LINK) + export PIPELINE_LINK=$(PIPELINE_LINK) export USR_NAME=$(USR_NAME) export USR_TOKEN=$(USR_TOKEN) export TEST_RESULT=$test_result From 7518ab53229d62eb3385c9462c4319b79dc4901c Mon Sep 17 00:00:00 2001 From: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com> Date: Tue, 7 Sep 2021 16:54:09 +0800 Subject: [PATCH 58/58] Update create_auto_release_pr.py --- scripts/auto_release/create_auto_release_pr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/auto_release/create_auto_release_pr.py b/scripts/auto_release/create_auto_release_pr.py index 99391623fe25..9dafa7213691 100644 --- a/scripts/auto_release/create_auto_release_pr.py +++ b/scripts/auto_release/create_auto_release_pr.py @@ -8,7 +8,7 @@ def main(): pr_title = "[AutoRelease] {}(Do not merge)".format(os.getenv('NEW_BRANCH')) pr_head = "{}:{}".format(os.getenv('USR_NAME'), os.getenv('NEW_BRANCH')) pr_base = os.getenv('TARGET_BRANCH') - pr_body = "{} \n{}".format(os.getenv('ISSUE_LINK'), os.getenv('TEST_RESULT')) + pr_body = "{} \n{} \n{}".format(os.getenv('ISSUE_LINK'), os.getenv('TEST_RESULT'), os.getenv('PIPELINE_LINK')) res_create = api.pulls.create(pr_title, pr_head, pr_base, pr_body) pr_number = res_create.number