From 2375f3f0c80c29b1f3e4015966d0923898e9eb08 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 1aeb33a52..114309f03 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 34d3f94c48bde914091e7a28794c823326c186fa 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 114309f03..f3f18375e 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 e81e62e12f4b949d8a0e15ce8c4b6eb41726d27b 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 f3f18375e..959847272 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