diff --git a/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml b/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml index 2e10f695c99..a2c37ab5b81 100644 --- a/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml +++ b/eng/common/pipelines/templates/steps/daily-dev-build-variable.yml @@ -1,7 +1,19 @@ # This script fragment is used across our repos to set a variable "SetDevVersion" which # is used when this pipeline is going to be generating and publishing daily dev builds. - +parameters: + ServiceDirectory: '' steps: +- ${{if ne(parameters.ServiceDirectory, '')}}: + - task: Powershell@2 + inputs: + filePath: $(Build.SourcesDirectory)/eng/common/scripts/Save-Package-Properties.ps1 + arguments: > + -ServiceDirectory ${{parameters.ServiceDirectory}} + -OutDirectory $(Build.ArtifactStagingDirectory)/PackageInfo + pwsh: true + workingDirectory: $(Pipeline.Workspace) + displayName: Dump Package properties + condition: succeeded() - pwsh: | $setDailyDevBuild = "false" if (('$(Build.Reason)' -eq 'Schedule') -and ('$(System.TeamProject)' -eq 'internal')) { diff --git a/eng/common/scripts/Create-APIReview.ps1 b/eng/common/scripts/Create-APIReview.ps1 index 91fccacc129..210b82d4f69 100644 --- a/eng/common/scripts/Create-APIReview.ps1 +++ b/eng/common/scripts/Create-APIReview.ps1 @@ -40,6 +40,7 @@ function Submit-APIReview($packagename, $filePath, $uri, $apiKey, $apiLabel) try { $Response = Invoke-WebRequest -Method 'POST' -Uri $uri -Body $multipartContent -Headers $headers + Write-Host "API Review: $($Response)" $StatusCode = $Response.StatusCode } catch @@ -81,23 +82,47 @@ else } $FoundFailure = $False +$pkgInfoPath = Join-Path -Path $ArtifactPath "PackageInfo" foreach ($pkgName in $responses.Keys) { $respCode = $responses[$pkgName] if ($respCode -ne '200') { - $FoundFailure = $True - if ($respCode -eq '201') + $pkgPropPath = Join-Path -Path $pkgInfoPath ($PackageName + ".json") + if (-Not (Test-Path $pkgPropPath)) { - Write-Host "API Review is pending for package $pkgName" + Write-Host " Package property file path $($pkgPropPath) is invalid." + $FoundFailure = $True } else { - Write-Host "Failed to create API Review for package $pkgName" + $pkgInfo = Get-Content $pkgPropPath | ConvertFrom-Json + $version = [AzureEngSemanticVersion]::ParseVersionString($pkgInfo.Version) + if ($version.IsPrerelease) + { + Write-Host "Package version is not GA. Ignoring API view approval status" + } + elseif ($pkgInfo.SdkType -eq "client" -and $pkgInfo.IsNewSdk) + { + $FoundFailure = $True + if ($respCode -eq '201') + { + Write-Error "Automatic API Review approval is pending for package $($PackageName)" + } + else + { + Write-Error "Failed to create API Review for package $($PackageName)" + } + } + else + { + Write-Host "API review is not approved for package $($PackageName). Management and track1 package can be released without API review approval." + } } } } if ($FoundFailure) { - Write-Host "Atleast one API review is not yet approved" + Write-Error "Automatic API review is not yet approved for package $($PackageName)" + exit 1 } diff --git a/eng/common/scripts/Package-Properties.ps1 b/eng/common/scripts/Package-Properties.ps1 index c1daf77b3b3..f582a4a74dc 100644 --- a/eng/common/scripts/Package-Properties.ps1 +++ b/eng/common/scripts/Package-Properties.ps1 @@ -10,6 +10,8 @@ class PackageProps [string]$ReadMePath [string]$ChangeLogPath [string]$Group + [string]$SdkType + [boolean]$IsNewSdk PackageProps([string]$name, [string]$version, [string]$directoryPath, [string]$serviceDirectory) { diff --git a/eng/common/scripts/Save-Package-Properties.ps1 b/eng/common/scripts/Save-Package-Properties.ps1 new file mode 100644 index 00000000000..b78e3342efe --- /dev/null +++ b/eng/common/scripts/Save-Package-Properties.ps1 @@ -0,0 +1,34 @@ +[CmdletBinding()] +Param ( + [Parameter(Mandatory=$True)] + [string] $serviceDirectory, + [Parameter(Mandatory=$True)] + [string] $outDirectory +) + +. (Join-Path $PSScriptRoot common.ps1) +$allPackageProperties = Get-AllPkgProperties $serviceDirectory +if ($allPackageProperties) +{ + New-Item -ItemType Directory -Force -Path $outDirectory + foreach($pkg in $allPackageProperties) + { + if ($pkg.IsNewSDK) + { + Write-Host "Package Name: $($pkg.Name)" + Write-Host "Package Version: $($pkg.Version)" + Write-Host "Package SDK Type: $($pkg.SdkType)" + $outputPath = Join-Path -Path $outDirectory ($pkg.Name + ".json") + $outputObject = $pkg | ConvertTo-Json + Set-Content -Path $outputPath -Value $outputObject + } + } + + Get-ChildItem -Path $outDirectory +} +else +{ + Write-Error "Package properties are not available for service directory $($serviceDirectory)" + exit 1 +} +