Skip to content

Commit

Permalink
[pipeline] adapt to breaking change detection (Azure#18300)
Browse files Browse the repository at this point in the history
* breaking change item for pipeline

* fix

* fix

* fix

* fix

* Update conf.py

* Update conf.py

* Update auto_package.py
  • Loading branch information
msyyc authored Apr 27, 2021
1 parent e3a2bc9 commit df8c766
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
3 changes: 2 additions & 1 deletion swagger_to_sdk_config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"advancedOptions": {
"createSdkPullRequests": true,
"generationCallMode": "one-for-all-configs"
"generationCallMode": "one-for-all-configs",
"breakingChangeTracking": true
},

"initOptions": {
Expand Down
22 changes: 18 additions & 4 deletions tools/azure-sdk-tools/packaging_tools/auto_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,27 @@ def get_package_names(sdk_folder):
return package_names


def change_log_generate(package_name):
def change_log_generate(package_name, last_version):
from pypi_tools.pypi import PyPIClient
client = PyPIClient()
try:
client.get_ordered_versions(package_name)
last_version[-1] = str(client.get_ordered_versions(package_name)[-1])
except:
return " - Initial Release"
else:
return change_log_main(f"{package_name}:pypi", f"{package_name}:latest")


def _extract_breaking_change(changelog):
log = changelog.split('\n')
breaking_change = []
for i in range(0, len(log)):
if log[i].find('Breaking changes') > -1:
breaking_change = log[min(i + 2, len(log) - 1):]
break
return sorted([x.replace(' - ', '') for x in breaking_change])


def main(generate_input, generate_output):
with open(generate_input, "r") as reader:
data = json.load(reader)
Expand All @@ -55,11 +65,15 @@ def main(generate_input, generate_output):
for package in data.values():
package_name = package['packageName']
# Changelog
md_output = change_log_generate(package_name)
last_version = ['first release']
md_output = change_log_generate(package_name, last_version)
package["changelog"] = {
"content": md_output,
"hasBreakingChange": "Breaking changes" in md_output
"hasBreakingChange": "Breaking changes" in md_output,
"breakingChangeItems": _extract_breaking_change(md_output)
}
package["version"] = last_version[-1]

_LOGGER.info(f'[PACKAGE]({package_name})[CHANGELOG]:{md_output}')
# Built package
create_package(package_name)
Expand Down

0 comments on commit df8c766

Please sign in to comment.