Skip to content

Commit

Permalink
add check for multiapi (Azure#30555)
Browse files Browse the repository at this point in the history
  • Loading branch information
msyyc authored May 30, 2023
1 parent 2114d40 commit e328ef6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tools/azure-sdk-tools/packaging_tools/generate_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@
_DPG_README = "README.md"


def check_api_version_in_subfolder(sdk_code_path: str):
folders = glob(f"{sdk_code_path}/**/_configuration.py", recursive=True)
configs = [str(Path(f)) for f in folders if re.compile("v\d{4}_\d{2}_\d{2}").search(f)]
if configs:
result = []
for config in configs:
with open(config, "r") as file_in:
content = file_in.readlines()
if "self.api_version = api_version" not in "".join(content):
result.append(config)
if result:
raise Exception("Found files that do not set api_version: \n" + "\n".join(result))


def dpg_relative_folder(spec_folder: str) -> str:
return ("../" * 4) + spec_folder + "/"

Expand Down
4 changes: 4 additions & 0 deletions tools/azure-sdk-tools/packaging_tools/sdk_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
gen_typespec,
update_typespec_location,
return_origin_path,
check_api_version_in_subfolder,
)

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -177,6 +178,9 @@ def main(generate_input, generate_output):
shell=True,
)

# check whether multiapi package has only one api-version in per subfolder
check_api_version_in_subfolder(sdk_code_path)

# use multiapi combiner to combine multiapi package
if package_name in ("azure-mgmt-network"):
_LOGGER.info(f"start to combine multiapi package: {package_name}")
Expand Down

0 comments on commit e328ef6

Please sign in to comment.