Skip to content

Commit

Permalink
[auto relesae] support run recording test (#27940)
Browse files Browse the repository at this point in the history
* support run recording test

* support run recording test

* fix package-name
  • Loading branch information
msyyc authored Dec 14, 2022
1 parent 8cb6b38 commit 1a39de2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion scripts/auto_release/PythonSdkLiveTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
29 changes: 15 additions & 14 deletions scripts/auto_release/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))

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

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

0 comments on commit 1a39de2

Please sign in to comment.