Skip to content

Commit ec883b2

Browse files
authored
[SDK generation pipeline] multiapi package use old changelog tool (#36754)
* multiapi package use old changelog * format * fix
1 parent e5048d8 commit ec883b2

File tree

3 files changed

+37
-10
lines changed

3 files changed

+37
-10
lines changed

tools/azure-sdk-tools/packaging_tools/package_utils.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,14 @@ def change_log_new(package_folder: str, lastest_pypi_version: bool) -> str:
4040
return "\n".join(result[begin + 1 : end]).strip()
4141

4242

43-
def change_log_generate(package_name, last_version, tag_is_stable: bool = False, *, prefolder: Optional[str] = None):
43+
def change_log_generate(
44+
package_name,
45+
last_version,
46+
tag_is_stable: bool = False,
47+
*,
48+
prefolder: Optional[str] = None,
49+
is_multiapi: bool = False,
50+
):
4451
from pypi_tools.pypi import PyPIClient
4552

4653
client = PyPIClient()
@@ -57,7 +64,7 @@ def change_log_generate(package_name, last_version, tag_is_stable: bool = False,
5764
return "### Other Changes\n\n - Initial version"
5865

5966
# try new changelog tool
60-
if prefolder:
67+
if prefolder and not is_multiapi:
6168
try:
6269
return change_log_new(str(Path(prefolder) / package_name), not (last_stable_release and tag_is_stable))
6370
except Exception as e:

tools/azure-sdk-tools/packaging_tools/sdk_generator.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import shutil
99
import re
1010
import os
11+
1112
try:
1213
# py 311 adds this library natively
1314
import tomllib as toml
@@ -67,6 +68,7 @@ def multiapi_combiner(sdk_code_path: str, package_name: str):
6768
)
6869
check_call("pip install -e .", shell=True)
6970

71+
7072
@return_origin_path
7173
def after_multiapi_combiner(sdk_code_path: str, package_name: str, folder_name: str):
7274
toml_file = Path(sdk_code_path) / CONF_NAME
@@ -81,12 +83,14 @@ def after_multiapi_combiner(sdk_code_path: str, package_name: str, folder_name:
8183
# azure-mgmt-resource has subfolders
8284
subfolder_path = Path(sdk_code_path) / package_name.replace("-", "/")
8385
subfolders_name = [s.name for s in subfolder_path.iterdir() if s.is_dir() and not s.name.startswith("_")]
84-
content["packaging"]["exclude_folders"] = ",".join([exclude(f"{package_name}-{s}") for s in subfolders_name])
86+
content["packaging"]["exclude_folders"] = ",".join(
87+
[exclude(f"{package_name}-{s}") for s in subfolders_name]
88+
)
8589

8690
with open(toml_file, "wb") as file_out:
8791
tomlw.dump(content, file_out)
8892
call_build_config(package_name, folder_name)
89-
93+
9094
# remove .egg-info to reinstall package
9195
for item in Path(sdk_code_path).iterdir():
9296
if item.suffix == ".egg-info":
@@ -97,14 +101,20 @@ def after_multiapi_combiner(sdk_code_path: str, package_name: str, folder_name:
97101
_LOGGER.info(f"do not find {toml_file}")
98102

99103

100-
def del_outdated_files(readme: str):
104+
# readme: ../azure-rest-api-specs/specification/paloaltonetworks/resource-manager/readme.md or absolute path
105+
def get_readme_python_content(readme: str) -> List[str]:
101106
python_readme = Path(readme).parent / "readme.python.md"
102107
if not python_readme.exists():
103108
_LOGGER.info(f"do not find python configuration: {python_readme}")
104-
return
109+
return []
105110

106111
with open(python_readme, "r") as file_in:
107-
content = file_in.readlines()
112+
return file_in.readlines()
113+
114+
115+
# readme: ../azure-rest-api-specs/specification/paloaltonetworks/resource-manager/readme.md
116+
def del_outdated_files(readme: str):
117+
content = get_readme_python_content(readme)
108118
sdk_folder = extract_sdk_folder(content)
109119
is_multiapi = is_multiapi_package(content)
110120
if sdk_folder:
@@ -150,7 +160,7 @@ def get_related_swagger(readme_content: List[str], tag: str) -> List[str]:
150160

151161

152162
def get_last_commit_info(files: List[str]) -> str:
153-
result = [getoutput(f'git log -1 --pretty="format:%ai %H" {f}').strip('\n ') + " " + f for f in files]
163+
result = [getoutput(f'git log -1 --pretty="format:%ai %H" {f}').strip("\n ") + " " + f for f in files]
154164
result.sort()
155165
return result[-1]
156166

@@ -199,7 +209,9 @@ def extract_version_info(config: Dict[str, Any]) -> str:
199209
def if_need_regenerate(meta: Dict[str, Any]) -> bool:
200210
with open(str(Path("../azure-sdk-for-python", CONFIG_FILE)), "r") as file_in:
201211
config = json.load(file_in)
202-
current_info = config["meta"]["autorest_options"]["version"] + "".join(sorted(config["meta"]["autorest_options"]["use"]))
212+
current_info = config["meta"]["autorest_options"]["version"] + "".join(
213+
sorted(config["meta"]["autorest_options"]["use"])
214+
)
203215
recorded_info = meta["autorest"] + "".join(sorted(meta["use"]))
204216
return recorded_info != current_info
205217

@@ -327,6 +339,8 @@ def main(generate_input, generate_output):
327339
package_entry["path"] = [folder_name]
328340
package_entry[spec_word] = [input_readme]
329341
package_entry["tagIsStable"] = not judge_tag_preview(sdk_code_path)
342+
readme_python_content = get_readme_python_content(str(Path(spec_folder) / input_readme))
343+
package_entry["isMultiapi"] = is_multiapi_package(readme_python_content)
330344
result[package_name] = package_entry
331345
else:
332346
result[package_name]["path"].append(folder_name)

tools/azure-sdk-tools/packaging_tools/sdk_package.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ def main(generate_input, generate_output):
3030
last_version = ["first release"]
3131
if "azure-mgmt-" in package_name:
3232
try:
33-
md_output = change_log_generate(package_name, last_version, package["tagIsStable"], prefolder=prefolder)
33+
md_output = change_log_generate(
34+
package_name,
35+
last_version,
36+
package["tagIsStable"],
37+
prefolder=prefolder,
38+
is_multiapi=package["isMultiapi"],
39+
)
3440
except:
3541
md_output = "change log generation failed!!!"
3642
else:

0 commit comments

Comments
 (0)