Skip to content

Commit 99bfd77

Browse files
authored
[SDK generation pipeline] Fix for new changelog tool (#36951)
* new changelog fix * fix * fix * Delete tools/azure-sdk-tools/packaging_tools/test.py * fix * fix * changelog
1 parent 0731a12 commit 99bfd77

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

scripts/automation_init.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ PATH="$VIRTUAL_ENV/bin:$PATH"
1414
export PATH
1515
python -m pip install -U pip
1616
python scripts/dev_setup.py -p azure-core
17+
pip install tox==4.15.0
1718

1819
# install tsp-client globally (local install may interfere with tooling)
1920
echo Install tsp-client

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ def return_origin_path(func):
7777
@wraps(func)
7878
def wrapper(*args, **kwargs):
7979
current_path = os.getcwd()
80-
result = func(*args, **kwargs)
80+
try:
81+
result = func(*args, **kwargs)
82+
except Exception as e:
83+
os.chdir(current_path)
84+
raise e
8185
os.chdir(current_path)
8286
return result
8387

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
from typing import Optional
33
from pathlib import Path
44
import logging
5-
from subprocess import check_call, check_output, CalledProcessError
5+
from subprocess import check_call, CalledProcessError, getoutput
6+
from .generate_utils import return_origin_path
67

78
from .change_log import main as change_log_main
89

@@ -21,22 +22,20 @@ def create_package(prefolder, name, dest_folder=DEFAULT_DEST_FOLDER):
2122
)
2223

2324

25+
@return_origin_path
2426
def change_log_new(package_folder: str, lastest_pypi_version: bool) -> str:
27+
os.chdir(package_folder)
2528
cmd = "tox run -c ../../../eng/tox/tox.ini --root . -e breaking -- --changelog "
2629
if lastest_pypi_version:
2730
cmd += "--latest-pypi-version"
2831
try:
29-
output = check_output(cmd, cwd=package_folder, shell=True)
32+
output = getoutput(cmd)
3033
except CalledProcessError as e:
3134
_LOGGER.warning(f"Error ocurred when call breaking change detector: {e.output.decode('utf-8')}")
3235
raise e
33-
result = [l for l in output.decode("utf-8").split(os.linesep)]
36+
result = [l for l in output.split("\n")]
3437
begin = result.index("===== changelog start =====")
3538
end = result.index("===== changelog end =====")
36-
if begin == -1 or end == -1:
37-
warn_info = "Failed to get changelog from breaking change detector"
38-
_LOGGER.warning(warn_info)
39-
raise Exception(warn_info)
4039
return "\n".join(result[begin + 1 : end]).strip()
4140

4241

0 commit comments

Comments
 (0)