Skip to content

Commit

Permalink
Sync eng/common directory with azure-sdk-tools for PR 6305 (#20996)
Browse files Browse the repository at this point in the history
* Added switch to skip sync and generate script call

* output switch

* support forked spec repo in regex

---------

Co-authored-by: raychen <raychen@microsoft.com>
  • Loading branch information
azure-sdk and raych1 authored Jun 9, 2023
1 parent bf033de commit 3bfbbb2
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions eng/common/scripts/TypeSpec-Project-Process.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ param (
[Parameter(Position = 1)]
[string] $CommitHash,
[Parameter(Position = 2)]
[string] $RepoUrl
[string] $RepoUrl,
[switch] $SkipSyncAndGenerate
)

. $PSScriptRoot/common.ps1
Expand Down Expand Up @@ -111,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/(?<repo>Azure/azure-rest-api-specs(-pr)?)/blob/(?<commit>[0-9a-f]{40})/(?<path>.*)/tspconfig.yaml$') {
if ($TypeSpecProjectDirectory -match '^https://github.com/(?<repo>[^/]*/azure-rest-api-specs(-pr)?)/blob/(?<commit>[0-9a-f]{40})/(?<path>.*)/tspconfig.yaml$') {
try {
$TypeSpecProjectDirectory = $TypeSpecProjectDirectory -replace "https://github.com/(.*)/(tree|blob)", "https://raw.githubusercontent.com/`$1"
Invoke-WebRequest $TypeSpecProjectDirectory -OutFile $tspConfigPath -MaximumRetryCount 3
Expand Down Expand Up @@ -199,14 +200,19 @@ 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) {
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
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

0 comments on commit 3bfbbb2

Please sign in to comment.