Skip to content

Commit

Permalink
[TypeSpecValidation] Apply "all" suppressions when core files changed (
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeharder authored and digvijaymali94 committed Dec 17, 2024
1 parent 098749a commit d6f73a7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion eng/scripts/Get-TypeSpec-Folders.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 "")
Expand All @@ -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
Expand Down Expand Up @@ -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)
4 changes: 2 additions & 2 deletions eng/scripts/TypeSpec-Validation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ 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) {
$typespecFolders = $typespecFolders.Split('',[System.StringSplitOptions]::RemoveEmptyEntries)
foreach ($typespecFolder in $typespecFolders) {
LogGroupStart "Validating $typespecFolder"

if ($CheckAll) {
if ($checkedAll) {
$suppression = Get-Suppression "TypeSpecValidationAll" $typespecFolder
if ($suppression) {
$reason = $suppression["reason"] ?? "<no reason specified>"
Expand Down

0 comments on commit d6f73a7

Please sign in to comment.