Skip to content

Commit

Permalink
{CI} Enhance extension regression test pipeline (Azure#25525)
Browse files Browse the repository at this point in the history
* Enhance extension regression test pipeline

* fix syntax

* checkout cli custom repo

* rerun setup repo path

* revert repo path

* fix NoneType error

* test fix
  • Loading branch information
evelyn-ys authored Aug 15, 2023
1 parent 2404ce2 commit a32f58e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
20 changes: 19 additions & 1 deletion scripts/ci/automation_full_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
pull_request_number = os.environ.get('PULL_REQUEST_NUMBER', None)
enable_pipeline_result = bool(job_name and python_version)
unique_job_name = ' '.join([job_name, python_version, profile, str(instance_idx)]) if enable_pipeline_result else None
enable_traceback = True if os.environ.get('ENABLE_TRACEBACK').lower() == 'true' else False
enable_traceback = True if (os.environ.get('ENABLE_TRACEBACK') is not None and os.environ.get('ENABLE_TRACEBACK').lower() == 'true') else False
cli_jobs = {
'acr': 45,
'acs': 62,
Expand Down Expand Up @@ -271,6 +271,19 @@ def remove_extension(extension_module):
return error_flag


def rerun_setup(cli_repo_path, extension_repo_path):
try:
if extension_repo_path:
cmd = ['azdev', 'setup', '-c', cli_repo_path, '-r', extension_repo_path, '--debug']
else:
cmd = ['azdev', 'setup', '-c', cli_repo_path, '--debug']
error_flag = run_command(cmd, check_return_code=True)
except Exception:
error_flag = True

return error_flag


def git_restore(file_path):
if not file_path:
return
Expand Down Expand Up @@ -599,12 +612,17 @@ def run_extension_instance_modules(self, instance_modules):
for module, path in instance_modules.items():
run_command(["git", "checkout", f"regression_test_{os.getenv('BUILD_BUILDID')}"], check_return_code=True)
error_flag = install_extension(module)
logger.info(f"Finish installing extension {module}, error_flag: {error_flag}")
if not error_flag:
azdev_test_result_fp = os.path.join(azdev_test_result_dir, f"test_results_{module}.xml")
cmd = ['azdev', 'test', module, '--discover', '--no-exitfirst', '--verbose',
'--xml-path', azdev_test_result_fp, '--pytest-args', '"--durations=10"']
error_flag = process_test(cmd, azdev_test_result_fp, live_rerun=fix_failure_tests, modules=[module])
logger.info(f"Finish testing extension {module}, error_flag: {error_flag}")
remove_extension(module)
logger.info(f"Finish removing extension {module}, error_flag: {error_flag}")
if error_flag:
rerun_setup(cli_repo_path=os.getenv('BUILD_SOURCESDIRECTORY'), extension_repo_path=working_directory)
global_error_flag = global_error_flag or error_flag
return global_error_flag

Expand Down
8 changes: 7 additions & 1 deletion scripts/regression_test/extension_regression_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ jobs:
inlineScript: |
set -ev
pwd
if [[ -n "$(CUSTOM_CLI_REPO)" && -n "$(CUSTOM_CLI_BRANCH)" ]]; then
git remote add ${CUSTOM_CLI_REPO} https://github.com/${CUSTOM_CLI_REPO}/azure-cli.git
git fetch ${CUSTOM_CLI_REPO} $(CUSTOM_CLI_BRANCH)
git checkout -b ${CUSTOM_CLI_BRANCH} ${CUSTOM_CLI_REPO}/${CUSTOM_CLI_BRANCH}
fi
git clone https://github.com/Azure/azure-cli-extensions.git
cd azure-cli-extensions
Expand Down Expand Up @@ -146,7 +152,7 @@ jobs:
- job: ResultSummary
displayName: CLI Extension Regression Test Result Summary
dependsOn: CLIExtensionRegressionTest
condition: succeededOrFailed()
condition: and(succeededOrFailed(), eq(variables['CUSTOM_CLI_REPO'], ''))
pool:
name: ${{ variables.ubuntu_pool }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion scripts/regression_test/regression_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ jobs:
git config --global user.email "[email protected]"
git config --global user.name "Azure CLI Team"
git remote add ${GITHUB_REPO} https://${GITHUB_REPO}:${GITHUB_TOKEN}@github.com/${GITHUB_REPO}/azure-cli.git
git fetch ${GITHUB_REPO}
git fetch ${GITHUB_REPO} ${GITHUB_BRANCH}
git checkout -b ${GITHUB_BRANCH} ${GITHUB_REPO}/${GITHUB_BRANCH}
- template: ../../.azure-pipelines/templates/azdev_setup.yml
Expand Down

0 comments on commit a32f58e

Please sign in to comment.