From be9347d403c9ba3179321fe9500b956245e8f3e7 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Mon, 30 Sep 2024 15:33:18 -0700 Subject: [PATCH] [TypeSpecValidation] Apply "all" suppressions when core files changed (#30805) - Fixes #30521 --- eng/scripts/Get-TypeSpec-Folders.ps1 | 6 +++++- eng/scripts/TypeSpec-Validation.ps1 | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/eng/scripts/Get-TypeSpec-Folders.ps1 b/eng/scripts/Get-TypeSpec-Folders.ps1 index 1ddb8ef0fc55..e667216b0bdb 100644 --- a/eng/scripts/Get-TypeSpec-Folders.ps1 +++ b/eng/scripts/Get-TypeSpec-Folders.ps1 @@ -9,10 +9,13 @@ Set-StrictMode -Version 3 . $PSScriptRoot/ChangedFiles-Functions.ps1 $repoPath = Resolve-Path "$PSScriptRoot/../.." + $checkAllPath = ((Get-ChildItem "specification" -Directory).Name -replace '^', 'specification/') -replace '$', '/' +$checkedAll = $false if ($CheckAll) { $changedFiles = $checkAllPath + $checkedAll = $true } else { $changedFiles = @(Get-ChangedFiles -baseCommitish $BaseCommitish -targetCommitish $TargetCommitish -diffFilter "") @@ -21,6 +24,7 @@ else { if ($coreChangedFiles) { Write-Verbose "Found changes to core eng or root files so checking all specs." $changedFiles = $checkAllPath + $checkedAll = $true } else { $changedFiles = Get-ChangedFilesUnderSpecification $changedFiles @@ -49,4 +53,4 @@ foreach ($skippedTypespecFolder in $skippedTypespecFolders | Select-Object -Uniq $typespecFolders = $typespecFolders | ForEach-Object { [IO.Path]::GetRelativePath($repoPath, $_) -replace '\\', '/' } | Sort-Object -Unique -return $typespecFolders +return @($typespecFolders, $checkedAll) diff --git a/eng/scripts/TypeSpec-Validation.ps1 b/eng/scripts/TypeSpec-Validation.ps1 index 30985a681fb7..031ae7d69000 100644 --- a/eng/scripts/TypeSpec-Validation.ps1 +++ b/eng/scripts/TypeSpec-Validation.ps1 @@ -10,7 +10,7 @@ param ( . $PSScriptRoot/Logging-Functions.ps1 . $PSScriptRoot/Suppressions-Functions.ps1 -$typespecFolders = &"$PSScriptRoot/Get-TypeSpec-Folders.ps1" -BaseCommitish:$BaseCommitish -TargetCommitish:$TargetCommitish -CheckAll:$CheckAll +$typespecFolders, $checkedAll = &"$PSScriptRoot/Get-TypeSpec-Folders.ps1" -BaseCommitish:$BaseCommitish -TargetCommitish:$TargetCommitish -CheckAll:$CheckAll $typespecFoldersWithFailures = @() if ($typespecFolders) { @@ -18,7 +18,7 @@ if ($typespecFolders) { foreach ($typespecFolder in $typespecFolders) { LogGroupStart "Validating $typespecFolder" - if ($CheckAll) { + if ($checkedAll) { $suppression = Get-Suppression "TypeSpecValidationAll" $typespecFolder if ($suppression) { $reason = $suppression["reason"] ?? ""