From 315855a5f988d36e2de3330a0e269c54a4b0be2a Mon Sep 17 00:00:00 2001 From: Albert Date: Thu, 13 Jul 2023 17:43:21 -0700 Subject: [PATCH 01/26] testing --- .../Widgets_GetWidgetOperationStatusSample.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/contosowidgetmanager/Contoso.WidgetManager/examples/2022-11-01-preview/Widgets_GetWidgetOperationStatusSample.json b/specification/contosowidgetmanager/Contoso.WidgetManager/examples/2022-11-01-preview/Widgets_GetWidgetOperationStatusSample.json index 3d3b76b030dc..4279adff8687 100644 --- a/specification/contosowidgetmanager/Contoso.WidgetManager/examples/2022-11-01-preview/Widgets_GetWidgetOperationStatusSample.json +++ b/specification/contosowidgetmanager/Contoso.WidgetManager/examples/2022-11-01-preview/Widgets_GetWidgetOperationStatusSample.json @@ -7,7 +7,7 @@ "api-version": "2022-11-01-preview" }, "responses": { - "200": { + "200": { assdf "body": { "id": "opreation id1", "status": "InProgress", From 632a2c6ba9bf15de3865be8ca3238c56dbaf003c Mon Sep 17 00:00:00 2001 From: Albert Date: Thu, 13 Jul 2023 18:19:41 -0700 Subject: [PATCH 02/26] tsv noop on no typespec diff --- eng/scripts/Validate-TypeSpec.ps1 | 1 + .../Widgets_GetWidgetOperationStatusSample.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/eng/scripts/Validate-TypeSpec.ps1 b/eng/scripts/Validate-TypeSpec.ps1 index 7bd3171d001f..1cee4d764030 100644 --- a/eng/scripts/Validate-TypeSpec.ps1 +++ b/eng/scripts/Validate-TypeSpec.ps1 @@ -11,6 +11,7 @@ param ( $typespecFolders = @() $typespecFolders = &"$PSScriptRoot/Get-TypeSpec-Folders.ps1" "$SpecsRepoRootDirectory" "$TargetBranch" "$SourceBranch" +$typespecFolders = $typespecFolders.Split('',[System.StringSplitOptions]::RemoveEmptyEntries) $exitCode = 0 foreach ($typespecFolder in $typespecFolders) { diff --git a/specification/contosowidgetmanager/Contoso.WidgetManager/examples/2022-11-01-preview/Widgets_GetWidgetOperationStatusSample.json b/specification/contosowidgetmanager/Contoso.WidgetManager/examples/2022-11-01-preview/Widgets_GetWidgetOperationStatusSample.json index 4279adff8687..3d3b76b030dc 100644 --- a/specification/contosowidgetmanager/Contoso.WidgetManager/examples/2022-11-01-preview/Widgets_GetWidgetOperationStatusSample.json +++ b/specification/contosowidgetmanager/Contoso.WidgetManager/examples/2022-11-01-preview/Widgets_GetWidgetOperationStatusSample.json @@ -7,7 +7,7 @@ "api-version": "2022-11-01-preview" }, "responses": { - "200": { assdf + "200": { "body": { "id": "opreation id1", "status": "InProgress", From dd16d3de9d7fca75cf4a8e9b50f814f2452616da Mon Sep 17 00:00:00 2001 From: Albert Date: Thu, 13 Jul 2023 19:20:38 -0700 Subject: [PATCH 03/26] windows linux directory slash --- eng/scripts/Get-TypeSpec-Folders.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/scripts/Get-TypeSpec-Folders.ps1 b/eng/scripts/Get-TypeSpec-Folders.ps1 index 4271184ca72b..7e75ba69ef3b 100644 --- a/eng/scripts/Get-TypeSpec-Folders.ps1 +++ b/eng/scripts/Get-TypeSpec-Folders.ps1 @@ -10,7 +10,7 @@ param ( $tspFiles = @() if ([string]::IsNullOrEmpty($TargetBranch) -or [string]::IsNullOrEmpty($SourceBranch)) { - $tspFiles = (Get-ChildItem -path ./specification tspconfig.yaml -Recurse).FullName -replace "$($pwd.Path)/" + $tspFiles = (Get-ChildItem -path ./specification tspconfig.yaml -Recurse).FullName -replace "$($pwd.Path)$([IO.Path]::DirectorySeparatorChar)" } else { Write-Host "git -c core.quotepath=off -c i18n.logoutputencoding=utf-8 diff --name-only `"$TargetBranch...$SourceBranch`" -- | Where-Object {`$_.StartsWith('specification')}" @@ -20,7 +20,7 @@ else { $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 += (Get-ChildItem -path $matches[0] tspconfig.yaml -Recurse).Directory.FullName -replace "$($pwd.Path)$([IO.Path]::DirectorySeparatorChar)" } $typespecFolders = $typespecFolders | Select-Object -Unique From 8dc59c96fb56ee194546bd41656dad5a8c31f1ca Mon Sep 17 00:00:00 2001 From: Albert Date: Thu, 13 Jul 2023 19:31:43 -0700 Subject: [PATCH 04/26] test --- eng/pipelines/typespec-ci.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/eng/pipelines/typespec-ci.yml b/eng/pipelines/typespec-ci.yml index 08d97f68faae..cb87b9e27eb2 100644 --- a/eng/pipelines/typespec-ci.yml +++ b/eng/pipelines/typespec-ci.yml @@ -20,9 +20,19 @@ pr: jobs: - job: Validate_All_Specs + + strategy: + matrix: + Linux: + Pool: azsdk-pool-mms-ubuntu-2204-general + OsVmImage: ubuntu-22.04 + Windows: + Pool: azsdk-pool-mms-win-2022-general + OsVmImage: windows-2022 + pool: - name: azsdk-pool-mms-ubuntu-2204-general - vmImage: ubuntu-22.04 + name: $(Pool) + vmImage: $(OSVmImage) steps: - script: npm ci From 6331a77db95d7541e541f48db9398c9a8dd617b5 Mon Sep 17 00:00:00 2001 From: Albert Date: Thu, 13 Jul 2023 19:38:43 -0700 Subject: [PATCH 05/26] escaping backward slash for regex --- eng/scripts/Get-TypeSpec-Folders.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/scripts/Get-TypeSpec-Folders.ps1 b/eng/scripts/Get-TypeSpec-Folders.ps1 index 7e75ba69ef3b..358ce7f74b77 100644 --- a/eng/scripts/Get-TypeSpec-Folders.ps1 +++ b/eng/scripts/Get-TypeSpec-Folders.ps1 @@ -10,7 +10,7 @@ param ( $tspFiles = @() if ([string]::IsNullOrEmpty($TargetBranch) -or [string]::IsNullOrEmpty($SourceBranch)) { - $tspFiles = (Get-ChildItem -path ./specification tspconfig.yaml -Recurse).FullName -replace "$($pwd.Path)$([IO.Path]::DirectorySeparatorChar)" + $tspFiles = (Get-ChildItem -path ./specification tspconfig.yaml -Recurse).FullName -replace [Regex]::Escape("$($pwd.Path)$([IO.Path]::DirectorySeparatorChar)") } else { Write-Host "git -c core.quotepath=off -c i18n.logoutputencoding=utf-8 diff --name-only `"$TargetBranch...$SourceBranch`" -- | Where-Object {`$_.StartsWith('specification')}" From 764a70951d5531840f7fa4d2cec9d8ed8c13a326 Mon Sep 17 00:00:00 2001 From: Albert Date: Thu, 13 Jul 2023 19:45:56 -0700 Subject: [PATCH 06/26] avoid null array --- eng/scripts/Get-TypeSpec-Folders.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/scripts/Get-TypeSpec-Folders.ps1 b/eng/scripts/Get-TypeSpec-Folders.ps1 index 358ce7f74b77..482b9350051e 100644 --- a/eng/scripts/Get-TypeSpec-Folders.ps1 +++ b/eng/scripts/Get-TypeSpec-Folders.ps1 @@ -10,7 +10,7 @@ param ( $tspFiles = @() if ([string]::IsNullOrEmpty($TargetBranch) -or [string]::IsNullOrEmpty($SourceBranch)) { - $tspFiles = (Get-ChildItem -path ./specification tspconfig.yaml -Recurse).FullName -replace [Regex]::Escape("$($pwd.Path)$([IO.Path]::DirectorySeparatorChar)") + $tspFiles = (Get-ChildItem -path ./specification tspconfig.yaml -Recurse)?.FullName -replace [Regex]::Escape("$($pwd.Path)$([IO.Path]::DirectorySeparatorChar)") } else { Write-Host "git -c core.quotepath=off -c i18n.logoutputencoding=utf-8 diff --name-only `"$TargetBranch...$SourceBranch`" -- | Where-Object {`$_.StartsWith('specification')}" From 6103296fc3527fcd5a3dc515d3d93b169f3871d7 Mon Sep 17 00:00:00 2001 From: Albert Date: Thu, 13 Jul 2023 19:58:28 -0700 Subject: [PATCH 07/26] fix index null array bug --- eng/scripts/Get-TypeSpec-Folders.ps1 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/eng/scripts/Get-TypeSpec-Folders.ps1 b/eng/scripts/Get-TypeSpec-Folders.ps1 index 482b9350051e..7d33077255ea 100644 --- a/eng/scripts/Get-TypeSpec-Folders.ps1 +++ b/eng/scripts/Get-TypeSpec-Folders.ps1 @@ -9,8 +9,9 @@ param ( ) $tspFiles = @() +$osSlash = [IO.Path]::DirectorySeparatorChar if ([string]::IsNullOrEmpty($TargetBranch) -or [string]::IsNullOrEmpty($SourceBranch)) { - $tspFiles = (Get-ChildItem -path ./specification tspconfig.yaml -Recurse)?.FullName -replace [Regex]::Escape("$($pwd.Path)$([IO.Path]::DirectorySeparatorChar)") + $tspFiles = (Get-ChildItem -path ./specification tspconfig.yaml -Recurse).FullName -replace [Regex]::Escape("$($pwd.Path)$osSlash") } else { Write-Host "git -c core.quotepath=off -c i18n.logoutputencoding=utf-8 diff --name-only `"$TargetBranch...$SourceBranch`" -- | Where-Object {`$_.StartsWith('specification')}" @@ -19,8 +20,10 @@ else { $typespecFolders = @() foreach ($file in $tspFiles) { - $file -match 'specification\/[^\/]*\/' | out-null - $typespecFolders += (Get-ChildItem -path $matches[0] tspconfig.yaml -Recurse).Directory.FullName -replace "$($pwd.Path)$([IO.Path]::DirectorySeparatorChar)" + $file -match "specification\$osSlash[^\$osSlash]*\$osSlash" | out-null + if ($matches) { + $typespecFolders += (Get-ChildItem -path $matches[0] tspconfig.yaml -Recurse).Directory.FullName -replace "$($pwd.Path)$osSlash" + } } $typespecFolders = $typespecFolders | Select-Object -Unique From c5a59b6584a6247b584f39217b731e747cc14b45 Mon Sep 17 00:00:00 2001 From: Albert Date: Thu, 13 Jul 2023 20:05:47 -0700 Subject: [PATCH 08/26] stringify osslash --- eng/scripts/Get-TypeSpec-Folders.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/scripts/Get-TypeSpec-Folders.ps1 b/eng/scripts/Get-TypeSpec-Folders.ps1 index 7d33077255ea..583aef6b583e 100644 --- a/eng/scripts/Get-TypeSpec-Folders.ps1 +++ b/eng/scripts/Get-TypeSpec-Folders.ps1 @@ -9,7 +9,7 @@ param ( ) $tspFiles = @() -$osSlash = [IO.Path]::DirectorySeparatorChar +$osSlash = "$([IO.Path]::DirectorySeparatorChar)" if ([string]::IsNullOrEmpty($TargetBranch) -or [string]::IsNullOrEmpty($SourceBranch)) { $tspFiles = (Get-ChildItem -path ./specification tspconfig.yaml -Recurse).FullName -replace [Regex]::Escape("$($pwd.Path)$osSlash") } From 46b5f85608552f025a20dd76a019948f628f0824 Mon Sep 17 00:00:00 2001 From: Albert Date: Thu, 13 Jul 2023 20:11:58 -0700 Subject: [PATCH 09/26] regex escape --- eng/scripts/Get-TypeSpec-Folders.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/scripts/Get-TypeSpec-Folders.ps1 b/eng/scripts/Get-TypeSpec-Folders.ps1 index 583aef6b583e..aec1b7e39282 100644 --- a/eng/scripts/Get-TypeSpec-Folders.ps1 +++ b/eng/scripts/Get-TypeSpec-Folders.ps1 @@ -9,7 +9,7 @@ param ( ) $tspFiles = @() -$osSlash = "$([IO.Path]::DirectorySeparatorChar)" +$osSlash = [IO.Path]::DirectorySeparatorChar if ([string]::IsNullOrEmpty($TargetBranch) -or [string]::IsNullOrEmpty($SourceBranch)) { $tspFiles = (Get-ChildItem -path ./specification tspconfig.yaml -Recurse).FullName -replace [Regex]::Escape("$($pwd.Path)$osSlash") } @@ -22,7 +22,7 @@ $typespecFolders = @() foreach ($file in $tspFiles) { $file -match "specification\$osSlash[^\$osSlash]*\$osSlash" | out-null if ($matches) { - $typespecFolders += (Get-ChildItem -path $matches[0] tspconfig.yaml -Recurse).Directory.FullName -replace "$($pwd.Path)$osSlash" + $typespecFolders += (Get-ChildItem -path $matches[0] tspconfig.yaml -Recurse).Directory.FullName -replace [Regex]::Escape("$($pwd.Path)$osSlash") } } $typespecFolders = $typespecFolders | Select-Object -Unique From d4a22cf686e4c9f7110afa95388a6afacb0a552c Mon Sep 17 00:00:00 2001 From: Albert Date: Thu, 13 Jul 2023 20:30:54 -0700 Subject: [PATCH 10/26] tsv path separator --- eng/tools/TypeSpecValidation/src/TypeSpecValidation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/tools/TypeSpecValidation/src/TypeSpecValidation.ts b/eng/tools/TypeSpecValidation/src/TypeSpecValidation.ts index 447f73d6ecae..83167b1507b0 100755 --- a/eng/tools/TypeSpecValidation/src/TypeSpecValidation.ts +++ b/eng/tools/TypeSpecValidation/src/TypeSpecValidation.ts @@ -69,7 +69,7 @@ export async function main() { } // Format parent folder to include shared files - await runCmd(`npx tsp format ../**/*.tsp`, folder); + await runCmd(`npx tsp format ..${path.sep}**${path.sep}*.tsp`, folder); // Verify generated swagger file is in sync with one on disk const git = simpleGit(); From c9c2596feff0cbeb523660e152c059d02b941dfa Mon Sep 17 00:00:00 2001 From: Albert Date: Thu, 13 Jul 2023 20:35:29 -0700 Subject: [PATCH 11/26] test --- eng/tools/TypeSpecValidation/src/TypeSpecValidation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/tools/TypeSpecValidation/src/TypeSpecValidation.ts b/eng/tools/TypeSpecValidation/src/TypeSpecValidation.ts index 83167b1507b0..24a56da8cc9e 100755 --- a/eng/tools/TypeSpecValidation/src/TypeSpecValidation.ts +++ b/eng/tools/TypeSpecValidation/src/TypeSpecValidation.ts @@ -69,7 +69,7 @@ export async function main() { } // Format parent folder to include shared files - await runCmd(`npx tsp format ..${path.sep}**${path.sep}*.tsp`, folder); + //await runCmd(`npx tsp format ..${path.sep}**${path.sep}*.tsp`, folder); // Verify generated swagger file is in sync with one on disk const git = simpleGit(); From 8bcf6448f926e85b7ce88fa7e229a3898dcf588f Mon Sep 17 00:00:00 2001 From: Albert Date: Thu, 13 Jul 2023 20:39:44 -0700 Subject: [PATCH 12/26] revert testing --- eng/tools/TypeSpecValidation/src/TypeSpecValidation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/tools/TypeSpecValidation/src/TypeSpecValidation.ts b/eng/tools/TypeSpecValidation/src/TypeSpecValidation.ts index 24a56da8cc9e..83167b1507b0 100755 --- a/eng/tools/TypeSpecValidation/src/TypeSpecValidation.ts +++ b/eng/tools/TypeSpecValidation/src/TypeSpecValidation.ts @@ -69,7 +69,7 @@ export async function main() { } // Format parent folder to include shared files - //await runCmd(`npx tsp format ..${path.sep}**${path.sep}*.tsp`, folder); + await runCmd(`npx tsp format ..${path.sep}**${path.sep}*.tsp`, folder); // Verify generated swagger file is in sync with one on disk const git = simpleGit(); From 974a65e5c252af92dcf415a8fe12595242a66568 Mon Sep 17 00:00:00 2001 From: Albert Date: Tue, 18 Jul 2023 12:32:13 -0700 Subject: [PATCH 13/26] cleaner windows separator --- eng/scripts/Get-TypeSpec-Folders.ps1 | 9 ++++----- eng/tools/TypeSpecValidation/src/TypeSpecValidation.ts | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/eng/scripts/Get-TypeSpec-Folders.ps1 b/eng/scripts/Get-TypeSpec-Folders.ps1 index aec1b7e39282..bdd0f47697a7 100644 --- a/eng/scripts/Get-TypeSpec-Folders.ps1 +++ b/eng/scripts/Get-TypeSpec-Folders.ps1 @@ -9,9 +9,9 @@ param ( ) $tspFiles = @() -$osSlash = [IO.Path]::DirectorySeparatorChar +$sanitizedPwd = $($pwd.path) -replace '\\', '/' if ([string]::IsNullOrEmpty($TargetBranch) -or [string]::IsNullOrEmpty($SourceBranch)) { - $tspFiles = (Get-ChildItem -path ./specification tspconfig.yaml -Recurse).FullName -replace [Regex]::Escape("$($pwd.Path)$osSlash") + $tspFiles = (Get-ChildItem -path ./specification tspconfig.yaml -Recurse).FullName -replace '\\', '/' | ForEach-Object {[IO.Path]::GetRelativePath($sanitizedPwd, $_)} } else { Write-Host "git -c core.quotepath=off -c i18n.logoutputencoding=utf-8 diff --name-only `"$TargetBranch...$SourceBranch`" -- | Where-Object {`$_.StartsWith('specification')}" @@ -20,9 +20,8 @@ else { $typespecFolders = @() foreach ($file in $tspFiles) { - $file -match "specification\$osSlash[^\$osSlash]*\$osSlash" | out-null - if ($matches) { - $typespecFolders += (Get-ChildItem -path $matches[0] tspconfig.yaml -Recurse).Directory.FullName -replace [Regex]::Escape("$($pwd.Path)$osSlash") + if ($file -match 'specification\/[^\/]*\/') { + $typespecFolders += (Get-ChildItem -path $matches[0] tspconfig.yaml -Recurse).Directory.FullName -replace '\\', '/' | ForEach-Object {[IO.Path]::GetRelativePath($sanitizedPwd, $_)} } } $typespecFolders = $typespecFolders | Select-Object -Unique diff --git a/eng/tools/TypeSpecValidation/src/TypeSpecValidation.ts b/eng/tools/TypeSpecValidation/src/TypeSpecValidation.ts index 83167b1507b0..447f73d6ecae 100755 --- a/eng/tools/TypeSpecValidation/src/TypeSpecValidation.ts +++ b/eng/tools/TypeSpecValidation/src/TypeSpecValidation.ts @@ -69,7 +69,7 @@ export async function main() { } // Format parent folder to include shared files - await runCmd(`npx tsp format ..${path.sep}**${path.sep}*.tsp`, folder); + await runCmd(`npx tsp format ../**/*.tsp`, folder); // Verify generated swagger file is in sync with one on disk const git = simpleGit(); From 4647d0e507f2a832e1478ae0e8cfc4b0786375ec Mon Sep 17 00:00:00 2001 From: Albert Date: Tue, 18 Jul 2023 12:40:22 -0700 Subject: [PATCH 14/26] windwos separator sanitization --- eng/scripts/Get-TypeSpec-Folders.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/eng/scripts/Get-TypeSpec-Folders.ps1 b/eng/scripts/Get-TypeSpec-Folders.ps1 index bdd0f47697a7..5ab0225c5a4c 100644 --- a/eng/scripts/Get-TypeSpec-Folders.ps1 +++ b/eng/scripts/Get-TypeSpec-Folders.ps1 @@ -17,6 +17,7 @@ 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')} } +$tspFile -replace '\\', '/' $typespecFolders = @() foreach ($file in $tspFiles) { From e77e1267197546e16105b14502b25da3cb570509 Mon Sep 17 00:00:00 2001 From: Albert Date: Tue, 18 Jul 2023 23:25:53 -0700 Subject: [PATCH 15/26] debug --- eng/scripts/Get-TypeSpec-Folders.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/scripts/Get-TypeSpec-Folders.ps1 b/eng/scripts/Get-TypeSpec-Folders.ps1 index 5ab0225c5a4c..bfa586b9f3ed 100644 --- a/eng/scripts/Get-TypeSpec-Folders.ps1 +++ b/eng/scripts/Get-TypeSpec-Folders.ps1 @@ -17,7 +17,7 @@ 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')} } -$tspFile -replace '\\', '/' +$tspFiles -replace '\\', '/' $typespecFolders = @() foreach ($file in $tspFiles) { From 3ad7a22e640189b0776992a6ec91f7937996f66b Mon Sep 17 00:00:00 2001 From: Albert Date: Tue, 18 Jul 2023 23:52:34 -0700 Subject: [PATCH 16/26] get dir --- eng/scripts/Get-TypeSpec-Folders.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/scripts/Get-TypeSpec-Folders.ps1 b/eng/scripts/Get-TypeSpec-Folders.ps1 index bfa586b9f3ed..db0ac3e44e4c 100644 --- a/eng/scripts/Get-TypeSpec-Folders.ps1 +++ b/eng/scripts/Get-TypeSpec-Folders.ps1 @@ -11,7 +11,7 @@ param ( $tspFiles = @() $sanitizedPwd = $($pwd.path) -replace '\\', '/' if ([string]::IsNullOrEmpty($TargetBranch) -or [string]::IsNullOrEmpty($SourceBranch)) { - $tspFiles = (Get-ChildItem -path ./specification tspconfig.yaml -Recurse).FullName -replace '\\', '/' | ForEach-Object {[IO.Path]::GetRelativePath($sanitizedPwd, $_)} + $tspFiles = (Get-ChildItem -path ./specification tspconfig.yaml -Recurse).Directory.FullName -replace '\\', '/' | ForEach-Object {[IO.Path]::GetRelativePath($sanitizedPwd, $_)} } else { Write-Host "git -c core.quotepath=off -c i18n.logoutputencoding=utf-8 diff --name-only `"$TargetBranch...$SourceBranch`" -- | Where-Object {`$_.StartsWith('specification')}" From 834e1ded4b8c8d627013c45adcf0da8dccc21799 Mon Sep 17 00:00:00 2001 From: Albert Cheng <38804567+ckairen@users.noreply.github.com> Date: Wed, 19 Jul 2023 14:43:55 -0700 Subject: [PATCH 17/26] Update eng/pipelines/typespec-ci.yml --- eng/pipelines/typespec-ci.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/eng/pipelines/typespec-ci.yml b/eng/pipelines/typespec-ci.yml index cb87b9e27eb2..b5c287bdebdd 100644 --- a/eng/pipelines/typespec-ci.yml +++ b/eng/pipelines/typespec-ci.yml @@ -20,16 +20,6 @@ pr: jobs: - job: Validate_All_Specs - - strategy: - matrix: - Linux: - Pool: azsdk-pool-mms-ubuntu-2204-general - OsVmImage: ubuntu-22.04 - Windows: - Pool: azsdk-pool-mms-win-2022-general - OsVmImage: windows-2022 - pool: name: $(Pool) vmImage: $(OSVmImage) From bf7de414688fe7249ee6cfa34eca39114c107c34 Mon Sep 17 00:00:00 2001 From: Albert Cheng <38804567+ckairen@users.noreply.github.com> Date: Wed, 19 Jul 2023 14:44:10 -0700 Subject: [PATCH 18/26] Update eng/pipelines/typespec-ci.yml --- eng/pipelines/typespec-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/pipelines/typespec-ci.yml b/eng/pipelines/typespec-ci.yml index b5c287bdebdd..08d97f68faae 100644 --- a/eng/pipelines/typespec-ci.yml +++ b/eng/pipelines/typespec-ci.yml @@ -21,8 +21,8 @@ pr: jobs: - job: Validate_All_Specs pool: - name: $(Pool) - vmImage: $(OSVmImage) + name: azsdk-pool-mms-ubuntu-2204-general + vmImage: ubuntu-22.04 steps: - script: npm ci From 921431ab44605798d6e6d778a41cd99d964d5769 Mon Sep 17 00:00:00 2001 From: Albert Date: Thu, 20 Jul 2023 11:03:37 -0700 Subject: [PATCH 19/26] replace --- eng/scripts/Get-TypeSpec-Folders.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eng/scripts/Get-TypeSpec-Folders.ps1 b/eng/scripts/Get-TypeSpec-Folders.ps1 index db0ac3e44e4c..5f54ba146fbf 100644 --- a/eng/scripts/Get-TypeSpec-Folders.ps1 +++ b/eng/scripts/Get-TypeSpec-Folders.ps1 @@ -9,9 +9,8 @@ param ( ) $tspFiles = @() -$sanitizedPwd = $($pwd.path) -replace '\\', '/' if ([string]::IsNullOrEmpty($TargetBranch) -or [string]::IsNullOrEmpty($SourceBranch)) { - $tspFiles = (Get-ChildItem -path ./specification tspconfig.yaml -Recurse).Directory.FullName -replace '\\', '/' | ForEach-Object {[IO.Path]::GetRelativePath($sanitizedPwd, $_)} + $tspFiles = (Get-ChildItem -path ./specification tspconfig.yaml -Recurse).Directory.FullName | ForEach-Object {[IO.Path]::GetRelativePath($($pwd.path), $_)} } else { Write-Host "git -c core.quotepath=off -c i18n.logoutputencoding=utf-8 diff --name-only `"$TargetBranch...$SourceBranch`" -- | Where-Object {`$_.StartsWith('specification')}" @@ -22,7 +21,8 @@ $tspFiles -replace '\\', '/' $typespecFolders = @() foreach ($file in $tspFiles) { if ($file -match 'specification\/[^\/]*\/') { - $typespecFolders += (Get-ChildItem -path $matches[0] tspconfig.yaml -Recurse).Directory.FullName -replace '\\', '/' | ForEach-Object {[IO.Path]::GetRelativePath($sanitizedPwd, $_)} + $typespecFolder = (Get-ChildItem -path $matches[0] tspconfig.yaml -Recurse).Directory.FullName | ForEach-Object {[IO.Path]::GetRelativePath($($pwd.path), $_)} + $typespecFolders += $typespecFolder -replace '\\', '/' } } $typespecFolders = $typespecFolders | Select-Object -Unique From 120b45d9c574dbc3c5a8ca810cd77d0cfc79708e Mon Sep 17 00:00:00 2001 From: Albert Date: Thu, 20 Jul 2023 11:05:57 -0700 Subject: [PATCH 20/26] windows testing --- eng/pipelines/typespec-ci.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/eng/pipelines/typespec-ci.yml b/eng/pipelines/typespec-ci.yml index 08d97f68faae..18964acbc1e6 100644 --- a/eng/pipelines/typespec-ci.yml +++ b/eng/pipelines/typespec-ci.yml @@ -20,9 +20,17 @@ pr: jobs: - job: Validate_All_Specs + strategy: + matrix: + Linux: + Pool: azsdk-pool-mms-ubuntu-2204-general + OsVmImage: ubuntu-22.04 + Windows: + Pool: azsdk-pool-mms-win-2022-general + OsVmImage: windows-2022 pool: - name: azsdk-pool-mms-ubuntu-2204-general - vmImage: ubuntu-22.04 + name: $(Pool) + vmImage: $(OSVmImage) steps: - script: npm ci From 57a5fa4f7824d4254700fc2d62080aa0814a5710 Mon Sep 17 00:00:00 2001 From: Albert Cheng <38804567+ckairen@users.noreply.github.com> Date: Thu, 20 Jul 2023 11:13:16 -0700 Subject: [PATCH 21/26] Update eng/pipelines/typespec-ci.yml --- eng/pipelines/typespec-ci.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/eng/pipelines/typespec-ci.yml b/eng/pipelines/typespec-ci.yml index 18964acbc1e6..b5c287bdebdd 100644 --- a/eng/pipelines/typespec-ci.yml +++ b/eng/pipelines/typespec-ci.yml @@ -20,14 +20,6 @@ pr: jobs: - job: Validate_All_Specs - strategy: - matrix: - Linux: - Pool: azsdk-pool-mms-ubuntu-2204-general - OsVmImage: ubuntu-22.04 - Windows: - Pool: azsdk-pool-mms-win-2022-general - OsVmImage: windows-2022 pool: name: $(Pool) vmImage: $(OSVmImage) From 9fa7685c247f2dff885995c9bf8a888f0c953f09 Mon Sep 17 00:00:00 2001 From: Albert Cheng <38804567+ckairen@users.noreply.github.com> Date: Thu, 20 Jul 2023 11:13:44 -0700 Subject: [PATCH 22/26] Update eng/pipelines/typespec-ci.yml --- eng/pipelines/typespec-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/pipelines/typespec-ci.yml b/eng/pipelines/typespec-ci.yml index b5c287bdebdd..08d97f68faae 100644 --- a/eng/pipelines/typespec-ci.yml +++ b/eng/pipelines/typespec-ci.yml @@ -21,8 +21,8 @@ pr: jobs: - job: Validate_All_Specs pool: - name: $(Pool) - vmImage: $(OSVmImage) + name: azsdk-pool-mms-ubuntu-2204-general + vmImage: ubuntu-22.04 steps: - script: npm ci From af3dee7724492bfe0508aa478577786f5f74e0f1 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Thu, 20 Jul 2023 18:43:08 +0000 Subject: [PATCH 23/26] Handle null $typespecFolders --- eng/scripts/Validate-TypeSpec.ps1 | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/eng/scripts/Validate-TypeSpec.ps1 b/eng/scripts/Validate-TypeSpec.ps1 index 1cee4d764030..38feee44e6dc 100644 --- a/eng/scripts/Validate-TypeSpec.ps1 +++ b/eng/scripts/Validate-TypeSpec.ps1 @@ -8,19 +8,19 @@ param ( [string]$SourceBranch ) -$typespecFolders = @() +$exitCode = 0 $typespecFolders = &"$PSScriptRoot/Get-TypeSpec-Folders.ps1" "$SpecsRepoRootDirectory" "$TargetBranch" "$SourceBranch" -$typespecFolders = $typespecFolders.Split('',[System.StringSplitOptions]::RemoveEmptyEntries) - -$exitCode = 0 -foreach ($typespecFolder in $typespecFolders) { - npx --no tsv $typespecFolder 2>&1 | Write-Host - if ($LASTEXITCODE) { - $exitCode = 1 - } - git restore . - git clean -df +if ($typespecFolders) { + $typespecFolders = $typespecFolders.Split('',[System.StringSplitOptions]::RemoveEmptyEntries) + foreach ($typespecFolder in $typespecFolders) { + npx --no tsv $typespecFolder 2>&1 | Write-Host + if ($LASTEXITCODE) { + $exitCode = 1 + } + git restore . + git clean -df + } } exit $exitCode From b800d8db779670cd1d27c32df9f3f11899710094 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Thu, 20 Jul 2023 19:15:53 +0000 Subject: [PATCH 24/26] Add debugging, assign changedFiles --- eng/scripts/Get-TypeSpec-Folders.ps1 | 16 +++++++++++----- eng/scripts/Validate-TypeSpec.ps1 | 9 ++++++++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/eng/scripts/Get-TypeSpec-Folders.ps1 b/eng/scripts/Get-TypeSpec-Folders.ps1 index 5f54ba146fbf..053caed1b2c3 100644 --- a/eng/scripts/Get-TypeSpec-Folders.ps1 +++ b/eng/scripts/Get-TypeSpec-Folders.ps1 @@ -8,18 +8,24 @@ param ( [string]$SourceBranch ) -$tspFiles = @() +$changedFiles = @() if ([string]::IsNullOrEmpty($TargetBranch) -or [string]::IsNullOrEmpty($SourceBranch)) { - $tspFiles = (Get-ChildItem -path ./specification tspconfig.yaml -Recurse).Directory.FullName | ForEach-Object {[IO.Path]::GetRelativePath($($pwd.path), $_)} + $changedFiles = (Get-ChildItem -path ./specification tspconfig.yaml -Recurse).Directory.FullName | ForEach-Object {[IO.Path]::GetRelativePath($($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')} + $changedFiles = git -c core.quotepath=off -c i18n.logoutputencoding=utf-8 diff --name-only `"$TargetBranch...$SourceBranch`" -- | Where-Object {$_.StartsWith('specification')} } -$tspFiles -replace '\\', '/' +$changedFiles = $changedFiles -replace '\\', '/' + +Write-Host "changedFiles:" +foreach ($changedFile in $changedFiles) { + Write-Host " $changedFile" +} +Write-Host $typespecFolders = @() -foreach ($file in $tspFiles) { +foreach ($file in $changedFiles) { if ($file -match 'specification\/[^\/]*\/') { $typespecFolder = (Get-ChildItem -path $matches[0] tspconfig.yaml -Recurse).Directory.FullName | ForEach-Object {[IO.Path]::GetRelativePath($($pwd.path), $_)} $typespecFolders += $typespecFolder -replace '\\', '/' diff --git a/eng/scripts/Validate-TypeSpec.ps1 b/eng/scripts/Validate-TypeSpec.ps1 index 38feee44e6dc..f84a272cacb9 100644 --- a/eng/scripts/Validate-TypeSpec.ps1 +++ b/eng/scripts/Validate-TypeSpec.ps1 @@ -11,6 +11,13 @@ param ( $exitCode = 0 $typespecFolders = &"$PSScriptRoot/Get-TypeSpec-Folders.ps1" "$SpecsRepoRootDirectory" "$TargetBranch" "$SourceBranch" + +Write-Host "typespecFolders:" +foreach ($typespecFolder in $typespecFolders) { + Write-Host " $typespecFolder" +} +Write-Host + if ($typespecFolders) { $typespecFolders = $typespecFolders.Split('',[System.StringSplitOptions]::RemoveEmptyEntries) foreach ($typespecFolder in $typespecFolders) { @@ -20,7 +27,7 @@ if ($typespecFolders) { } git restore . git clean -df - } + } } exit $exitCode From c59fb0bd541e7aadf3061f519ac0217a0e63b148 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Thu, 20 Jul 2023 19:24:16 +0000 Subject: [PATCH 25/26] Only print changes files if git diff --- eng/scripts/Get-TypeSpec-Folders.ps1 | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/eng/scripts/Get-TypeSpec-Folders.ps1 b/eng/scripts/Get-TypeSpec-Folders.ps1 index 053caed1b2c3..56755d77ad0e 100644 --- a/eng/scripts/Get-TypeSpec-Folders.ps1 +++ b/eng/scripts/Get-TypeSpec-Folders.ps1 @@ -11,18 +11,19 @@ param ( $changedFiles = @() if ([string]::IsNullOrEmpty($TargetBranch) -or [string]::IsNullOrEmpty($SourceBranch)) { $changedFiles = (Get-ChildItem -path ./specification tspconfig.yaml -Recurse).Directory.FullName | ForEach-Object {[IO.Path]::GetRelativePath($($pwd.path), $_)} + $changedFiles = $changedFiles -replace '\\', '/' } else { Write-Host "git -c core.quotepath=off -c i18n.logoutputencoding=utf-8 diff --name-only `"$TargetBranch...$SourceBranch`" -- | Where-Object {`$_.StartsWith('specification')}" $changedFiles = git -c core.quotepath=off -c i18n.logoutputencoding=utf-8 diff --name-only `"$TargetBranch...$SourceBranch`" -- | Where-Object {$_.StartsWith('specification')} -} -$changedFiles = $changedFiles -replace '\\', '/' + $changedFiles = $changedFiles -replace '\\', '/' -Write-Host "changedFiles:" -foreach ($changedFile in $changedFiles) { - Write-Host " $changedFile" + Write-Host "changedFiles:" + foreach ($changedFile in $changedFiles) { + Write-Host " $changedFile" + } + Write-Host } -Write-Host $typespecFolders = @() foreach ($file in $changedFiles) { From 455aa5aeb4c9d71827bfb1dd7c3da90ca3d91da4 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Thu, 20 Jul 2023 12:37:54 -0700 Subject: [PATCH 26/26] Check path empty --- eng/scripts/Get-TypeSpec-Folders.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/scripts/Get-TypeSpec-Folders.ps1 b/eng/scripts/Get-TypeSpec-Folders.ps1 index 56755d77ad0e..5b5dc2227d87 100644 --- a/eng/scripts/Get-TypeSpec-Folders.ps1 +++ b/eng/scripts/Get-TypeSpec-Folders.ps1 @@ -28,7 +28,7 @@ else { $typespecFolders = @() foreach ($file in $changedFiles) { if ($file -match 'specification\/[^\/]*\/') { - $typespecFolder = (Get-ChildItem -path $matches[0] tspconfig.yaml -Recurse).Directory.FullName | ForEach-Object {[IO.Path]::GetRelativePath($($pwd.path), $_)} + $typespecFolder = (Get-ChildItem -path $matches[0] tspconfig.yaml -Recurse).Directory.FullName | ForEach-Object {if ($_) { [IO.Path]::GetRelativePath($($pwd.path), $_) }} $typespecFolders += $typespecFolder -replace '\\', '/' } }