Skip to content

Commit

Permalink
DPG, integrate with apiview (Azure#28054)
Browse files Browse the repository at this point in the history
  • Loading branch information
weidongxu-microsoft authored Apr 7, 2022
1 parent ebe60c2 commit a270f42
Show file tree
Hide file tree
Showing 6 changed files with 229 additions and 156 deletions.
7 changes: 4 additions & 3 deletions eng/mgmt/automation/changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@
os.chdir(os.path.abspath(os.path.dirname(sys.argv[0])))
from parameters import *
from generate import update_parameters
from generate import get_version
from generate_utils import get_version
from generate import compile_package
from generate import compare_with_maven_package

os.chdir(pwd)


def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser()
parser.add_argument('-s', '--service', required = True)
parser.add_argument('-s', '--service', required=True)
parser.add_argument('--suffix')
parser.add_argument('-c', '--compile', action = 'store_true')
parser.add_argument('-c', '--compile', action='store_true')
return parser.parse_args()


Expand Down
81 changes: 38 additions & 43 deletions eng/mgmt/automation/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
get_and_update_service_from_api_specs,
get_suffix_from_api_specs,
)

os.chdir(pwd)


Expand All @@ -40,50 +41,48 @@ def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser()
parser.add_argument(
'--spec-root',
default =
'https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/',
help = 'Spec root folder',
default='https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/',
help='Spec root folder',
)
parser.add_argument(
'-r',
'--readme',
help =
'Readme path, Sample: "storage" or "specification/storage/resource-manager/readme.md"',
help='Readme path, Sample: "storage" or "specification/storage/resource-manager/readme.md"',
)
parser.add_argument('-t', '--tag', help = 'Specific tag')
parser.add_argument('-v', '--version', help = 'Specific sdk version')
parser.add_argument('-t', '--tag', help='Specific tag')
parser.add_argument('-v', '--version', help='Specific sdk version')
parser.add_argument(
'-s',
'--service',
help = 'Service Name if not the same as spec name',
help='Service Name if not the same as spec name',
)
parser.add_argument(
'-u',
'--use',
default = AUTOREST_JAVA,
help = 'Autorest java plugin',
default=AUTOREST_JAVA,
help='Autorest java plugin',
)
parser.add_argument(
'--autorest',
default = AUTOREST_CORE_VERSION,
help = 'Autorest version',
default=AUTOREST_CORE_VERSION,
help='Autorest version',
)
parser.add_argument(
'--autorest-options',
default = '',
help = 'Additional autorest options',
default='',
help='Additional autorest options',
)
parser.add_argument('--suffix', help = 'Suffix for namespace and artifact')
parser.add_argument('--suffix', help='Suffix for namespace and artifact')
parser.add_argument(
'--auto-commit-external-change',
action = 'store_true',
help = 'Automatic commit the generated code',
action='store_true',
help='Automatic commit the generated code',
)
parser.add_argument('--user-name', help = 'User Name for commit')
parser.add_argument('--user-email', help = 'User Email for commit')
parser.add_argument('--user-name', help='User Name for commit')
parser.add_argument('--user-email', help='User Email for commit')
parser.add_argument(
'config',
nargs = '*',
nargs='*',
)

return parser.parse_args()
Expand Down Expand Up @@ -140,14 +139,14 @@ def sdk_automation(input_file: str, output_file: str):
succeeded = generate(
sdk_root,
service,
spec_root = config['specFolder'],
readme = readme,
autorest = AUTOREST_CORE_VERSION,
use = AUTOREST_JAVA,
output_folder = output_folder,
module = module,
namespace = namespace,
tag = tag,
spec_root=config['specFolder'],
readme=readme,
autorest=AUTOREST_CORE_VERSION,
use=AUTOREST_JAVA,
output_folder=output_folder,
module=module,
namespace=namespace,
tag=tag,
)
if succeeded:
compile_package(sdk_root, module)
Expand All @@ -163,14 +162,11 @@ def sdk_automation(input_file: str, output_file: str):
'pom.xml',
],
'readmeMd': [readme],
'artifacts': [
'{0}/pom.xml'.format(output_folder),
] + [
jar for jar in glob.glob('{0}/target/*.jar'.format(
output_folder))
],
'result':
'succeeded' if succeeded else 'failed',
'artifacts': ['{0}/pom.xml'.format(output_folder)] +
[jar for jar in glob.glob('{0}/target/*.jar'.format(output_folder))],
'apiViewArtifact': next(iter(glob.glob('{0}/target/*-sources.jar'.format(output_folder))), None),
'language': 'Java',
'result': 'succeeded' if succeeded else 'failed',
})

update_parameters(pre_suffix)
Expand Down Expand Up @@ -224,20 +220,19 @@ def main():
namespace = NAMESPACE_FORMAT.format(service)
succeeded = generate(
sdk_root,
module = module,
output_folder = output_folder,
namespace = namespace,
module=module,
output_folder=output_folder,
namespace=namespace,
**args
)

if succeeded:
succeeded = compile_package(sdk_root, module)
if succeeded:
compare_with_maven_package(sdk_root, service, stable_version,
current_version, module)
current_version, module)

if args.get('auto_commit_external_change') and args.get(
'user_name') and args.get('user_email'):
if args.get('auto_commit_external_change') and args.get('user_name') and args.get('user_email'):
pwd = os.getcwd()
try:
os.chdir(sdk_root)
Expand All @@ -246,7 +241,7 @@ def main():
POM_FILE_FORMAT.format(service)))
os.system(
'git -c user.name={0} -c user.email={1} commit -m "[Automation] External Change"'
.format(args['user_name'], args['user_email']))
.format(args['user_name'], args['user_email']))
finally:
os.chdir(pwd)

Expand Down
Loading

0 comments on commit a270f42

Please sign in to comment.