Skip to content
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

tsv auto folder detection for pr pipeline run #24629

Merged
merged 28 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b66e2ed
tsv auto folder detection for pr pipeline run
ckairen Jun 28, 2023
7818abc
get typespec folder script
ckairen Jul 11, 2023
93bb01d
merge main
ckairen Jul 11, 2023
472e6d0
fix ambiguous main
ckairen Jul 11, 2023
85801bd
trigger on tspconfig
ckairen Jul 11, 2023
09e6428
merge main
ckairen Jul 11, 2023
38eead2
cleanup
ckairen Jul 11, 2023
2081891
fixing try catch
ckairen Jul 12, 2023
c84cdc4
fix specs dir
ckairen Jul 12, 2023
5b99a70
fix specs dir
ckairen Jul 12, 2023
61f1873
cleanup
ckairen Jul 12, 2023
38e2205
cleanup
ckairen Jul 12, 2023
75efc3d
tsv local script
ckairen Jul 12, 2023
e1d9e9a
cleanup
ckairen Jul 12, 2023
239b42c
write to std out
ckairen Jul 12, 2023
909325f
write to std out
ckairen Jul 12, 2023
37adb14
Add trailing newline
mikeharder Jul 13, 2023
06055a4
Merge branch 'main' into al/auto-detection
mikeharder Jul 13, 2023
5ef8fab
Merge branch 'main' into al/auto-detection
mikeharder Jul 13, 2023
8f8915a
Remove unused $typespecFolders variable
mikeharder Jul 13, 2023
6b83e5a
Remove unused $typespecFolders variable
mikeharder Jul 13, 2023
54c0b2f
Remove unused $typespecFolders variable
mikeharder Jul 13, 2023
af2a669
Improve displayName
mikeharder Jul 13, 2023
9095230
Rename Get-Typespec-Folders.ps1 to Get-TypeSpec-Folders.ps1
mikeharder Jul 13, 2023
97e4618
Typespec -> TypeSpec
mikeharder Jul 13, 2023
7514081
Typespec -> TypeSpec
mikeharder Jul 13, 2023
77110cf
Rename Validate-Typespec.ps1 to Validate-TypeSpec.ps1
mikeharder Jul 13, 2023
dd1bf28
Typespec -> TypeSpec
mikeharder Jul 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions eng/pipelines/templates/steps/typespec-ci.yml

This file was deleted.

78 changes: 9 additions & 69 deletions eng/pipelines/typespec-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,72 +40,12 @@ jobs:
displayName: npm ls -a
condition: succeededOrFailed()

- template: templates/steps/typespec-ci.yml
parameters:
Folder: specification/contosowidgetmanager/Contoso.WidgetManager
DisplayName: Contoso.WidgetManager

- template: templates/steps/typespec-ci.yml
parameters:
Folder: specification/cognitiveservices/AnomalyDetector
DisplayName: AnomalyDetector

- template: templates/steps/typespec-ci.yml
parameters:
Folder: specification/cognitiveservices/ContentSafety
DisplayName: ContentSafety

- template: templates/steps/typespec-ci.yml
parameters:
Folder: specification/cognitiveservices/HealthInsights/healthinsights.openapi
DisplayName: healthinsights.openapi

- template: templates/steps/typespec-ci.yml
parameters:
Folder: specification/cognitiveservices/HealthInsights/healthinsights.oncophenotype
DisplayName: healthinsights.oncophenotype

- template: templates/steps/typespec-ci.yml
parameters:
Folder: specification/cognitiveservices/HealthInsights/healthinsights.trialmatcher
DisplayName: healthinsights.trialmatcher

- template: templates/steps/typespec-ci.yml
parameters:
Folder: specification/cognitiveservices/OpenAI.Inference
DisplayName: OpenAI.Inference

- template: templates/steps/typespec-ci.yml
parameters:
Folder: specification/confidentialledger/Microsoft.ManagedCcf
DisplayName: ManagedCcf

- template: templates/steps/typespec-ci.yml
parameters:
Folder: specification/containerservice/Fleet.Management
DisplayName: Fleet.Management

- template: templates/steps/typespec-ci.yml
parameters:
Folder: specification/containerstorage/ContainerStorage.Management
DisplayName: ContainerStorage.Management

- template: templates/steps/typespec-ci.yml
parameters:
Folder: specification/eventgrid/Azure.Messaging.EventGrid
DisplayName: Messaging.EventGrid

- template: templates/steps/typespec-ci.yml
parameters:
Folder: specification/servicenetworking/ServiceNetworking.Management
DisplayName: Microsoft.ServiceNetworking

- template: templates/steps/typespec-ci.yml
parameters:
Folder: specification/sphere/Sphere.Management
DisplayName: Sphere.Management

- template: templates/steps/typespec-ci.yml
parameters:
Folder: specification/translation/Azure.AI.TextTranslation
DisplayName: AI.TextTranslation
- pwsh: |
if ('$(Build.Reason)' -eq 'PullRequest') {
$(Build.SourcesDirectory)/eng/scripts/Validate-Typespec.ps1 $(Build.SourcesDirectory) "origin/${env:SYSTEM_PULLREQUEST_TARGETBRANCH}" "${env:SYSTEM_PULLREQUEST_SOURCECOMMITID}"
mikeharder marked this conversation as resolved.
Show resolved Hide resolved
}
else {
$(Build.SourcesDirectory)/eng/scripts/Validate-Typespec.ps1 $(Build.SourcesDirectory)
mikeharder marked this conversation as resolved.
Show resolved Hide resolved
}
displayName: Validate TypeSpec
condition: succeededOrFailed()
27 changes: 27 additions & 0 deletions eng/scripts/Get-Typespec-Folders.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[CmdletBinding()]
param (
[Parameter(Position = 0, Mandatory = $true)]
[string] $SpecsRepoRootDirectory,
[Parameter(Position = 1, Mandatory = $false)]
[string]$TargetBranch,
[Parameter(Position = 2, Mandatory = $false)]
[string]$SourceBranch
)

$tspFiles = @()
if ([string]::IsNullOrEmpty($TargetBranch) -or [string]::IsNullOrEmpty($SourceBranch)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fail with error if exactly one parameter is empty (this should never be valid)

$tspFiles = (Get-ChildItem -path ./specification tspconfig.yaml -Recurse).FullName -replace "$($pwd.Path)/"
}
else {
Write-Host "git -c core.quotepath=off -c i18n.logoutputencoding=utf-8 diff --name-only `"$TargetBranch...$SourceBranch`" -- | Where-Object {`$_.StartsWith('specification')}"
$tspFiles = git -c core.quotepath=off -c i18n.logoutputencoding=utf-8 diff --name-only `"$TargetBranch...$SourceBranch`" -- | Where-Object {$_.StartsWith('specification')}
}

ckairen marked this conversation as resolved.
Show resolved Hide resolved
$typespecFolders = @()
foreach ($file in $tspFiles) {
$file -match 'specification\/[^\/]*\/' | out-null
$typespecFolders += (Get-ChildItem -path $matches[0] tspconfig.yaml -Recurse).Directory.FullName -replace "$($pwd.Path)/"
}
$typespecFolders = $typespecFolders | Select-Object -Unique

return $typespecFolders
ckairen marked this conversation as resolved.
Show resolved Hide resolved
25 changes: 25 additions & 0 deletions eng/scripts/Validate-Typespec.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[CmdletBinding()]
param (
[Parameter(Position = 0, Mandatory = $true)]
[string] $SpecsRepoRootDirectory,
[Parameter(Position = 1, Mandatory = $false)]
[string]$TargetBranch,
[Parameter(Position = 2, Mandatory = $false)]
[string]$SourceBranch
)

$typespecFolders = @()

$typespecFolders = &"$PSScriptRoot/Get-Typespec-Folders.ps1" "$SpecsRepoRootDirectory" "$TargetBranch" "$SourceBranch"
mikeharder marked this conversation as resolved.
Show resolved Hide resolved

$exitCode = 0
foreach ($typespecFolder in $typespecFolders) {
npx --no tsv $typespecFolder 2>&1 | Write-Host
if ($LASTEXITCODE) {
$exitCode = 1
}
git restore .
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add another parameter to control whether the script runs git restore and git clean between folders. In validation pipelines, these commands are good to isolate the diffs caused by each spec folder. But on dev machines, you generally want to leave the files changed in your enlistment so you can view them in an editor, add them to a PR, etc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a dev machine, if validating multiple specs without clean between specs, it means any diffs from earlier specs will cause later specs to fail validation. But I think this is fine. Users will likely review the git diffs in VS Code rather than from the command-line output.

git clean -df
}

exit $exitCode