mirror of
https://github.com/actions/runner-images.git
synced 2025-12-13 04:37:09 +00:00
try
This commit is contained in:
@@ -7,6 +7,7 @@ Install-Module -Name GripDevJsonSchemaValidator -Force -Scope CurrentUser
|
|||||||
$toolsetFiles = Get-ChildItem -Recurse -Filter "toolset-*.json" | Where-Object { $_.Name -notlike "*schema.json" }
|
$toolsetFiles = Get-ChildItem -Recurse -Filter "toolset-*.json" | Where-Object { $_.Name -notlike "*schema.json" }
|
||||||
$schemaFilePath = "./schemas/toolset-schema.json"
|
$schemaFilePath = "./schemas/toolset-schema.json"
|
||||||
|
|
||||||
|
$toolsetHasErrors = $false
|
||||||
foreach ($file in $toolsetFiles) {
|
foreach ($file in $toolsetFiles) {
|
||||||
Write-Host "🔍 Validating $($file.FullName)" -ForegroundColor Cyan
|
Write-Host "🔍 Validating $($file.FullName)" -ForegroundColor Cyan
|
||||||
|
|
||||||
@@ -15,15 +16,21 @@ foreach ($file in $toolsetFiles) {
|
|||||||
if ($validationResult.Valid) {
|
if ($validationResult.Valid) {
|
||||||
Write-Host "✅ JSON is valid." -ForegroundColor Green
|
Write-Host "✅ JSON is valid." -ForegroundColor Green
|
||||||
} else {
|
} else {
|
||||||
|
$toolsetHasErrors = $true
|
||||||
Write-Host "`n❌ JSON validation failed!" -ForegroundColor Red
|
Write-Host "`n❌ JSON validation failed!" -ForegroundColor Red
|
||||||
Write-Host " Found the following errors:`n" -ForegroundColor Yellow
|
Write-Host " Found the following errors:`n" -ForegroundColor Yellow
|
||||||
$validationResult.Errors | ForEach-Object {
|
$validationResult.Errors | ForEach-Object {
|
||||||
Write-Host $_.UserMessage
|
Write-Host $_.UserMessage
|
||||||
if ($env:GITHUB_ACTIONS -eq 'true') {
|
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"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user