Skip to content
Merged
Changes from 1 commit
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
27 changes: 19 additions & 8 deletions eng/common/scripts/Verify-ChangeLogs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ Set-StrictMode -Version 3

. (Join-Path $PSScriptRoot common.ps1)

function ShouldVerifyChangeLog ($ServiceDirectory, $PackageName) {
$jsonCiYmlPath = Join-Path $ServiceDirectory "ci.yml"

function ShouldVerifyChangeLog ($PkgArtifactDetails, $PackageName) {
if (Test-Path $jsonCiYmlPath)
{
$ciYml = Get-Content $jsonCiYmlPath -Raw | yq -o=json | ConvertFrom-Json -AsHashTable
$ciYml = Get-Content $jsonCiYmlPath -Raw | CompatibleConvertFrom-Yaml

if ($ciYml.extends -and $ciYml.extends.parameters -and $ciYml.extends.parameters.Artifacts) {
$packagesCheckingChangeLog = $ciYml.extends.parameters.Artifacts `
Expand All @@ -28,11 +26,24 @@ function ShouldVerifyChangeLog ($ServiceDirectory, $PackageName) {
}
}

if (-not (Get-Command 'yq' -ErrorAction SilentlyContinue)) {
Write-Host "Error: 'yq' is not installed or not found in PATH. Please remedy this before running this script."
exit 1
function ShouldVerifyChangeLog ($PkgArtifactDetails) {
if ($PkgArtifactDetails) {
Write-Host $PkgArtifactDetails.Name
$possibleValue = $PkgArtifactDetails.PSObject.Properties["skipVerifyChangeLog"]

if ($possibleValue) {
if ($possibleValue -eq $true) {
return $false
}
}

return $true
}

return $false
}


# find which packages we need to confirm the changelog for
$packageProperties = Get-ChildItem -Recurse "$PackagePropertiesFolder" *.json

Expand All @@ -41,7 +52,7 @@ $allPassing = $true
foreach($propertiesFile in $packageProperties) {
$PackageProp = Get-Content -Path $propertiesFile | ConvertFrom-Json

if (-not (ShouldVerifyChangeLog -ServiceDirectory (Join-Path $RepoRoot "sdk" $PackageProp.ServiceDirectory) -PackageName $PackageProp.Name)) {
if (-not (ShouldVerifyChangeLog $PackageProp.ArtifactDetails)) {
Write-Host "Skipping changelog verification for $($PackageProp.Name)"
continue
}
Expand Down