Sync eng/common directory with azure-sdk-tools for PR 6530 (#4801)
* Update-DocsMsMetadata.ps1 can fail the build on invalid packages * Better error handling and logging * Review feedback --------- Co-authored-by: Daniel Jurek <djurek@microsoft.com>
This commit is contained in:
parent
7bbf780875
commit
cdfabe3cc5
@ -0,0 +1,11 @@
|
||||
steps:
|
||||
# Fail the build if any of the packages failed validation. Valid values are
|
||||
# "true" or "false"
|
||||
- pwsh: |
|
||||
if ('$(DocsMsPackagesAllValid)' -eq 'true') {
|
||||
Write-Host "All packages passed validation."
|
||||
} else {
|
||||
Write-Error "Some packages failed validation."
|
||||
exit 1
|
||||
}
|
||||
displayName: Check package validation results
|
||||
@ -230,17 +230,40 @@ function UpdateDocsMsMetadataForPackage($packageInfoJsonLocation) {
|
||||
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
|
||||
}
|
||||
|
||||
$allSucceeded = $true
|
||||
foreach ($packageInfoLocation in $PackageInfoJsonLocations) {
|
||||
|
||||
if ($ValidateDocsMsPackagesFn -and (Test-Path "Function:$ValidateDocsMsPackagesFn")) {
|
||||
Write-Host "Validating the packages..."
|
||||
|
||||
$packageInfo = GetPackageInfoJson $packageInfoLocation
|
||||
# This calls a function named "Validate-${Language}-DocMsPackages"
|
||||
# declared in common.ps1, implemented in Language-Settings.ps1
|
||||
$isValid = &$ValidateDocsMsPackagesFn `
|
||||
-PackageInfos $packageInfo `
|
||||
-PackageSourceOverride $PackageSourceOverride `
|
||||
-DocValidationImageId $DocValidationImageId `
|
||||
-DocRepoLocation $DocRepoLocation
|
||||
|
||||
if (!$isValid) {
|
||||
Write-Host "Package validation failed for package: $packageInfoLocation"
|
||||
$allSucceeded = $false
|
||||
|
||||
# Skip the later call to UpdateDocsMsMetadataForPackage because this
|
||||
# package has not passed validation
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "Updating metadata for package: $packageInfoLocation"
|
||||
# Convert package metadata json file to metadata json property.
|
||||
UpdateDocsMsMetadataForPackage $packageInfoLocation
|
||||
}
|
||||
|
||||
# Set a variable which will be used by the pipeline later to fail the build if
|
||||
# any packages failed validation
|
||||
if ($allSucceeded) {
|
||||
Write-Host "##vso[task.setvariable variable=DocsMsPackagesAllValid;]$true"
|
||||
} else {
|
||||
Write-Host "##vso[task.setvariable variable=DocsMsPackagesAllValid;]$false"
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user