-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Add Support for Changed Spec Identification in spec-gen-sdk-runner tool #32763
base: main
Are you sure you want to change the base?
Conversation
Next Steps to MergeNext steps that must be taken to merge this PR:
|
PR validation pipeline restarted successfully. If there is ApiView generated, it will be updated in this comment. |
*/ | ||
export async function resetGitRepo(repoPath: string): Promise<void> { | ||
try { | ||
const { stderr } = await execAsync("git clean -fd && git reset --hard HEAD", { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const { stderr } = await execAsync("git clean -fd && git reset --hard HEAD", { | |
const { stderr } = await execAsync("git clean -fdx && git reset --hard HEAD", { |
Add x so ignored files also get deleted. Will reset HEAD be correct? It will only work if we haven't create a new branch and committed those changes, or do we just need a clean git status?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'reset' HEAD is needed to remove any modifications to the tracked files.
const workingFolder = "."; | ||
const workPath = path.resolve(process.cwd(), workingFolder, options.specFolder, searchPath); | ||
// Execute the git command using exec | ||
const { stdout, stderr } = await execAsync(`git ls-tree ${options.treeId} ${workPath}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we use a git command here instead of just traversing the file system? I would expect by the name of this function we are only looking at the files on disk.
logMessage("No files changed in the PR"); | ||
} | ||
logMessage(`Changed files in the PR: ${prChangedFiles.length}`); | ||
const fileList = prChangedFiles.filter((p) => !p.includes("/scenarios/")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is special about "scenarios" here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We intend to exclude SDK generation for changes coming from the scenarios
folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are also other paths like examples should those be included? I'm mostly asking this question as it seems a little odd to only figure out this one folder type if what you are looking for is json files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some other file types also need to be included, such as *.tsp, tspconfig.yaml, readme.md
.
Changes in the examples
folder would need to trigger the automation run because samples would be used in the SDK test/sample generation step. I am not aware of any other folders we might have in the specification folder. I will also add 'specification' to the filter.
const { stdout: headCommitRaw } = await execAsync("git rev-parse HEAD"); | ||
const headCommit = headCommitRaw.trim(); // Trim any newline characters | ||
const { stdout: treeIdRaw } = await execAsync(`git rev-parse ${headCommit}^{tree}`); | ||
const treeId = treeIdRaw.trim(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we looking at git here? We should just be using the files on disk and assume that repo is correctly checked out.
Major changes are to identify the changed specs to pass into the
spec-gen-sdk
tool for SDK generation.[
eng/pipelines/templates/stages/archetype-spec-gen-sdk.yml
]Updated the
parameters
section to includeUse1ESOfficial: false
and increased the job timeout to 2400 minutes.[
eng/tools/spec-gen-sdk-runner/src/change-files.ts
]Introduced a new function
detectChangedSpecConfigFiles
to detect changed specification configuration files in a pull request. This function identifies relatedreadme.md
andtspconfig.yaml
files and logs the changes.[
eng/tools/spec-gen-sdk-runner/src/commands.ts
]Added a new function
generateSdkForSpecPr
to generate SDKs for specification pull requests.[
eng/tools/spec-gen-sdk-runner/src/utils.ts
]Added a new utility function
resetGitRepo
to reset unstaged changes in a git repository.@weshaggard can you review these changes?