diff --git a/eng/automation/generate.py b/eng/automation/generate.py index 7937f0f62fc6..c5f9d9bfa3b0 100755 --- a/eng/automation/generate.py +++ b/eng/automation/generate.py @@ -127,8 +127,7 @@ def sdk_automation(input_file: str, output_file: str): logging.error("[GENERATE] Code generation failed. Unknown exception", exc_info=True) if packages and len(packages) == 1: packages[0]["result"] = "failed" - else: - sys.exit(1) + sys.exit(1) with open(output_file, "w", encoding="utf-8") as fout: output = { @@ -136,6 +135,9 @@ def sdk_automation(input_file: str, output_file: str): } json.dump(output, fout) + if packages and len(packages) == 1 and packages[0]["result"] == "failed": + sys.exit(1) + def sdk_automation_autorest(config: dict) -> List[dict]: base_dir = os.path.abspath(os.path.dirname(sys.argv[0])) @@ -250,8 +252,22 @@ def sdk_automation_typespec(config: dict) -> List[dict]: tsp_projects = [tsp_projects] for tsp_project in tsp_projects: + # folder structure v2: specification/{service}/[data-plane|resource-manager]/{provider}/ + folder_structure_v2_pattern = r"specification/.*/(data-plane|resource-manager)" + match = re.compile(folder_structure_v2_pattern).search(tsp_project) + if match: + sdk_type = match.group(1) + if sdk_type == "data-plane": + logging.info("[GENERATE] Generating data-plane from folder structure v2: " + tsp_project) + packages.append(sdk_automation_typespec_project_data(tsp_project, config)) + elif sdk_type == "resource-manager": + logging.info("[GENERATE] Generating mgmt-plane from folder structure v2: " + tsp_project) + packages.append(sdk_automation_typespec_project(tsp_project, config)) + else: + raise ValueError("Unexpected sdk type: " + sdk_type) + # folder structure v1 # mgmt tsp project folder follow the pattern, e.g. specification/deviceregistry/DeviceRegistry.Management - if re.match(r"specification[\\/](.*)[\\/](.*)[\\.]Management", tsp_project): + elif re.match(r"specification[\\/](.*)[\\/](.*)[\\.]Management", tsp_project): packages.append(sdk_automation_typespec_project(tsp_project, config)) else: packages.append(sdk_automation_typespec_project_data(tsp_project, config))