Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the batch version of ValidateDocsMsPackagesFn #3169

Merged
2 commits merged into from
Apr 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions eng/common/scripts/Update-DocsMsMetadata.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ function GetPackageInfoJson ($packageInfoJsonLocation) {
# version is always 'dev' when interacting with NPM.
if ($GetDocsMsDevLanguageSpecificPackageInfoFn -and (Test-Path "Function:$GetDocsMsDevLanguageSpecificPackageInfoFn")) {
$packageInfo = &$GetDocsMsDevLanguageSpecificPackageInfoFn $packageInfo
} else {
}
else {
# Default: use the dev version from package info as the version for
# downstream processes
$packageInfo.Version = $packageInfo.DevVersion
Expand All @@ -162,19 +163,23 @@ function GetPackageInfoJson ($packageInfoJsonLocation) {
return $packageInfo
}

function UpdateDocsMsMetadataForPackage($packageInfoJsonLocation, $packageInfo) {
function UpdateDocsMsMetadataForPackage($packageInfoJsonLocation) {
$packageInfo = GetPackageInfoJson $packageInfoJsonLocation

$originalVersion = [AzureEngSemanticVersion]::ParseVersionString($packageInfo.Version)
$packageMetadataArray = (Get-CSVMetadata).Where({ $_.Package -eq $packageInfo.Name -and $_.Hide -ne 'true' -and $_.New -eq 'true' })
if ($packageInfo.Group) {
$packageMetadataArray = ($packageMetadataArray).Where({$_.GroupId -eq $packageInfo.Group})
$packageMetadataArray = ($packageMetadataArray).Where({ $_.GroupId -eq $packageInfo.Group })
}
if ($packageMetadataArray.Count -eq 0) {
LogWarning "Could not retrieve metadata for $($packageInfo.Name) from metadata CSV. Using best effort defaults."
$packageMetadata = $null
} elseif ($packageMetadataArray.Count -gt 1) {
}
elseif ($packageMetadataArray.Count -gt 1) {
LogWarning "Multiple metadata entries for $($packageInfo.Name) in metadata CSV. Using first entry."
$packageMetadata = $packageMetadataArray[0]
} else {
}
else {
$packageMetadata = $packageMetadataArray[0]
}

Expand Down Expand Up @@ -214,15 +219,17 @@ function UpdateDocsMsMetadataForPackage($packageInfoJsonLocation, $packageInfo)
Set-Content -Path $readmeLocation -Value $outputReadmeContent
}

# For daily update and release, validate DocsMS publishing using the language-specific validation function
if ($ValidateDocsMsPackagesFn -and (Test-Path "Function:$ValidateDocsMsPackagesFn")) {
Write-Host "Validating the packages..."

$packageInfos = @($PackageInfoJsonLocations | ForEach-Object { GetPackageInfoJson $_ })

&$ValidateDocsMsPackagesFn -PackageInfos $packageInfos -PackageSourceOverride $PackageSourceOverride -DocValidationImageId $DocValidationImageId -DocRepoLocation $DocRepoLocation
}

foreach ($packageInfoLocation in $PackageInfoJsonLocations) {
Write-Host "Updating metadata for package: $packageInfoLocation"
# Convert package metadata json file to metadata json property.
$packageInfo = GetPackageInfoJson $packageInfoLocation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot remove this without breaking the other languages until they each are updated to start passing in this new parameter. What is our transition plan?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each of the language-settings files that implemented $ValidateDocsMsPackagesFn have been shimmed to support single packageInfo and multiple packageInfos parameters:
Azure/azure-sdk-for-js#21483
Azure/azure-sdk-for-java#28346
Azure/azure-sdk-for-python#24041

Copy link
Member Author

@hallipr hallipr Apr 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The yaml and powershell script for Update-DocsMsMetadata already supported multiple package info locations. The implementation steps are:

  1. Add batch support to the language repos (language repo prs)
  2. Add batch invocation to eng/common (this pr)
  3. Optimize batch processing per language
    • Pass multiple packageInfoLocations to update-docsms-metadata.yml
    • Use deeper batch processing in Validate-{language}-DocMsPackages

# Add validation step for daily update and release
if ($ValidateDocsMsPackagesFn -and (Test-Path "Function:$ValidateDocsMsPackagesFn")) {
Write-Host "Validating the package..."
&$ValidateDocsMsPackagesFn -PackageInfo $packageInfo -PackageSourceOverride $PackageSourceOverride -DocValidationImageId $DocValidationImageId -DocRepoLocation $DocRepoLocation
}
Write-Host "Updating the package json ..."
UpdateDocsMsMetadataForPackage $packageInfoLocation $packageInfo
UpdateDocsMsMetadataForPackage $packageInfoLocation
}