From ecc990e7f20256b9ac9e18811f46e4b9f3dc9240 Mon Sep 17 00:00:00 2001 From: raychen Date: Thu, 8 Jun 2023 13:29:51 +0800 Subject: [PATCH 1/3] Added switch to skip sync and generate script call --- .../scripts/TypeSpec-Project-Process.ps1 | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/eng/common/scripts/TypeSpec-Project-Process.ps1 b/eng/common/scripts/TypeSpec-Project-Process.ps1 index a27036a80a45..6f5912283039 100644 --- a/eng/common/scripts/TypeSpec-Project-Process.ps1 +++ b/eng/common/scripts/TypeSpec-Project-Process.ps1 @@ -8,7 +8,8 @@ param ( [Parameter(Position = 1)] [string] $CommitHash, [Parameter(Position = 2)] - [string] $RepoUrl + [string] $RepoUrl, + [switch] $SkipSyncAndGenerate ) . $PSScriptRoot/common.ps1 @@ -199,14 +200,17 @@ if ($generateFromLocalTypeSpec) { $sdkProjectFolder = CreateUpdate-TspLocation $tspConfigYaml $TypeSpecProjectDirectory $CommitHash $repo $sdkRepoRootPath } -# call TypeSpec-Project-Sync.ps1 -$syncScript = Join-Path $PSScriptRoot TypeSpec-Project-Sync.ps1 -& $syncScript $sdkProjectFolder $specRepoRoot -if ($LASTEXITCODE) { exit $LASTEXITCODE } - -# call TypeSpec-Project-Generate.ps1 -$generateScript = Join-Path $PSScriptRoot TypeSpec-Project-Generate.ps1 -& $generateScript $sdkProjectFolder -if ($LASTEXITCODE) { exit $LASTEXITCODE } +# checking skip switch +if (!$SkipSyncAndGenerate) { + # call TypeSpec-Project-Sync.ps1 + $syncScript = Join-Path $PSScriptRoot TypeSpec-Project-Sync.ps1 + & $syncScript $sdkProjectFolder $specRepoRoot + if ($LASTEXITCODE) { exit $LASTEXITCODE } + + # call TypeSpec-Project-Generate.ps1 + $generateScript = Join-Path $PSScriptRoot TypeSpec-Project-Generate.ps1 + & $generateScript $sdkProjectFolder + if ($LASTEXITCODE) { exit $LASTEXITCODE } +} return $sdkProjectFolder \ No newline at end of file From 1d406bfec9e7bb014a0c561c47b5b10f8e10407e Mon Sep 17 00:00:00 2001 From: raychen Date: Thu, 8 Jun 2023 13:47:46 +0800 Subject: [PATCH 2/3] output switch --- eng/common/scripts/TypeSpec-Project-Process.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/eng/common/scripts/TypeSpec-Project-Process.ps1 b/eng/common/scripts/TypeSpec-Project-Process.ps1 index 6f5912283039..ec910a3b8d34 100644 --- a/eng/common/scripts/TypeSpec-Project-Process.ps1 +++ b/eng/common/scripts/TypeSpec-Project-Process.ps1 @@ -201,7 +201,9 @@ if ($generateFromLocalTypeSpec) { } # checking skip switch -if (!$SkipSyncAndGenerate) { +if ($SkipSyncAndGenerate) { + Write-Host "Skip calling TypeSpec-Project-Sync.ps1 and TypeSpec-Project-Generate.ps1." +} else { # call TypeSpec-Project-Sync.ps1 $syncScript = Join-Path $PSScriptRoot TypeSpec-Project-Sync.ps1 & $syncScript $sdkProjectFolder $specRepoRoot From 19b5905a917e663ca2011f24ab94a1d2f73a9ac8 Mon Sep 17 00:00:00 2001 From: raychen Date: Thu, 8 Jun 2023 14:18:41 +0800 Subject: [PATCH 3/3] support forked spec repo in regex --- eng/common/scripts/TypeSpec-Project-Process.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/scripts/TypeSpec-Project-Process.ps1 b/eng/common/scripts/TypeSpec-Project-Process.ps1 index ec910a3b8d34..71c7e003ce53 100644 --- a/eng/common/scripts/TypeSpec-Project-Process.ps1 +++ b/eng/common/scripts/TypeSpec-Project-Process.ps1 @@ -112,7 +112,7 @@ $specRepoRoot = "" $generateFromLocalTypeSpec = $false # remote url scenario # example url of tspconfig.yaml: https://github.com/Azure/azure-rest-api-specs-pr/blob/724ccc4d7ef7655c0b4d5c5ac4a5513f19bbef35/specification/containerservice/Fleet.Management/tspconfig.yaml -if ($TypeSpecProjectDirectory -match '^https://github.com/(?Azure/azure-rest-api-specs(-pr)?)/blob/(?[0-9a-f]{40})/(?.*)/tspconfig.yaml$') { +if ($TypeSpecProjectDirectory -match '^https://github.com/(?[^/]*/azure-rest-api-specs(-pr)?)/blob/(?[0-9a-f]{40})/(?.*)/tspconfig.yaml$') { try { $TypeSpecProjectDirectory = $TypeSpecProjectDirectory -replace "https://github.com/(.*)/(tree|blob)", "https://raw.githubusercontent.com/`$1" Invoke-WebRequest $TypeSpecProjectDirectory -OutFile $tspConfigPath -MaximumRetryCount 3