From 3bc475f72e4a2bf38ad1897ce92d74be952b0d4a Mon Sep 17 00:00:00 2001 From: lawrencegripper Date: Fri, 31 Jan 2025 10:04:51 +0000 Subject: [PATCH] try --- helpers/CheckJsonSchema.ps1 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/helpers/CheckJsonSchema.ps1 b/helpers/CheckJsonSchema.ps1 index f38eafda2..e338530d4 100644 --- a/helpers/CheckJsonSchema.ps1 +++ b/helpers/CheckJsonSchema.ps1 @@ -7,6 +7,7 @@ Install-Module -Name GripDevJsonSchemaValidator -Force -Scope CurrentUser $toolsetFiles = Get-ChildItem -Recurse -Filter "toolset-*.json" | Where-Object { $_.Name -notlike "*schema.json" } $schemaFilePath = "./schemas/toolset-schema.json" +$toolsetHasErrors = $false foreach ($file in $toolsetFiles) { Write-Host "šŸ” Validating $($file.FullName)" -ForegroundColor Cyan @@ -15,15 +16,21 @@ foreach ($file in $toolsetFiles) { if ($validationResult.Valid) { Write-Host "āœ… JSON is valid." -ForegroundColor Green } else { + $toolsetHasErrors = $true Write-Host "`nāŒ JSON validation failed!" -ForegroundColor Red Write-Host " Found the following errors:`n" -ForegroundColor Yellow $validationResult.Errors | ForEach-Object { Write-Host $_.UserMessage if ($env:GITHUB_ACTIONS -eq 'true') { - Write-Host "::error file=$($file.Name),line=$($_.LineNumber)::$($_.UserMessage)" + Write-Host "Adding annotation" + Write-Host "::error file=$($file.Name),line=$($_.LineNumber)::$($_.UserMessage.Replace("`n", '%0A'))" } } } } -Write-Host "Schema validation completed successfully" +if ($toolsetHasErrors) { + Write-Error "One or more toolset JSON files failed schema validation. See the error output above for more details." +} else { + Write-Host "Schema validation completed successfully" +}