-
Notifications
You must be signed in to change notification settings - Fork 227
Initial check in for the sdk generation core project #9327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,5 @@ | ||
| lib/ | ||
| node_modules/ | ||
| package-deps.json | ||
| .env | ||
| .vscode | ||
This file contains hidden or 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,21 @@ | ||
| MIT License | ||
raych1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Copyright (c) Microsoft Corporation. All rights reserved. | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE | ||
This file contains hidden or 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,14 @@ | ||
|
|
||
| # Contributing | ||
raych1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| This project welcomes contributions and suggestions. Most contributions require you to agree to a | ||
| Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us | ||
| the rights to use your contribution. For details, visit https://cla.microsoft.com. | ||
|
|
||
| When you submit a pull request, a CLA-bot will automatically determine whether you need to provide | ||
| a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions | ||
| provided by the bot. You will only need to do this once across all repos using our CLA. | ||
|
|
||
| This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). | ||
| For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or | ||
| contact [[email protected]](mailto:[email protected]) with any additional questions or comments. | ||
This file contains hidden or 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,104 @@ | ||
| trigger: | ||
| - master | ||
|
|
||
| pool: | ||
| name: AzurePipelines-EO | ||
| demands: | ||
| - ImageOverride -equals AzurePipelinesUbuntu20.04compliant | ||
|
|
||
| variables: | ||
| DOCKER_BUILDKIT: 1 | ||
|
|
||
| jobs: | ||
| - job: Build_Verfication | ||
| steps: | ||
| - task: npmAuthenticate@0 | ||
| inputs: | ||
| workingFile: .npmrc | ||
|
|
||
| - script: cp .npmrc .npmrc-registry | ||
| displayName: Disable .npmrc-registry | ||
|
|
||
| - script: sed -i -E 's/"version":\s*"([0-9\.]+)",/"version":"\1.$(Build.BuildNumber)",/' package.json | ||
| displayName: Set version in package.json | ||
|
|
||
| - task: Docker@2 | ||
| displayName: Build Image | ||
| inputs: | ||
| command: build | ||
| repository: openapi/sdk-automation | ||
| tags: $(Build.BuildNumber) | ||
| Dockerfile: ./Dockerfile | ||
| containerRegistry: openapi_test_docker_connection | ||
| arguments: --build-arg UBUNTU_MIRROR=$(UBUNTU_MIRROR) | ||
|
|
||
| - task: Docker@2 | ||
| displayName: Push Image | ||
| condition: notIn(variables['Build.Reason'], 'PullRequest') | ||
| inputs: | ||
| command: push | ||
| repository: openapi/sdk-automation | ||
| containerRegistry: openapi_test_docker_connection | ||
| tags: $(Build.BuildNumber) | ||
|
|
||
| - task: ComponentGovernanceComponentDetection@0 | ||
| displayName: Dependencies Compliance Analysis | ||
| inputs: | ||
| verbosity: Verbose | ||
| snapshotForceEnabled: true | ||
| useDefaultDetectors: false | ||
| detectorsToRun: Npm | ||
|
|
||
| - job: Integration_Test | ||
| variables: | ||
| SDK_REPO_NAME: PLACEHOLDER | ||
| steps: | ||
| - task: NodeTool@0 | ||
| inputs: | ||
| versionSpec: '18.x' | ||
|
|
||
| - task: npmAuthenticate@0 | ||
| inputs: | ||
| workingFile: .npmrc | ||
|
|
||
| - script: npm ci | ||
| displayName: NPM Install | ||
|
|
||
| - script: | | ||
| git config --global user.email "[email protected]" | ||
| git config --global user.name "SDK Automation" | ||
| rm .npmrc | ||
|
|
||
| npm config set audit false | ||
| sudo npm install -g npm@latest | ||
|
|
||
| sudo apt update | ||
| sudo apt install python3-setuptools python3-venv | ||
| /usr/bin/python3 -m venv work/pyenv | ||
| node ./node_modules/.bin/autorest --typescript | ||
|
|
||
| TEST_RUN_ID=`node -e "console.log(Math.random().toString(36).substring(2, 8))"` | ||
| echo "##vso[task.setvariable variable=TEST_RUN_ID]$TEST_RUN_ID" | ||
| echo "TEST_RUN_ID=$TEST_RUN_ID" | ||
| displayName: Init | ||
|
|
||
| - script: | | ||
| source work/pyenv/bin/activate | ||
| npm run test-ci | ||
| displayName: Integration Test | ||
| timeoutInMinutes: 30 | ||
| env: | ||
| SPEC_REPO: $(spec-repo) | ||
| GITHUB_COMMENT_AUTHOR_NAME: $(github.amrom.workers.devment-author-name) | ||
| GITHUBAPP_ID: $(githubapp-id) | ||
| GITHUBAPP_PRIVATE_KEY: $(githubapp-private-key) | ||
|
|
||
| - script: | | ||
| [ -z $TEST_RUN_ID ] || npm run clear-github-test-repos | ||
| displayName: Clean Up | ||
| condition: always() | ||
| env: | ||
| SPEC_REPO: $(spec-repo) | ||
| GITHUB_COMMENT_AUTHOR_NAME: $(github.amrom.workers.devment-author-name) | ||
| GITHUBAPP_ID: $(githubapp-id) | ||
| GITHUBAPP_PRIVATE_KEY: $(githubapp-private-key) |
This file contains hidden or 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,10 @@ | ||
| import globals from "globals"; | ||
| import tseslint from "typescript-eslint"; | ||
|
|
||
|
|
||
| export default [ | ||
| {files: ["**/*.{js,mjs,cjs,ts}"]}, | ||
| {files: ["**/*.js"], languageOptions: {sourceType: "commonjs"}}, | ||
| {languageOptions: { globals: globals.node }}, | ||
| ...tseslint.configs.recommended, | ||
| ]; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions
46
tools/sdk-automation-core/integrationTest/clearGithubTestRepos.ts
This file contains hidden or 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,46 @@ | ||
| import { getTestGithubClient, repoOwner } from './utils'; | ||
| import { sdkAutomationCliConfig } from '../src/cli/config'; | ||
| import { Octokit, RestEndpointMethodTypes } from '@octokit/rest'; | ||
|
|
||
| type ReposListForOrgResponse = RestEndpointMethodTypes['repos']['listForOrg']['response']['data'] | ||
|
|
||
| const cleanGithubTestRepos = async () => { | ||
| const github = await getTestGithubClient(); | ||
| const reposRsp: ReposListForOrgResponse = await github.paginate(github.repos.listForOrg.endpoint.merge({ | ||
| org: repoOwner | ||
| })); | ||
|
|
||
| const runId = sdkAutomationCliConfig.testRunId; | ||
| const prefixToMatch = runId ? `test-${runId}` : 'test'; | ||
|
|
||
| let repos = reposRsp.map(repo => repo.name); | ||
| console.log(`Repos in ${repoOwner}:`); | ||
| console.log(repos.join('\n')); | ||
|
|
||
| console.log(`\nFilter: ${prefixToMatch}`); | ||
| repos = repos.filter(name => name.startsWith(prefixToMatch)); | ||
| console.log(`Repos after filter:`); | ||
| console.log(repos.join('\n')); | ||
|
|
||
| const parallelCount = 4; | ||
| const promises: Promise<void>[] = []; | ||
| for (let i = 0; i < parallelCount; ++i) { | ||
| promises.push(cleanReposWorker(github, repos)); | ||
| } | ||
| await Promise.all(promises); | ||
| }; | ||
|
|
||
| const cleanReposWorker = async (github: Octokit, repos: string[]) => { | ||
| while (repos.length > 0) { | ||
| const repoName = repos.shift() as string; | ||
| console.log(`Cleaning up ${repoOwner}/${repoName}`); | ||
| try { | ||
| await github.repos.delete({ owner: repoOwner, repo: repoName }); | ||
| } catch (e) { | ||
| console.log(`Failed to delete ${repoOwner}/${repoName}: ${e.message} ${e.stack}`); | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| // tslint:disable-next-line: no-floating-promises | ||
| cleanGithubTestRepos(); |
26 changes: 26 additions & 0 deletions
26
tools/sdk-automation-core/integrationTest/fixtures/index.ts
This file contains hidden or 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,26 @@ | ||
| export const fixtures = { | ||
| specTest: { | ||
| name: 'spec-test', | ||
| patch0_AddService: 'spec-test-patch0-add-service', | ||
| patch1_Add_02_01: 'spec-test-patch1-add-02-01', // Depends on patch0 | ||
| patch2_Empty: 'spec-test-patch2-empty-update', // Depends on patch0 | ||
| patch3_TwoReadme: 'spec-test-patch3-two-readme' | ||
| }, | ||
| sdkGo: { | ||
| name: 'sdk-go-test' | ||
| }, | ||
| sdkJs: { | ||
| name: 'sdk-js-test', | ||
| patch0_AddServiceGen: 'sdk-js-test-patch0-add-service-gen' // CodeGen result after spec patch0 | ||
| }, | ||
| sdkPy: { | ||
| name: 'sdk-py-test', | ||
| patch0_Track2: 'sdk-py-test-patch0-track2' // Track2 config | ||
| }, | ||
| sdkTf: { | ||
| name: 'sdk-tf-test' | ||
| }, | ||
| schmARM: { | ||
| name: 'schm-arm-test' | ||
| } | ||
| } as const; |
1 change: 1 addition & 0 deletions
1
tools/sdk-automation-core/integrationTest/fixtures/schm-arm-test/.gitignore
This file contains hidden or 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 @@ | ||
| schemas/code-model-v1 |
Empty file.
18 changes: 18 additions & 0 deletions
18
tools/sdk-automation-core/integrationTest/fixtures/schm-arm-test/swagger_to_sdk_config.json
This file contains hidden or 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,18 @@ | ||
| { | ||
| "$schema": "https://openapistorageprod.blob.core.windows.net/sdkautomation/prod/schemas/swagger_to_sdk_config.schema.json", | ||
| "meta": { | ||
| "autorest_options": { | ||
| "use": "@autorest/[email protected]", | ||
| "azureresourceschema": "", | ||
| "multiapi": "", | ||
| "sdkrel:azureresourceschema-folder": ".", | ||
| "title": "none", | ||
| "pass-thru:subset-reducer": "" | ||
| }, | ||
| "advanced_options": { | ||
| "create_sdk_pull_requests": true, | ||
| "sdk_generation_pull_request_base": "integration_branch" | ||
| }, | ||
| "version": "0.2.0" | ||
| } | ||
| } |
34 changes: 34 additions & 0 deletions
34
tools/sdk-automation-core/integrationTest/fixtures/sdk-go-test/.gitignore
This file contains hidden or 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,34 @@ | ||
| # Compiled Object files, Static and Dynamic libs (Shared Objects) | ||
| *.o | ||
| *.a | ||
| *.so | ||
|
|
||
| # Folders | ||
| _obj | ||
| _test | ||
|
|
||
| # Architecture specific extensions/prefixes | ||
| # *.[568vq] | ||
| [568vq].out | ||
|
|
||
| *.cgo1.go | ||
| *.cgo2.c | ||
| _cgo_defun.c | ||
| _cgo_gotypes.go | ||
| _cgo_export.* | ||
|
|
||
| _testmain.go | ||
|
|
||
| *.exe | ||
| *.test | ||
| *.prof | ||
| *.zip | ||
|
|
||
| # Editor swap files | ||
| *.swp | ||
| *~ | ||
| .DS_Store | ||
| .vscode | ||
|
|
||
| # ignore vendor/ | ||
| vendor/ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.