forked from Azure/azure-sdk-for-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into python-track2-test
- Loading branch information
Showing
557 changed files
with
251,350 additions
and
23,409 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
parameters: | ||
- name: ServiceDirectory | ||
type: string | ||
- name: NodeVersion | ||
type: string | ||
default: '12.x' | ||
- name: PythonVersion | ||
type: string | ||
default: '$(PythonVersion)' | ||
- name: auto_rest_clone_url | ||
type: string | ||
default: 'https://github.com/Azure/autorest.python.git' | ||
- name: VerifyAutorest | ||
type: boolean | ||
default: false | ||
|
||
steps: | ||
- ${{if eq(parameters.VerifyAutorest, 'true')}}: | ||
- template: /eng/common/pipelines/templates/steps/set-default-branch.yml | ||
|
||
- task: UsePythonVersion@0 | ||
displayName: Use | ||
inputs: | ||
versionSpec: ${{ parameters.PythonVersion }} | ||
|
||
- task: NodeTool@0 | ||
inputs: | ||
versionSpec: ${{ parameters.NodeVersion }} | ||
|
||
- script: | | ||
npm install -g autorest | ||
autorest --help | ||
displayName: "Install autorest" | ||
- template: /eng/common/pipelines/templates/steps/sparse-checkout.yml | ||
parameters: | ||
Paths: | ||
- "/*" | ||
Repositories: | ||
- Name: "Azure/autorest.python" | ||
Commitish: "master" | ||
WorkingDirectory: "$(Build.SourcesDirectory)/autorest.python" | ||
SkipDefaultCheckout: true | ||
|
||
- script: | | ||
python --version | ||
pip install -r eng/autorest_req.txt | ||
cd autorest.python | ||
npm install | ||
displayName: 'Prepare Environment' | ||
- task: PythonScript@0 | ||
displayName: 'Verify autorest' | ||
inputs: | ||
scriptPath: 'scripts/devops_tasks/verify_autorest.py' | ||
arguments: >- | ||
--service_directory="${{ parameters.ServiceDirectory }}" | ||
- ${{ if and(ne(variables['Build.Reason'], 'PullRequest'), eq(variables['System.TeamProject'], 'internal')) }}: | ||
- template: /eng/common/pipelines/templates/steps/create-pull-request.yml | ||
# # displayName: Create PR for ${{ ServiceDirectory }} | ||
# condition: and(ne(variables['Build.Reason'],'PullRequest'), eq(variables['System.TeamProject'], 'internal')) | ||
parameters: | ||
CommitMsg: "Regenerated code from nightly builds" | ||
PRTitle: "Automated autorest generation" | ||
PRBranchName: 'autorest-${{ ServiceDirectory }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
#!/usr/bin/env python | ||
|
||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
import argparse | ||
import os | ||
import logging | ||
import sys | ||
|
||
from common_tasks import run_check_call | ||
|
||
logging.getLogger().setLevel(logging.INFO) | ||
|
||
root_dir = os.path.abspath(os.path.join(os.path.abspath(__file__), "..", "..", "..")) | ||
sdk_dir = os.path.join(root_dir, "sdk") | ||
|
||
SWAGGER_FOLDER = "swagger" | ||
|
||
|
||
def run_autorest(service_dir): | ||
logging.info("Running autorest for {}".format(service_dir)) | ||
|
||
service_dir = os.path.join(sdk_dir, service_dir) | ||
|
||
swagger_folders = find_swagger_folders(service_dir) | ||
|
||
for working_dir in swagger_folders: | ||
os.chdir(working_dir) | ||
f = os.path.abspath(os.path.join(working_dir, "README.md")) | ||
if os.path.exists(f): | ||
reset_command = ["autorest", "--reset"] | ||
run_check_call(reset_command, root_dir) | ||
|
||
command = ["autorest", "--python", f, "--verbose"] | ||
logging.info("Command: {}\nLocation: {}\n".format(command, working_dir)) | ||
run_check_call(command, working_dir) | ||
return swagger_folders | ||
|
||
|
||
def find_swagger_folders(directory): | ||
logging.info("Searching for swagger files in: {}".format(directory)) | ||
|
||
ret = [] | ||
for root, subdirs, files in os.walk(directory): | ||
for d in subdirs: | ||
if d == SWAGGER_FOLDER: | ||
if os.path.exists(os.path.join(root, d, "README.md")): | ||
ret.append(os.path.join(root, d)) | ||
|
||
logging.info("Found swagger files at: {}".format(ret)) | ||
return ret | ||
|
||
|
||
def check_diff(folder): | ||
# We don't care about changes to txt files (dev_requirements change) | ||
run_check_call(["git", "status"], sdk_dir, always_exit=False) | ||
|
||
command = [ | ||
"git", | ||
"checkout", | ||
"--", | ||
"**/*.txt", | ||
] | ||
result = run_check_call(command, sdk_dir, always_exit=False) | ||
|
||
# Remove the whl dirs | ||
command = [ | ||
"rm", | ||
"-r", | ||
"**/.tmp_whl_dir/" | ||
] | ||
result = run_check_call(command, sdk_dir, always_exit=False) | ||
|
||
# Next we need to move the autorest and _tox_logs directories and then replace them | ||
|
||
dir_changed = folder.split("/")[:-2] | ||
command = [ | ||
"git", | ||
"diff", | ||
"--exit-code", | ||
"{}".format("/".join(dir_changed)), | ||
] | ||
result = run_check_call(command, sdk_dir, always_exit=False) | ||
if result: | ||
command = ["git", "status"] | ||
run_check_call(command, root_dir) | ||
raise ValueError( | ||
"Found difference between re-generated code and current commit. Please re-generate with the latest autorest." | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser( | ||
description="Run autorest to verify generated code." | ||
) | ||
parser.add_argument( | ||
"--service_directory", help="Directory of the package being tested" | ||
) | ||
|
||
args = parser.parse_args() | ||
folders = run_autorest(args.service_directory) | ||
|
||
if len(folders): | ||
for folder in folders: | ||
check_diff(folder) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
sdk/communication/azure-communication-phonenumbers/CHANGELOG.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.