Skip to content

Commit

Permalink
call yq from script
Browse files Browse the repository at this point in the history
  • Loading branch information
scbedd authored and azure-sdk committed Sep 24, 2024
1 parent b458080 commit 5ec7f75
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
6 changes: 0 additions & 6 deletions eng/common/pipelines/templates/steps/verify-changelogs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ parameters:
default: succeeded()

steps:
- pwsh: |
Get-ChildItem -Recurse -Path "$(Build.SourcesDirectory)/sdk" -Include ci.yml `
| ForEach-Object { Get-Content $_ -Raw | yq -o=json > "$($_.FullName).json" }
displayName: Generate ci.yml.json
condition: ${{ parameters.Condition }}
- task: Powershell@2
inputs:
filePath: $(Build.SourcesDirectory)/eng/common/scripts/Verify-ChangeLogs.ps1
Expand Down
10 changes: 7 additions & 3 deletions eng/common/scripts/Verify-ChangeLogs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@ Set-StrictMode -Version 3
. (Join-Path $PSScriptRoot common.ps1)

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

if (Test-Path $jsonCiYmlPath)
{
$ciYml = ConvertFrom-Json (Get-Content $jsonCiYmlPath -Raw) -AsHashTable
$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
Expand All @@ -29,6 +28,11 @@ 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
}

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

Expand Down

0 comments on commit 5ec7f75

Please sign in to comment.