Skip to content

Commit

Permalink
Refactor to simplify & remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony-c-martin committed Apr 1, 2024
1 parent 393ce6d commit 7edebc8
Show file tree
Hide file tree
Showing 21 changed files with 69 additions and 18,280 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/generate-schemas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
mkdir -p "$GITHUB_WORKSPACE/schemas"
npm run generate-all -- \
--local-path "$GITHUB_WORKSPACE/workflow-temp/azure-rest-api-specs" \
--specs-dir "$GITHUB_WORKSPACE/workflow-temp/azure-rest-api-specs" \
--batch-count ${{ env.BATCH_COUNT }} \
--batch-index ${{ matrix.batch }} \
--summary-log-path "$GITHUB_WORKSPACE/summary.log" \
Expand Down Expand Up @@ -106,4 +106,4 @@ jobs:
commit_message: Update Generated Schemas
branch: autogenerate-batch
push_options: '--force'
create_branch: true
create_branch: true
2 changes: 1 addition & 1 deletion .github/workflows/generate-single.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- name: Run generator
run: |
npm run generate-single -- \
--local-path "$GITHUB_WORKSPACE/workflow-temp/azure-rest-api-specs" \
--specs-dir "$GITHUB_WORKSPACE/workflow-temp/azure-rest-api-specs" \
--base-path '${{ github.event.inputs.single_path }}'
working-directory: generator

Expand Down
39 changes: 1 addition & 38 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,41 +61,4 @@ jobs:

- name: Build
run: npm run build
working-directory: ./generator

automerge:
runs-on: ubuntu-latest
needs: schema-tests
env:
PR_PREFIX: sdkAuto/
if: ${{ github.event.pull_request.user.login == 'azure-sdk' }}
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16.x

- name: Install NPM modules
run: npm ci
working-directory: ./generator

- name: Check RP in Autogenlist
run: |
check_result='';
exec=$(npm run find-basepath ${{ github.head_ref }} $PR_PREFIX);
while read line;
do
# overriding check_result until the last line is read, last line contains
# the result to whether or not the basepath was found in autogenlist.
check_result=$line;
echo $check_result;
done <<< "$exec";
if [ $check_result == 'false' ] ; then
echo "Base path: '$basePath' not onboarded for autogeneration" 1>&2
exit 1
fi
working-directory: ./generator
working-directory: ./generator
4 changes: 2 additions & 2 deletions .sdkauto/generateScript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ OUTPUT_PATH=$2

pushd generator

echo "npm run generate-all -- --local-path $LOCAL_PATH --readme-files $README_FILES --output-path $OUTPUT_PATH"
npm run generate-all -- --local-path $LOCAL_PATH --readme-files $README_FILES --output-path $OUTPUT_PATH
echo "npm run generate-all -- --specs-dir $LOCAL_PATH --readme-files $README_FILES --output-path $OUTPUT_PATH"
npm run generate-all -- --specs-dir $LOCAL_PATH --readme-files $README_FILES --output-path $OUTPUT_PATH

popd
61 changes: 28 additions & 33 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,48 @@
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "List basepaths",
"runtimeArgs": ["-r", "ts-node/register"],
"cwd": "${workspaceFolder}/generator",
"args": ["${workspaceFolder}/generator/cmd/listbasepaths.ts"]
},
{
"type": "node",
"request": "launch",
"name": "List resources",
"runtimeArgs": ["-r", "ts-node/register"],
"cwd": "${workspaceFolder}/generator",
"args": ["${workspaceFolder}/generator/cmd/listresources.ts"]
},
{
"type": "node",
"request": "launch",
"name": "Generate single",
"runtimeArgs": ["-r", "ts-node/register"],
"cwd": "${workspaceFolder}/generator",
"runtimeExecutable": "npm",
"args": [
"${workspaceFolder}/generator/cmd/generatesingle.ts",
"--base-path",
"${input:resourceProvider}"
]
"run",
"list-basepaths",
"--",
"--specs-dir",
"${workspaceFolder}/../azure-rest-api-specs"
],
"cwd": "${workspaceFolder}/generator"
},
{
"name": "Generate Single",
"type": "node",
"request": "launch",
"name": "Generate all",
"runtimeArgs": ["-r", "ts-node/register"],
"cwd": "${workspaceFolder}/generator",
"runtimeExecutable": "npm",
"args": [
"${workspaceFolder}/generator/cmd/generateall.ts"
]
"run",
"generate-single",
"--",
"--specs-dir",
"${workspaceFolder}/../azure-rest-api-specs",
"--base-path",
"${input:basePath}"
],
"cwd": "${workspaceFolder}/generator"
},
{
"name": "Generate All",
"type": "node",
"request": "launch",
"name": "Generate all - local",
"runtimeArgs": ["-r", "ts-node/register"],
"cwd": "${workspaceFolder}/generator",
"runtimeExecutable": "npm",
"args": [
"${workspaceFolder}/generator/cmd/generateall.ts",
"{\"localPath\":\"../azure-rest-api-specs\",\"readmeFiles\":[\"specification/signalr/resource-manager/readme.md\",\"specification/appplatform/resource-manager/readme.md\"],\"outputPath\":\"../generateOutput.json\"}"
]
"run",
"generate-all",
"--",
"--specs-dir",
"${workspaceFolder}/../azure-rest-api-specs"
],
"cwd": "${workspaceFolder}/generator"
}
],
"inputs": [
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,18 @@ Please see [generator/autogenlist.ts](/generator/autogenlist.ts) for the list of
You can use the generator in this repo to automatically generate a schema from a swagger spec checked into the [azure-rest-api-specs](https://github.com/Azure/azure-rest-api-specs) repo.

#### Generating locally
1. Clone [azure-rest-api-specs](https://github.com/Azure/azure-rest-api-specs).
1. Fork this repo, and clone it locally.
2. Run the following commands (replace the base path accordingly - valid paths can be disovered with `npm run list-basepaths`):
1. Run the following commands (replace the base path accordingly - valid paths can be disovered with `npm run list-basepaths -- --specs-dir path/to/azure-rest-api-specs`):
```bash
cd generator
npm install
npm run generate-single -- --base-path myprovider/resource-manager
npm run generate-single -- --specs-dir path/to/azure-rest-api-specs --base-path myprovider/resource-manager
```
4. Review the generator logs to ensure no errors, and review the changes generated.
5. Ensure that you have reviewed the guidelines under [Submitting a PR](#submitting-a-pr).
6. Generate a commit and push it to your fork.
7. Submit a pull request to this repo. Please include the full command output in a PR comment.
1. Review the generator logs to ensure no errors, and review the changes generated.
1. Ensure that you have reviewed the guidelines under [Submitting a PR](#submitting-a-pr).
1. Generate a commit and push it to your fork.
1. Submit a pull request to this repo. Please include the full command output in a PR comment.

Alternatively, you can hand-author your schema, but **please note** that this process is error-prone, and ARM will not be responsible for reviewing for accuracy when validating your PR.

Expand Down
90 changes: 0 additions & 90 deletions azure-pipelines-autogen.yml

This file was deleted.

69 changes: 0 additions & 69 deletions azure-pipelines-generate-onboarded-report.yml

This file was deleted.

2 changes: 0 additions & 2 deletions generator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
3. `npm install`

### Running commands
* `npm run clean` - Resets the local schemas directory to a clean state.
* `npm run list-basepaths` - Lists all the valid base paths from the specs repo for generation.
* `npm run list-resources` - Lists all the schema-declared types and API versions referenced in [schemas/2019-04-01/deploymentTemplate.json](/schemas/2019-04-01/deploymentTemplate.json).
* `npm run generate-all` - Re-generates all schemas for providers which have been added to [autogenlist.ts](./autogenlist.ts). Run `npm run generate-all -- --help` to see available options.
* `npm run generate-single` - Re-generates schemas for all resource types and API versions found under a given base path. Run `npm run generate-single -- --help` to see available options.
* See [package.json](./package.json) for the full set of commands.
Expand Down
11 changes: 0 additions & 11 deletions generator/cmd/clean.ts

This file was deleted.

Loading

0 comments on commit 7edebc8

Please sign in to comment.