-
Notifications
You must be signed in to change notification settings - Fork 235
Support CI.yml provisioning and updates with cli #14432
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
skywing918
wants to merge
13
commits into
main
Choose a base branch
from
updateCi
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.
+668
−6
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
2cff5b1
Add generate-ci-yaml command
cf7938e
Add CI YAML template and implement data plane CI YAML creation and up…
14a1a05
Remove SDK type check for CI YAML generation in generateCiYamlCli
9e263a6
Refactor CI YAML handling: remove feature branch exclusion and update…
41a7280
Update tools/js-sdk-release-tools/src/generateCiYamlCli.ts
skywing918 d6747a2
Update tools/js-sdk-release-tools/src/common/ciYamlUtils.ts
skywing918 b7c2707
Fix service directory path assignment in CI YAML functions
4764f20
Enhance CI YAML handling: add path normalization and streamline path …
2039dc9
Refactor data plane CI YAML functions: update parameter handling and …
2275cab
Merge branch 'main' into updateCi
skywing918 9f3ced8
Add unit tests for createOrUpdateCiYaml function in ciYamlUtils
e1c04a6
Remove unused pathInclude function from ciYamlUtils
22467c1
Add tests for edge cases in updateDataPlaneCiYaml function in ciYamlU…
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
Some comments aren't visible on the classic Files Changed page.
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
30 changes: 30 additions & 0 deletions
30
tools/js-sdk-release-tools/src/common/ciYamlTemplates/ci.template.yml
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,30 @@ | ||
| # NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. | ||
|
|
||
| trigger: | ||
| branches: | ||
| include: | ||
| - main | ||
| - release/* | ||
| - hotfix/* | ||
| paths: | ||
| include: null | ||
|
|
||
| pr: | ||
| branches: | ||
| include: | ||
| - main | ||
| - feature/* | ||
| - release/* | ||
| - hotfix/* | ||
| exclude: | ||
| - feature/v4 | ||
| paths: | ||
| include: null | ||
|
|
||
| extends: | ||
| template: /eng/pipelines/templates/stages/archetype-sdk-client.yml | ||
| parameters: | ||
| ServiceDirectory: null | ||
| Artifacts: | ||
| - name: null | ||
| safeName: null |
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
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,75 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| import commandLineArgs from "command-line-args"; | ||
| import { createOrUpdateCiYaml } from "./common/ciYamlUtils.js"; | ||
| import { getNpmPackageInfo, getNpmPackageName } from "./common/npmUtils.js"; | ||
| import { VersionPolicyName } from "./common/types.js"; | ||
| import { logger } from "./utils/logger.js"; | ||
| import path from "path"; | ||
|
|
||
| const generateCiYamlCli = async ( | ||
skywing918 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| sdkRepoPath: string | undefined, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will this CLI be used directly in inner loop? Need to confirm whether we had the agreement about the input/output of this too. Please check with Ray for more clarification. |
||
| packageFolderPath: string | undefined | ||
| ) => { | ||
| if (!sdkRepoPath || !packageFolderPath) { | ||
| logger.error(`SdkRepoPath and PackagePath are required.`); | ||
| logger.error( | ||
| `Usage: generate-ci-yaml --sdkRepoPath <SdkRepoPath> --packagePath <PackagePath>` | ||
| ); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| // Calculate relative path from sdkRepoPath to packagePath | ||
| const normalizedSdkRepoPath = path.resolve(sdkRepoPath); | ||
| const absolutePackagePath = path.resolve(packageFolderPath); | ||
| const relativePackagePath = path.relative(normalizedSdkRepoPath, absolutePackagePath); | ||
|
|
||
| // Validate that the package path is safely inside the SDK repo path. | ||
| // Reject obvious path traversal attempts such as absolute paths outside the repo | ||
| // or relative paths that start with "..". | ||
| const normalizedSdkRepoPathWithSep = normalizedSdkRepoPath.endsWith(path.sep) | ||
| ? normalizedSdkRepoPath | ||
| : normalizedSdkRepoPath + path.sep; | ||
|
|
||
| const isRelativeTraversal = | ||
| !path.isAbsolute(packageFolderPath) && | ||
| (packageFolderPath === ".." || packageFolderPath.startsWith(".." + path.sep)); | ||
|
|
||
| const isOutsideRepoByPrefix = !absolutePackagePath.startsWith(normalizedSdkRepoPathWithSep); | ||
|
|
||
| const isOutsideRepoByRelative = | ||
| relativePackagePath === ".." || relativePackagePath.startsWith(".." + path.sep); | ||
|
|
||
| if (isRelativeTraversal || isOutsideRepoByPrefix || isOutsideRepoByRelative) { | ||
| logger.error( | ||
| `The provided packagePath ("${packageFolderPath}") resolves outside the sdkRepoPath ("${sdkRepoPath}"). ` + | ||
| `Please provide a package path that is within the SDK repository root.` | ||
| ); | ||
| process.exit(1); | ||
| } | ||
| logger.info(`SDK Repo Path: ${normalizedSdkRepoPath}`); | ||
| logger.info(`Package Path (absolute): ${absolutePackagePath}`); | ||
| logger.info(`Package Path (relative): ${relativePackagePath}`); | ||
|
|
||
| const npmPackageInfo = await getNpmPackageInfo(absolutePackagePath); | ||
| const packageName = getNpmPackageName(npmPackageInfo); | ||
| const versionPolicyName: VersionPolicyName = packageName.includes("arm-") ? "management" : "client"; | ||
| logger.info(`Detected versionPolicyName: ${versionPolicyName} for package: ${packageName}`); | ||
|
|
||
| const ciPath = await createOrUpdateCiYaml( | ||
| relativePackagePath.replace(/\\/g, "/"), | ||
| versionPolicyName, | ||
| npmPackageInfo | ||
| ); | ||
|
|
||
| logger.info(`CI yaml file created/updated at: ${ciPath}`); | ||
| }; | ||
|
|
||
| const optionDefinitions = [ | ||
| { name: "sdkRepoPath", type: String }, | ||
| { name: "packagePath", type: String }, | ||
| ]; | ||
|
|
||
| const options = commandLineArgs(optionDefinitions); | ||
|
|
||
| generateCiYamlCli(options["sdkRepoPath"], options["packagePath"]); | ||
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.