-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[EngSys] add SDK Automation validation to dev-tool CI #36821
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
Open
jeremymeng
wants to merge
9
commits into
Azure:main
Choose a base branch
from
jeremymeng:engsys/sdk-automation-ci
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4772b6e
[EngSys] add SDK Automation validation to dev-tool CI
jeremymeng de17d8d
address CR feedback
jeremymeng c14edbc
fix
jeremymeng 4702382
use "main" as default spec commit id
jeremymeng ea4d845
enable ApiView change detection
jeremymeng 03b8464
Revert "enable ApiView change detection"
jeremymeng 80acce9
Synthesize a spec-gen-sdk-artifact.json to create apiview
jeremymeng bf60a76
add missing script
jeremymeng 65878b1
fix filename
jeremymeng 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,66 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| // this script reads a tspconfig.yaml file and synthesize a spec-gen-sdk-artifiact.json | ||
| // to pass to eng/common/scripts/Helpers/ApiView-Helpers.ps1 Create-API-Review | ||
|
|
||
| const process = require("process"); | ||
| const path = require("path"); | ||
| const fs = require("fs"); | ||
| const yaml = require("yaml"); | ||
|
|
||
| const tspconfigPath = process.argv[2]; | ||
| if (!tspconfigPath) { | ||
| console.error("Please provide a path to tspconfig.yaml"); | ||
| process.exit(1); | ||
| } | ||
| // if the path is not full path, resolve it related to current working directory | ||
| const resolvedTspconfigPath = path.isAbsolute(tspconfigPath) | ||
| ? tspconfigPath | ||
| : path.normalize(path.join(process.cwd(), tspconfigPath)); | ||
|
|
||
| if (!fs.existsSync(resolvedTspconfigPath)) { | ||
| console.error(`The file ${resolvedTspconfigPath} does not exist`); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| const tspconfigContent = fs.readFileSync(tspconfigPath, "utf8"); | ||
| const tspconfig = yaml.parse(tspconfigContent); | ||
|
|
||
| const tsEmitterOutputDir = | ||
| tspconfig["options"]?.["@azure-tools/typespec-ts"]?.["emitter-output-dir"]; | ||
| if (!tsEmitterOutputDir) { | ||
| console.error( | ||
| "The tspconfig.yaml does not have @azure-tools/typespec-ts emitter-output-dir option", | ||
| ); | ||
| process.exit(1); | ||
| } | ||
| const paramters = tspconfig.parameters; | ||
| const updatedTsEmitterOutputDir = tsEmitterOutputDir | ||
| .replace("{service-dir}", paramters["service-dir"]["default"]) | ||
| .replace("{output-dir}/", ""); | ||
| const jsRepoPath = path.normalize(path.join(process.argv[1], "../../../../")); | ||
| const packageJsonPath = path.join(jsRepoPath, updatedTsEmitterOutputDir, "package.json"); | ||
| if (!fs.existsSync(packageJsonPath)) { | ||
| console.error( | ||
| `The resolved package directory ${jsRepoPath}/${updatedTsEmitterOutputDir} does not contains a package.json`, | ||
| ); | ||
| process.exit(1); | ||
| } | ||
| const packageJsonContent = fs.readFileSync(packageJsonPath, "utf8"); | ||
| const packageJson = JSON.parse(packageJsonContent); | ||
| const unscopedPackageName = packageJson.name.startsWith("@") | ||
| ? packageJson.name.split("/")[1] | ||
| : packageJson.name; | ||
| const specGenArtifact = { | ||
| language: "azure-sdk-for-js", | ||
| apiViewRequestData: [ | ||
| { | ||
| packageName: packageJson.name, | ||
| filePath: `${packageJson.name}/${unscopedPackageName}-node.api.json`, | ||
| }, | ||
| ], | ||
| }; | ||
| console.log(JSON.stringify(specGenArtifact, null, 2)); |
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
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.