From 324962a0955efbf0e64c13e13fc917c7d8c1363e Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Wed, 28 Feb 2024 15:45:19 +0800 Subject: [PATCH 1/3] Revert "eng, migrate sdk automation to tsp-client (#38563)" This reverts commit adbd86af8ef06b4e423a73abb61ced4814569418. --- eng/mgmt/automation/generate_data.py | 44 +++++++--------------------- eng/mgmt/automation/init.sh | 3 -- 2 files changed, 10 insertions(+), 37 deletions(-) diff --git a/eng/mgmt/automation/generate_data.py b/eng/mgmt/automation/generate_data.py index c1cbf52aeddb2..6cd86bc090b03 100755 --- a/eng/mgmt/automation/generate_data.py +++ b/eng/mgmt/automation/generate_data.py @@ -32,8 +32,8 @@ def sdk_automation_typespec(config: dict) -> List[dict]: if 'relatedTypeSpecProjectFolder' not in config: return packages - head_sha: str = config['headSha'] - repo_url: str = config['repoHttpsUrl'] + head_sha = config['headSha'] + repo_url = config['repoHttpsUrl'] tsp_projects = config['relatedTypeSpecProjectFolder'] if isinstance(tsp_projects, str): @@ -47,40 +47,16 @@ def sdk_automation_typespec(config: dict) -> List[dict]: service = None module = None try: - def remove_prefix(text, prefix): - if text.startswith(prefix): - return text[len(prefix):] - return text - - def find_sdk_folder(): - cmd = ['git', 'add', '.'] - check_call(cmd, sdk_root) - - cmd = ['git', 'status', '--porcelain', '**/tsp-location.yaml'] - logging.info('Command line: ' + ' '.join(cmd)) - output = subprocess.check_output(cmd, cwd=sdk_root) - output_str = str(output, 'utf-8') - git_items = output_str.splitlines() - sdk_folder = None - if len(git_items) > 0: - tsp_location_item: str = git_items[0] - sdk_folder = tsp_location_item[1:].strip()[0:-len('/tsp-location.yaml')] - - cmd = ['git', 'reset', '.'] - check_call(cmd, sdk_root) - - return sdk_folder - - repo = remove_prefix(repo_url, 'https://github.com/') - cmd = ['npx', 'tsp-client', 'init', '--debug', '--tsp-config', tsp_dir, '--commit', head_sha, '--repo', repo] - check_call(cmd, sdk_root) - - sdk_folder = find_sdk_folder() + cmd = ['pwsh', './eng/common/scripts/TypeSpec-Project-Process.ps1', tsp_dir, head_sha, repo_url] + logging.info('Command line: ' + ' '.join(cmd)) + output = subprocess.check_output(cmd, cwd=sdk_root) + output_str = str(output, 'utf-8') + script_return = output_str.splitlines()[-1] # the path to sdk folder + sdk_folder = os.path.relpath(script_return, sdk_root) logging.info('SDK folder: ' + sdk_folder) - if sdk_folder: - succeeded = True + succeeded = True except subprocess.CalledProcessError as error: - logging.error(f'tsp-client init fail: {error}') + logging.error(f'TypeSpec-Project-Process.ps1 fail: {error}') if succeeded: # check require_sdk_integration diff --git a/eng/mgmt/automation/init.sh b/eng/mgmt/automation/init.sh index 201df2651b2dc..3723c60fb7d01 100755 --- a/eng/mgmt/automation/init.sh +++ b/eng/mgmt/automation/init.sh @@ -10,9 +10,6 @@ export NVM_DIR="$HOME/.nvm" nvm install v18.15.0 nvm alias default node -# install tsp-client globally (local install may interfere with tooling) -npm install -g @azure-tools/typespec-client-generator-cli - cat << EOF > $2 {"envs": {"PATH": "$JAVA_HOME_11_X64/bin:$PATH", "JAVA_HOME": "$JAVA_HOME_11_X64"}} EOF From 6d1df39014e600f9c7a55b6fcf6a5508fbcadc91 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Wed, 28 Feb 2024 15:50:16 +0800 Subject: [PATCH 2/3] enhance --- eng/mgmt/automation/generate_data.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eng/mgmt/automation/generate_data.py b/eng/mgmt/automation/generate_data.py index 6cd86bc090b03..891378f868a73 100755 --- a/eng/mgmt/automation/generate_data.py +++ b/eng/mgmt/automation/generate_data.py @@ -54,7 +54,8 @@ def sdk_automation_typespec(config: dict) -> List[dict]: script_return = output_str.splitlines()[-1] # the path to sdk folder sdk_folder = os.path.relpath(script_return, sdk_root) logging.info('SDK folder: ' + sdk_folder) - succeeded = True + if sdk_folder: + succeeded = True except subprocess.CalledProcessError as error: logging.error(f'TypeSpec-Project-Process.ps1 fail: {error}') From 23cfc0d24fc5cafb96299b11958e55c22493f0dd Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Wed, 28 Feb 2024 15:58:21 +0800 Subject: [PATCH 3/3] minor --- eng/mgmt/automation/generate_data.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/mgmt/automation/generate_data.py b/eng/mgmt/automation/generate_data.py index 891378f868a73..b23f8878b85a5 100755 --- a/eng/mgmt/automation/generate_data.py +++ b/eng/mgmt/automation/generate_data.py @@ -32,8 +32,8 @@ def sdk_automation_typespec(config: dict) -> List[dict]: if 'relatedTypeSpecProjectFolder' not in config: return packages - head_sha = config['headSha'] - repo_url = config['repoHttpsUrl'] + head_sha: str = config['headSha'] + repo_url: str = config['repoHttpsUrl'] tsp_projects = config['relatedTypeSpecProjectFolder'] if isinstance(tsp_projects, str):