Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
steps:
# Fail the build if any of the packages failed validation. Valid values are
# "true" or "false" though some attempt is made to parse the boolean value from
# the string.
- pwsh: |
$value = '$(DocsMsPackagesAllValid)'

try {
$result = [System.Convert]::ToBoolean($value)
Comment thread
danieljurek marked this conversation as resolved.
Outdated
if (!$result) {
Write-Error "Some packages failed validation"
exit 1
}

Write-Host "All packages passed validation"
} catch [FormatException] {
Write-Host "Failed to parse DocsMsPackagesAllValid value '$value' as a boolean."
Write-Error $_
exit 1
}
Comment thread
benbp marked this conversation as resolved.
displayName: Check package validation results
36 changes: 29 additions & 7 deletions eng/common/scripts/Update-DocsMsMetadata.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -230,17 +230,39 @@ 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..."
$allSucceeded = $true
foreach ($packageInfoLocation in $PackageInfoJsonLocations) {

$packageInfos = @($PackageInfoJsonLocations | ForEach-Object { GetPackageInfoJson $_ })
if ($ValidateDocsMsPackagesFn -and (Test-Path "Function:$ValidateDocsMsPackagesFn")) {
Write-Host "Validating the packages..."

&$ValidateDocsMsPackagesFn -PackageInfos $packageInfos -PackageSourceOverride $PackageSourceOverride -DocValidationImageId $DocValidationImageId -DocRepoLocation $DocRepoLocation
}
$packageInfo = GetPackageInfoJson $packageInfoLocation
# "Validate-${Language}-DocMsPackages"
Comment thread
danieljurek marked this conversation as resolved.
Outdated
$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
}
}

foreach ($packageInfoLocation in $PackageInfoJsonLocations) {
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) {
Comment thread
weshaggard marked this conversation as resolved.
Write-Host "##vso[task.setvariable variable=DocsMsPackagesAllValid;]$true"
} else {
Write-Host "##vso[task.setvariable variable=DocsMsPackagesAllValid;]$false"
}