From 1a39de24a23423df4766e3e87302c480865744b5 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Wed, 14 Dec 2022 12:46:22 +0800 Subject: [PATCH] [auto relesae] support run recording test (#27940) * support run recording test * support run recording test * fix package-name --- scripts/auto_release/PythonSdkLiveTest.yml | 2 +- scripts/auto_release/main.py | 29 +++++++++++----------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index 8dee9c8e53ae..0edf376164bc 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -74,7 +74,7 @@ jobs: pip install -r $script_path/requirement.txt # import env variable - export AZURE_TEST_RUN_LIVE=true + export AZURE_TEST_RUN_LIVE=$(AZURE_TEST_RUN_LIVE) export TENANT_ID=$(ENV-TENANT-ID) export CLIENT_ID=$(ENV-CLIENT-ID) export CLIENT_SECRET=$(ENV-CLIENT-SECRET) diff --git a/scripts/auto_release/main.py b/scripts/auto_release/main.py index 54765ab461dc..a6eb5a4a070b 100644 --- a/scripts/auto_release/main.py +++ b/scripts/auto_release/main.py @@ -251,12 +251,6 @@ def get_sdk_folder_with_package_name(self): folder_info = glob(f'sdk/*/azure-mgmt-{self.package_name}')[0] self.sdk_folder = Path(folder_info).parts[1] - def prepare_branch(self): - if self.spec_readme: - self.prepare_branch_with_readme() - # else: - # self.prepare_branch_with_base_branch() - def check_sdk_readme(self): sdk_readme = str(Path(f'sdk/{self.sdk_folder}/azure-mgmt-{self.package_name}/README.md')) @@ -470,12 +464,13 @@ def prepare_test_env(self): def run_test_proc(self): # run test os.chdir(self.sdk_code_path()) - succeeded_result = 'Live test success' - failed_result = 'Live test fail, detailed info is in pipeline log(search keyword FAILED)!!!' + test_mode = "Live test" if os.getenv("AZURE_TEST_RUN_LIVE") else "Recording test" + succeeded_result = f'{test_mode} success' + failed_result = f'{test_mode} fail, detailed info is in pipeline log(search keyword FAILED)!!!' try: print_check(f'pytest --collect-only') except: - log('live test run done, do not find any test !!!') + log(f'{test_mode} run done, do not find any test !!!') self.test_result = succeeded_result return @@ -485,7 +480,7 @@ def run_test_proc(self): log('some test failed, please fix it locally') self.test_result = failed_result else: - log('live test run done, do not find failure !!!') + log(f'{test_mode} run done, do not find failure !!!') self.test_result = succeeded_result def run_test(self): @@ -597,10 +592,16 @@ def create_pr(self): self.issue_comment() def run(self): - self.prepare_branch() - self.check_file() - self.run_test() - self.create_pr() + if "https:" in self.spec_readme: + self.prepare_branch_with_readme() + self.check_file() + self.run_test() + self.create_pr() + else: + self.sdk_folder = self.spec_readme.split('/')[0] + self.package_name = self.spec_readme.split('/')[-1].split('-')[-1] + self.checkout_branch("DEBUG_SDK_BRANCH", "azure-sdk-for-python") + self.run_test() if __name__ == '__main__':