From 19c0a5ebefc9c9319d8670ac850fc82bfcf0e259 Mon Sep 17 00:00:00 2001 From: Ray Chen Date: Tue, 23 Jan 2024 10:43:41 +0000 Subject: [PATCH 1/4] Correct the name of JS package folder --- .../scripts/Verify-RestApiSpecLocation.ps1 | 80 ++++++++++--------- 1 file changed, 44 insertions(+), 36 deletions(-) diff --git a/eng/common/scripts/Verify-RestApiSpecLocation.ps1 b/eng/common/scripts/Verify-RestApiSpecLocation.ps1 index 7204c29c034a..7dc0f95b682e 100644 --- a/eng/common/scripts/Verify-RestApiSpecLocation.ps1 +++ b/eng/common/scripts/Verify-RestApiSpecLocation.ps1 @@ -43,7 +43,7 @@ param ( . (Join-Path $PSScriptRoot Helpers/PSModule-Helpers.ps1) # Check if github token is set -if(-not $GitHubPat) { +if (-not $GitHubPat) { LogError "GitHubPat is not set. Please set the environment variable GH_TOKEN or pass the GitHubPat parameter." exit 1 } @@ -56,17 +56,17 @@ Install-ModuleIfNotInstalled "powershell-yaml" "0.4.1" | Import-Module # or # https://github.com/Azure/azure-rest-api-specs/blob/0ebd4949e8e1cd9537ca5a07384c7661162cc7a6/specification/purview/data-plane/Azure.Analytics.Purview.Account/preview/2019-11-01-preview/account.json function Verify-Url([string]$fileUrl) { - if($fileUrl -match "^https://(raw\.githubusercontent\.com|github\.com)/(?[^/]*/azure-rest-api-specs)(/(blob|tree))?/(?[^\/]+(\/[^\/]+)*|[0-9a-f]{40})/(?specification/.*)") { + if ($fileUrl -match "^https://(raw\.githubusercontent\.com|github\.com)/(?[^/]*/azure-rest-api-specs)(/(blob|tree))?/(?[^\/]+(\/[^\/]+)*|[0-9a-f]{40})/(?specification/.*)") { $repo = $matches['repo'] $commit = $matches['commit'] - if($repo -ne "Azure/azure-rest-api-specs") { + if ($repo -ne "Azure/azure-rest-api-specs") { LogError "ServiceDir:$ServiceDirectory, PackageName:$PackageName. Invalid repo in the file url: $fileUrl. Repo should be 'Azure/azure-rest-api-specs'." exit 1 } # check the commit hash belongs to main branch Verify-CommitFromMainBranch $commit } - else{ + else { LogError "ServiceDir:$ServiceDirectory, PackageName:$PackageName. Invalid file url: $fileUrl" exit 1 } @@ -76,7 +76,7 @@ function Verify-Url([string]$fileUrl) { function Verify-TspLocation([System.Object]$tspLocationObj) { $repo = $tspLocationObj["repo"] $commit = $tspLocationObj["commit"] - if($repo -ne "Azure/azure-rest-api-specs") { + if ($repo -ne "Azure/azure-rest-api-specs") { LogError "Invalid repo setting in the tsp-location.yaml: $repo. Repo should be 'Azure/azure-rest-api-specs'. ServiceDir:$ServiceDirectory, PackageName:$PackageName" exit 1 } @@ -87,11 +87,11 @@ function Verify-TspLocation([System.Object]$tspLocationObj) { # This function is used to verify the specific 'commit' belongs to the main branch of Azure/azure-rest-api-specs repository function Verify-CommitFromMainBranch([string]$commit) { - if($commit -notmatch "^[0-9a-f]{40}$" -and $commit -ne "main") { + if ($commit -notmatch "^[0-9a-f]{40}$" -and $commit -ne "main") { LogError "Invalid commit hash or branch name: $commit. Branch name should be 'main' or the commit should be a 40-character SHA-1 hash. ServiceDir:$ServiceDirectory, PackageName:$PackageName" exit 1 } - if($commit -eq "main") { + if ($commit -eq "main") { Write-Host "ServiceDir:$ServiceDirectory, PackageName:$PackageName. Branch is $commit branch of Azure/azure-rest-api-specs repository." return } @@ -101,7 +101,7 @@ function Verify-CommitFromMainBranch([string]$commit) { LogError "Commit $commit doesn't exist in 'main' branch of Azure/azure-rest-api-specs repository. ServiceDir:$ServiceDirectory, PackageName:$PackageName" exit 1 } - else{ + else { Write-Host "ServiceDir:$ServiceDirectory, PackageName:$PackageName. Commit $commit exists in 'main' branch of Azure/azure-rest-api-specs repository." } } @@ -114,13 +114,13 @@ function Verify-CommitFromMainBranch([string]$commit) { function Verify-YamlContent([string]$markdownContent) { $splitString = '``` yaml|```yaml|```' $yamlContent = $markdownContent -split $splitString - foreach($yamlSection in $yamlContent) { + foreach ($yamlSection in $yamlContent) { if ($yamlSection) { try { # remove the lines like: $(tag) == 'package-preview-2023-09' $yamlSection = $yamlSection -replace '^\s*\$\(.+\)\s*==.+', '' $yamlobj = ConvertFrom-Yaml -Yaml $yamlSection - if($yamlobj) { + if ($yamlobj) { $batchValue = $yamlobj["batch"] $requireValue = $yamlobj["require"] $inputFileValue = $yamlobj["input-file"] @@ -130,13 +130,13 @@ function Verify-YamlContent([string]$markdownContent) { } elseif ($inputFileValue) { LogDebug "ServiceDir:$ServiceDirectory, PackageName:$PackageName. 'input-file' is set as:$inputFileValue" - foreach($inputFile in $inputFileValue) { + foreach ($inputFile in $inputFileValue) { Verify-Url $inputFile } } elseif ($batchValue) { # there are some services which use batch mode for sdk generation, e.g. Azure.AI.Language.QuestionAnswering - foreach($batch in $batchValue) { + foreach ($batch in $batchValue) { $requireValue = $batch["require"] $inputFileValue = $batch["input-file"] if ($requireValue) { @@ -145,7 +145,7 @@ function Verify-YamlContent([string]$markdownContent) { } elseif ($inputFileValue) { LogDebug "ServiceDir:$ServiceDirectory, PackageName:$PackageName. 'input-file' is set as:$inputFileValue" - foreach($inputFile in $inputFileValue) { + foreach ($inputFile in $inputFileValue) { Verify-Url $inputFile } } @@ -163,19 +163,16 @@ function Verify-YamlContent([string]$markdownContent) { function Verify-PackageVersion() { try { $packages = @{} - if ($FindArtifactForApiReviewFn -and (Test-Path "Function:$FindArtifactForApiReviewFn")) - { + if ($FindArtifactForApiReviewFn -and (Test-Path "Function:$FindArtifactForApiReviewFn")) { $packages = &$FindArtifactForApiReviewFn $ArtifactLocation $PackageName } - else - { + else { LogError "The function for 'FindArtifactForApiReviewFn' was not found.` Make sure it is present in eng/scripts/Language-Settings.ps1 and referenced in eng/common/scripts/common.ps1.` See https://github.com/Azure/azure-sdk-tools/blob/main/doc/common/common_engsys.md#code-structure" exit 1 } - if (-not $PackageInfoDirectory) - { + if (-not $PackageInfoDirectory) { $PackageInfoDirectory = Join-Path -Path $ArtifactLocation "PackageInfo" if (-not (Test-Path -Path $PackageInfoDirectory)) { # Call Save-Package-Properties.ps1 script to generate package info json files @@ -185,23 +182,19 @@ function Verify-PackageVersion() { } $continueValidation = $false - if ($packages) - { - foreach($pkgPath in $packages.Values) - { + if ($packages) { + foreach ($pkgPath in $packages.Values) { $pkgPropPath = Join-Path -Path $PackageInfoDirectory "$PackageName.json" - if (-Not (Test-Path $pkgPropPath)) - { - Write-Host "ServiceDir:$ServiceDirectory, PackageName:$PackageName. Package property file path $($pkgPropPath) is invalid." - continue + if (-Not (Test-Path $pkgPropPath)) { + Write-Host "ServiceDir:$ServiceDirectory, PackageName:$PackageName. Package property file path $($pkgPropPath) is invalid." + continue } # Get package info from json file $pkgInfo = Get-Content $pkgPropPath | ConvertFrom-Json $version = [AzureEngSemanticVersion]::ParseVersionString($pkgInfo.Version) - if ($null -eq $version) - { - LogError "ServiceDir:$ServiceDirectory, Version info is not available for package $PackageName, because version '$(pkgInfo.Version)' is invalid. Please check if the version follows Azure SDK package versioning guidelines." - exit 1 + if ($null -eq $version) { + LogError "ServiceDir:$ServiceDirectory, Version info is not available for package $PackageName, because version '$(pkgInfo.Version)' is invalid. Please check if the version follows Azure SDK package versioning guidelines." + exit 1 } Write-Host "Version: $($version)" @@ -216,7 +209,7 @@ function Verify-PackageVersion() { $continueValidation = $true } } - if($continueValidation -eq $false) { + if ($continueValidation -eq $false) { Write-Host "ServiceDir:$ServiceDirectory, no package info is found for package $PackageName, the validation of spec location is ignored." exit 0 } @@ -227,12 +220,24 @@ function Verify-PackageVersion() { } } -try{ +try { # Verify package version is not a prerelease version, only continue the validation if the package is GA version - Verify-PackageVersion + # Verify-PackageVersion $ServiceDir = Join-Path $RepoRoot 'sdk' $ServiceDirectory $PackageDirectory = Join-Path $ServiceDir $PackageName + + # JavaScript SDK repo has different convention for the package directory name + if ($Language -eq "javascript") { + $prefixOfRlcPkg = "azure-rest-" + $prefixOfAzurePkg = "azure-" + if ($PackageName -match $prefixOfRlcPkg) { + $PackageDirectory = Join-Path $ServiceDir ($PackageName.Substring($prefixOfRlcPkg.Length) + "-rest") + } + else { + $PackageDirectory = Join-Path $ServiceDir $PackageName.Substring($prefixOfAzurePkg.Length) + } + } Push-Location $PackageDirectory # Load tsp-location.yaml if existed @@ -259,8 +264,8 @@ try{ } elseif ($Language -eq "java" -or $Language -eq "javascript" -or $Language -eq "python" -or $Language -eq "go") { # for these languages we ignore the validation because they always use the latest spec from main branch to release SDK - # mgmt plane packages: azure-core-management|azure-resourcemanager|azure-resourcemanager-advisor (java), azure-mgmt-devcenter (python), arm-advisor (js), armaad (go) - if($PackageName -match "^(arm|azure-mgmt|azure-resourcemanager|azure-core-management)[-a-z]*$") { + # mgmt plane packages: azure-core-management|azure-resourcemanager|azure-resourcemanager-advisor (java), azure-mgmt-devcenter (python), azure-arm-advisor (js), armaad (go) + if ($PackageName -match "^(arm|azure-mgmt|azure-resourcemanager|azure-core-management|azure-arm|azure-rest-arm)[-a-z]*$") { Write-Host "ServiceDir:$ServiceDirectory, PackageName:$PackageName. Ignore the validation for $Language management plane package." exit 0 } @@ -276,6 +281,9 @@ try{ } } } +catch { + Write-Host "ServiceDir:$ServiceDirectory, PackageName:$PackageName. Failed to validate spec location with exception:`n$_ " +} finally { Pop-Location } From 2ed62b10633ee123d5daaa74136fd6732d156839 Mon Sep 17 00:00:00 2001 From: Ray Chen Date: Tue, 23 Jan 2024 12:04:51 +0000 Subject: [PATCH 2/4] Uncomment the package verification --- eng/common/scripts/Verify-RestApiSpecLocation.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/scripts/Verify-RestApiSpecLocation.ps1 b/eng/common/scripts/Verify-RestApiSpecLocation.ps1 index 7dc0f95b682e..52137ad49105 100644 --- a/eng/common/scripts/Verify-RestApiSpecLocation.ps1 +++ b/eng/common/scripts/Verify-RestApiSpecLocation.ps1 @@ -222,7 +222,7 @@ function Verify-PackageVersion() { try { # Verify package version is not a prerelease version, only continue the validation if the package is GA version - # Verify-PackageVersion + Verify-PackageVersion $ServiceDir = Join-Path $RepoRoot 'sdk' $ServiceDirectory $PackageDirectory = Join-Path $ServiceDir $PackageName From 2477ec65d0ad1bf773182ed0f4383e4138616dcf Mon Sep 17 00:00:00 2001 From: Ray Chen Date: Tue, 23 Jan 2024 14:07:26 +0000 Subject: [PATCH 3/4] Logging more info for troubleshooting --- .../scripts/Verify-RestApiSpecLocation.ps1 | 56 ++++++++++--------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/eng/common/scripts/Verify-RestApiSpecLocation.ps1 b/eng/common/scripts/Verify-RestApiSpecLocation.ps1 index 52137ad49105..3d1375a32531 100644 --- a/eng/common/scripts/Verify-RestApiSpecLocation.ps1 +++ b/eng/common/scripts/Verify-RestApiSpecLocation.ps1 @@ -48,6 +48,8 @@ if (-not $GitHubPat) { exit 1 } +Write-Host "The spec used to release SDK should be from the main branch of Azure/azure-rest-api-specs repository." +Write-Host "ServiceDir:$ServiceDirectory, PackageName:$PackageName, ArtifactLocation:$ArtifactLocation, PackageInfoDirectory:$PackageInfoDirectory." Install-ModuleIfNotInstalled "powershell-yaml" "0.4.1" | Import-Module # This function is used to verify the 'require' and 'input-file' settings in autorest.md point to the main branch of Azure/azure-rest-api-specs repository @@ -55,50 +57,50 @@ Install-ModuleIfNotInstalled "powershell-yaml" "0.4.1" | Import-Module # https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/purview/data-plane/Azure.Analytics.Purview.MetadataPolicies/preview/2021-07-01-preview/purviewMetadataPolicy.json # or # https://github.com/Azure/azure-rest-api-specs/blob/0ebd4949e8e1cd9537ca5a07384c7661162cc7a6/specification/purview/data-plane/Azure.Analytics.Purview.Account/preview/2019-11-01-preview/account.json -function Verify-Url([string]$fileUrl) { +function Verify-Url([string]$fileUrl, [string]$configFilePath) { if ($fileUrl -match "^https://(raw\.githubusercontent\.com|github\.com)/(?[^/]*/azure-rest-api-specs)(/(blob|tree))?/(?[^\/]+(\/[^\/]+)*|[0-9a-f]{40})/(?specification/.*)") { $repo = $matches['repo'] $commit = $matches['commit'] if ($repo -ne "Azure/azure-rest-api-specs") { - LogError "ServiceDir:$ServiceDirectory, PackageName:$PackageName. Invalid repo in the file url: $fileUrl. Repo should be 'Azure/azure-rest-api-specs'." + LogError "ServiceDir:$ServiceDirectory, PackageName:$PackageName. Invalid repo in the file url: $fileUrl. Repo should be 'Azure/azure-rest-api-specs' in the config file:$configFilePath." exit 1 } # check the commit hash belongs to main branch - Verify-CommitFromMainBranch $commit + Verify-CommitFromMainBranch $commit $configFilePath } else { - LogError "ServiceDir:$ServiceDirectory, PackageName:$PackageName. Invalid file url: $fileUrl" + LogError "ServiceDir:$ServiceDirectory, PackageName:$PackageName. Invalid file url: $fileUrl in the config file:$configFilePath. The spec location should point to the main branch of Azure/azure-rest-api-specs repository." exit 1 } } # This function is used to verify the 'repo' and 'commit' settings in tsp-location.yaml point to the main branch of Azure/azure-rest-api-specs repository -function Verify-TspLocation([System.Object]$tspLocationObj) { +function Verify-TspLocation([System.Object]$tspLocationObj, [string]$tspLocationYamlPath) { $repo = $tspLocationObj["repo"] $commit = $tspLocationObj["commit"] if ($repo -ne "Azure/azure-rest-api-specs") { - LogError "Invalid repo setting in the tsp-location.yaml: $repo. Repo should be 'Azure/azure-rest-api-specs'. ServiceDir:$ServiceDirectory, PackageName:$PackageName" + LogError "Invalid repo setting in the tsp-location.yaml: $repo. Repo should be 'Azure/azure-rest-api-specs'. ServiceDir:$ServiceDirectory, PackageName:$PackageName, tsp-location.yaml path:$tspLocationYamlPath." exit 1 } # check the commit hash belongs to main branch - Verify-CommitFromMainBranch $commit + Verify-CommitFromMainBranch $commit $tspLocationYamlPath } # This function is used to verify the specific 'commit' belongs to the main branch of Azure/azure-rest-api-specs repository -function Verify-CommitFromMainBranch([string]$commit) { +function Verify-CommitFromMainBranch([string]$commit, [string]$configFilePath) { if ($commit -notmatch "^[0-9a-f]{40}$" -and $commit -ne "main") { - LogError "Invalid commit hash or branch name: $commit. Branch name should be 'main' or the commit should be a 40-character SHA-1 hash. ServiceDir:$ServiceDirectory, PackageName:$PackageName" + LogError "Invalid commit hash or branch name: $commit. Branch name should be 'main' or the commit should be a 40-character SHA-1 hash. ServiceDir:$ServiceDirectory, PackageName:$PackageName, please check the config file:$configFilePath." exit 1 } if ($commit -eq "main") { - Write-Host "ServiceDir:$ServiceDirectory, PackageName:$PackageName. Branch is $commit branch of Azure/azure-rest-api-specs repository." + Write-Host "ServiceDir:$ServiceDirectory, PackageName:$PackageName, Config file:$configFilePath. Branch is $commit branch of Azure/azure-rest-api-specs repository." return } try { $searchResult = Search-GitHubCommit -AuthToken $GitHubPat -CommitHash $commit -RepoOwner "Azure" -RepoName "azure-rest-api-specs" if ($searchResult.total_count -lt 1) { - LogError "Commit $commit doesn't exist in 'main' branch of Azure/azure-rest-api-specs repository. ServiceDir:$ServiceDirectory, PackageName:$PackageName" + LogError "Commit $commit doesn't exist in 'main' branch of Azure/azure-rest-api-specs repository. ServiceDir:$ServiceDirectory, PackageName:$PackageName, please check the config file:$configFilePath. The spec used to release SDK should be from the main branch of Azure/azure-rest-api-specs repository." exit 1 } else { @@ -106,12 +108,12 @@ function Verify-CommitFromMainBranch([string]$commit) { } } catch { - LogError "ServiceDir:$ServiceDirectory, PackageName:$PackageName. Failed to search commit $commit with exception:`n$_ " + LogError "ServiceDir:$ServiceDirectory, PackageName:$PackageName, Config file:$configFilePath. The spec used to release SDK should be from the main branch of Azure/azure-rest-api-specs repository. Failed to search commit $commit with exception:`n$_ " exit 1 } } -function Verify-YamlContent([string]$markdownContent) { +function Verify-YamlContent([string]$markdownContent, [string]$configFilePath) { $splitString = '``` yaml|```yaml|```' $yamlContent = $markdownContent -split $splitString foreach ($yamlSection in $yamlContent) { @@ -125,13 +127,13 @@ function Verify-YamlContent([string]$markdownContent) { $requireValue = $yamlobj["require"] $inputFileValue = $yamlobj["input-file"] if ($requireValue) { - LogDebug "ServiceDir:$ServiceDirectory, PackageName:$PackageName. 'require' is set as:$requireValue" - Verify-Url $requireValue + LogDebug "ServiceDir:$ServiceDirectory, PackageName:$PackageName, Config file:$configFilePath. 'require' is set as:$requireValue" + Verify-Url $requireValue $configFilePath } elseif ($inputFileValue) { - LogDebug "ServiceDir:$ServiceDirectory, PackageName:$PackageName. 'input-file' is set as:$inputFileValue" + LogDebug "ServiceDir:$ServiceDirectory, PackageName:$PackageName, Config file:$configFilePath. 'input-file' is set as:$inputFileValue" foreach ($inputFile in $inputFileValue) { - Verify-Url $inputFile + Verify-Url $inputFile $configFilePath } } elseif ($batchValue) { @@ -140,13 +142,13 @@ function Verify-YamlContent([string]$markdownContent) { $requireValue = $batch["require"] $inputFileValue = $batch["input-file"] if ($requireValue) { - LogDebug "ServiceDir:$ServiceDirectory, PackageName:$PackageName. 'require' is set as:$requireValue" - Verify-Url $requireValue + LogDebug "ServiceDir:$ServiceDirectory, PackageName:$PackageName, Config file:$configFilePath. 'require' is set as:$requireValue" + Verify-Url $requireValue $configFilePath } elseif ($inputFileValue) { - LogDebug "ServiceDir:$ServiceDirectory, PackageName:$PackageName. 'input-file' is set as:$inputFileValue" + LogDebug "ServiceDir:$ServiceDirectory, PackageName:$PackageName, Config file:$configFilePath. 'input-file' is set as:$inputFileValue" foreach ($inputFile in $inputFileValue) { - Verify-Url $inputFile + Verify-Url $inputFile $configFilePath } } } @@ -248,17 +250,17 @@ try { if (Test-Path -Path $tspLocationYamlPath) { # typespec scenario $tspLocationYaml = Get-Content -Path $tspLocationYamlPath -Raw | ConvertFrom-Yaml - Verify-TspLocation $tspLocationYaml + Verify-TspLocation $tspLocationYaml $tspLocationYamlPath } elseif ($Language -eq "dotnet") { # only dotnet language sdk uses 'autorest.md' to configure the sdk generation if (Test-Path -Path $autorestMdPath) { try { $autorestMdContent = Get-Content -Path $autorestMdPath -Raw - Verify-YamlContent $autorestMdContent + Verify-YamlContent $autorestMdContent $autorestMdPath } catch { - Write-Host "ServiceDir:$ServiceDirectory, PackageName:$PackageName. Failed to parse autorest.md file with exception:`n$_ " + Write-Host "ServiceDir:$ServiceDirectory, PackageName:$PackageName. Failed to parse autorest.md file:$autorestMdPath with exception:`n$_ " } } } @@ -273,16 +275,16 @@ try { if (Test-Path -Path $swaggerReadmePath) { try { $swaggerReadmeContent = Get-Content -Path $swaggerReadmePath -Raw - Verify-YamlContent $swaggerReadmeContent + Verify-YamlContent $swaggerReadmeContent $swaggerReadmePath } catch { - Write-Host "ServiceDir:$ServiceDirectory, PackageName:$PackageName. Failed to parse swagger/readme.md file with exception:`n$_ " + Write-Host "ServiceDir:$ServiceDirectory, PackageName:$PackageName. Failed to parse swagger/readme.md file:$swaggerReadmePath with exception:`n$_ " } } } } catch { - Write-Host "ServiceDir:$ServiceDirectory, PackageName:$PackageName. Failed to validate spec location with exception:`n$_ " + Write-Host "ServiceDir:$ServiceDirectory, PackageName:$PackageName, PackageDirectory:$PackageDirectory. Failed to validate spec location with exception:`n$_ " } finally { Pop-Location From c064da45768084ac1ed14f792b9ecc12891a8aef Mon Sep 17 00:00:00 2001 From: Ray Chen Date: Wed, 24 Jan 2024 08:29:14 +0000 Subject: [PATCH 4/4] Get sdkType and directory from the package info --- .../scripts/Verify-RestApiSpecLocation.ps1 | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/eng/common/scripts/Verify-RestApiSpecLocation.ps1 b/eng/common/scripts/Verify-RestApiSpecLocation.ps1 index 3d1375a32531..b5ac422d570f 100644 --- a/eng/common/scripts/Verify-RestApiSpecLocation.ps1 +++ b/eng/common/scripts/Verify-RestApiSpecLocation.ps1 @@ -215,6 +215,8 @@ function Verify-PackageVersion() { Write-Host "ServiceDir:$ServiceDirectory, no package info is found for package $PackageName, the validation of spec location is ignored." exit 0 } + # Return the package info + return $pkgInfo } catch { LogError "ServiceDir:$ServiceDirectory, PackageName:$PackageName. Failed to retrieve package and validate package version with exception:`n$_ " @@ -224,21 +226,20 @@ function Verify-PackageVersion() { try { # Verify package version is not a prerelease version, only continue the validation if the package is GA version - Verify-PackageVersion - - $ServiceDir = Join-Path $RepoRoot 'sdk' $ServiceDirectory - $PackageDirectory = Join-Path $ServiceDir $PackageName + $packageInfo = Verify-PackageVersion + if (-not $packageInfo) { + Write-Host "ServiceDir:$ServiceDirectory, PackageName:$PackageName. The package info is not available." + exit 0 + } + # Get the package directory path + $PackageDirectory = $null + if ($packageInfo.DirectoryPath) { + $PackageDirectory = Join-Path $RepoRoot $packageInfo.DirectoryPath + } - # JavaScript SDK repo has different convention for the package directory name - if ($Language -eq "javascript") { - $prefixOfRlcPkg = "azure-rest-" - $prefixOfAzurePkg = "azure-" - if ($PackageName -match $prefixOfRlcPkg) { - $PackageDirectory = Join-Path $ServiceDir ($PackageName.Substring($prefixOfRlcPkg.Length) + "-rest") - } - else { - $PackageDirectory = Join-Path $ServiceDir $PackageName.Substring($prefixOfAzurePkg.Length) - } + if ((-not $PackageDirectory) -or (-not (Test-Path $PackageDirectory))) { + Write-Host "ServiceDir:$ServiceDirectory, PackageName:$PackageName, PackageDirectory:$PackageDirectory. The package directory path is invalid." + exit 0 } Push-Location $PackageDirectory @@ -265,10 +266,9 @@ try { } } elseif ($Language -eq "java" -or $Language -eq "javascript" -or $Language -eq "python" -or $Language -eq "go") { - # for these languages we ignore the validation because they always use the latest spec from main branch to release SDK - # mgmt plane packages: azure-core-management|azure-resourcemanager|azure-resourcemanager-advisor (java), azure-mgmt-devcenter (python), azure-arm-advisor (js), armaad (go) - if ($PackageName -match "^(arm|azure-mgmt|azure-resourcemanager|azure-core-management|azure-arm|azure-rest-arm)[-a-z]*$") { - Write-Host "ServiceDir:$ServiceDirectory, PackageName:$PackageName. Ignore the validation for $Language management plane package." + # for these languages we ignore the validation for mgmt plane SDK because they always use the latest spec from main branch to release SDK + if ($packageInfo.SdkType -eq "mgmt") { + Write-Host "ServiceDir:$ServiceDirectory, PackageName:$PackageName. Ignore the validation for $Language management plane SDK release." exit 0 } # for these languages they use 'swagger/readme.md' to configure the sdk generation for data plane scenarios