Skip to content

Commit

Permalink
[DPG] update quick-start-tool (#24942)
Browse files Browse the repository at this point in the history
* add generate ci

* fix ci template path]

* update

* update

* format

* Update scripts/quickstart_tooling_dpg/main.py

* Update scripts/quickstart_tooling_dpg/main.py

Co-authored-by: Yuchao Yan <yuchaoyan@microsoft.com>
  • Loading branch information
BigCat20196 and msyyc authored Jun 23, 2022
1 parent 92291c9 commit 570cfb1
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
25 changes: 25 additions & 0 deletions scripts/quickstart_tooling_dpg/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
_TEMPLATE = Path(__file__).resolve().parent / "template"
_TEMPLATE_TESTS = Path(__file__).resolve().parent / "template_tests"
_TEMPLATE_SAMPLES = Path(__file__).resolve().parent / "template_samples"
_TEMPLATE_CI = Path(__file__).resolve().parent / "template_ci"


def check_parameters(
Expand All @@ -25,6 +26,27 @@ def check_parameters(
_LOGGER.info(f'{output} is created')


def generate_ci(template_path: Path, folder_path: Path, package_name: str) -> None:
ci = Path(folder_path, "ci.yml")
ci_template_path = template_path / 'ci.yml'
service_name = folder_path.name
name = package_name.split('-')[-1]
if not ci.exists():
with open(ci_template_path, "r") as file_in:
content = file_in.readlines()
content = [line.replace("ServiceName", service_name).replace('PackageName', name) for line in content]
else:
with open(ci, "r") as file_in:
content = file_in.readlines()
for line in content:
if f'{package_name}\n' in line:
return
content.append(f' - name: {package_name}\n')
content.append(f' safeName: {package_name.replace("-", "")}\n')
with open(ci, "w") as file_out:
file_out.writelines(content)


def generate_test_sample(template_path: Path, target_path: Path, **kwargs: Any) -> None:
if not os.path.exists(target_path):
os.makedirs(target_path)
Expand Down Expand Up @@ -71,6 +93,9 @@ def build_package(**kwargs) -> None:
_LOGGER.info("Build start: %s", package_name)
check_parameters(output_folder)

#generate ci
generate_ci(_TEMPLATE_CI, Path(output_folder).parent, package_name)

# generate swagger readme
env = Environment(loader=FileSystemLoader(_TEMPLATE), keep_trailing_newline=True)
swagger_readme = generate_swagger_readme(output_folder, env, **kwargs)
Expand Down
33 changes: 33 additions & 0 deletions scripts/quickstart_tooling_dpg/template_ci/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# DO NOT EDIT THIS FILE
# This file is generated automatically and any changes will be lost.

trigger:
branches:
include:
- main
- hotfix/*
- release/*
- restapi*
paths:
include:
- sdk/ServiceName/

pr:
branches:
include:
- main
- feature/*
- hotfix/*
- release/*
- restapi*
paths:
include:
- sdk/ServiceName/

extends:
template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml
parameters:
ServiceDirectory: ServiceName
Artifacts:
- name: azure-mgmt-PackageName
safeName: azuremgmtPackageName

0 comments on commit 570cfb1

Please sign in to comment.