From 5c451553044323fe548e82d108e16a3ac8feb7f8 Mon Sep 17 00:00:00 2001 From: Scott Beddall Date: Wed, 13 Nov 2024 16:29:53 -0800 Subject: [PATCH 1/3] change our verifyChangelogs over to utilizing the artifact details. if we don't have an artifact details at all, don't verify changelog. if we do, but skipverifychangelog is present, don't verify changelog. if we have artifact details, but no disable, verify the changelog --- eng/common/scripts/Verify-ChangeLogs.ps1 | 27 +++++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/eng/common/scripts/Verify-ChangeLogs.ps1 b/eng/common/scripts/Verify-ChangeLogs.ps1 index 1aeb33a52c8e..114309f03642 100644 --- a/eng/common/scripts/Verify-ChangeLogs.ps1 +++ b/eng/common/scripts/Verify-ChangeLogs.ps1 @@ -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 ` @@ -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 @@ -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 } From 4e1e8cfeb59a83f3d0bc3075d267043f8b0dab10 Mon Sep 17 00:00:00 2001 From: Scott Beddall Date: Wed, 13 Nov 2024 16:44:58 -0800 Subject: [PATCH 2/3] remove extra definition of ShouldVerifyChangelog --- eng/common/scripts/Verify-ChangeLogs.ps1 | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/eng/common/scripts/Verify-ChangeLogs.ps1 b/eng/common/scripts/Verify-ChangeLogs.ps1 index 114309f03642..f3f18375ec87 100644 --- a/eng/common/scripts/Verify-ChangeLogs.ps1 +++ b/eng/common/scripts/Verify-ChangeLogs.ps1 @@ -7,25 +7,6 @@ Set-StrictMode -Version 3 . (Join-Path $PSScriptRoot common.ps1) -function ShouldVerifyChangeLog ($PkgArtifactDetails, $PackageName) { - if (Test-Path $jsonCiYmlPath) - { - $ciYml = Get-Content $jsonCiYmlPath -Raw | CompatibleConvertFrom-Yaml - - if ($ciYml.extends -and $ciYml.extends.parameters -and $ciYml.extends.parameters.Artifacts) { - $packagesCheckingChangeLog = $ciYml.extends.parameters.Artifacts ` - | Where-Object { -not ($_["skipVerifyChangelog"] -eq $true) } ` - | Select-Object -ExpandProperty name - if ($packagesCheckingChangeLog -contains $PackageName) - { - return $true - } else { - return $false - } - } - } -} - function ShouldVerifyChangeLog ($PkgArtifactDetails) { if ($PkgArtifactDetails) { Write-Host $PkgArtifactDetails.Name @@ -43,7 +24,6 @@ function ShouldVerifyChangeLog ($PkgArtifactDetails) { return $false } - # find which packages we need to confirm the changelog for $packageProperties = Get-ChildItem -Recurse "$PackagePropertiesFolder" *.json From ae6153d33e84cd412f9c17906452de5c7bcc9af7 Mon Sep 17 00:00:00 2001 From: Scott Beddall Date: Wed, 13 Nov 2024 16:47:59 -0800 Subject: [PATCH 3/3] simplify even more --- eng/common/scripts/Verify-ChangeLogs.ps1 | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/eng/common/scripts/Verify-ChangeLogs.ps1 b/eng/common/scripts/Verify-ChangeLogs.ps1 index f3f18375ec87..9598472720c5 100644 --- a/eng/common/scripts/Verify-ChangeLogs.ps1 +++ b/eng/common/scripts/Verify-ChangeLogs.ps1 @@ -7,15 +7,11 @@ Set-StrictMode -Version 3 . (Join-Path $PSScriptRoot common.ps1) + function ShouldVerifyChangeLog ($PkgArtifactDetails) { if ($PkgArtifactDetails) { - Write-Host $PkgArtifactDetails.Name - $possibleValue = $PkgArtifactDetails.PSObject.Properties["skipVerifyChangeLog"] - - if ($possibleValue) { - if ($possibleValue -eq $true) { - return $false - } + if ($PkgArtifactDetails.PSObject.Properties["skipVerifyChangeLog"] -eq $true) { + return $false } return $true