From 9655b9f5b8501207b9ec7f8e80a3cae0a1a76a14 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Wed, 25 Sep 2024 11:46:31 -0700 Subject: [PATCH] Sync eng/common directory with azure-sdk-tools for PR 9035 (#6032) * don't verify changelog for packages that aren't actively published anymore --------- Co-authored-by: Scott Beddall Co-authored-by: Scott Beddall <45376673+scbedd@users.noreply.github.com> Co-authored-by: Ben Broderick Phillips --- eng/common/scripts/Verify-ChangeLogs.ps1 | 32 +++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/eng/common/scripts/Verify-ChangeLogs.ps1 b/eng/common/scripts/Verify-ChangeLogs.ps1 index fbf117d5b..1aeb33a52 100644 --- a/eng/common/scripts/Verify-ChangeLogs.ps1 +++ b/eng/common/scripts/Verify-ChangeLogs.ps1 @@ -7,6 +7,32 @@ Set-StrictMode -Version 3 . (Join-Path $PSScriptRoot common.ps1) +function ShouldVerifyChangeLog ($ServiceDirectory, $PackageName) { + $jsonCiYmlPath = Join-Path $ServiceDirectory "ci.yml" + + if (Test-Path $jsonCiYmlPath) + { + $ciYml = Get-Content $jsonCiYmlPath -Raw | yq -o=json | ConvertFrom-Json -AsHashTable + + 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 + } + } + } +} + +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 +} + # find which packages we need to confirm the changelog for $packageProperties = Get-ChildItem -Recurse "$PackagePropertiesFolder" *.json @@ -15,6 +41,11 @@ $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)) { + Write-Host "Skipping changelog verification for $($PackageProp.Name)" + continue + } + $validChangeLog = Confirm-ChangeLogEntry -ChangeLogLocation $PackageProp.ChangeLogPath -VersionString $PackageProp.Version -ForRelease $false if (-not $validChangeLog) { @@ -22,7 +53,6 @@ foreach($propertiesFile in $packageProperties) { } } - if (!$allPassing) { exit 1