Skip to content

Commit

Permalink
Add configuration filter to exclusion list (#1001)
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoAdonis authored Jun 29, 2023
1 parent f5fe952 commit d9acf79
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/scripts/Build-ChangedSamples.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ foreach ($file in $ChangedFiles) {
$filename = Split-Path $file -Leaf

# Files that can affect how every sample is built should trigger a full build
if ($filename -eq "Build-AllSamples.ps1" -or $filename -eq "Build-Sample.ps1") {
if ($filename -eq "Build-AllSamples.ps1" -or $filename -eq "Build-Sample.ps1" -or $filename -eq "Build-SampleSet.ps1") {
$buildAll = $true
}
if ($dir -like "$root\.github\scripts" -or $dir -like "$root\.github\scripts\*") {
Expand Down
23 changes: 15 additions & 8 deletions Build-SampleSet.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ param(
[int]$ThrottleLimit = 0
)

$root = Get-Location
$ThrottleFactor = 5
$LogicalProcessors = (Get-CIMInstance -Class 'CIM_Processor' -Verbose:$false).NumberOfLogicalProcessors

Expand Down Expand Up @@ -43,10 +44,16 @@ finally {
$ErrorActionPreference = $oldPreference
}

# TODO: Make exclusion more granular; allow for configuration|platform exclusions
$exclusionsSet = @{}
$exclusionConfigurations = @{}
$exclusionReasons = @{}
Import-Csv 'exclusions.csv' | ForEach-Object {
$exclusionsSet[$_.Path.Replace($root, '').Trim('\').Replace('\', '.').ToLower()] = $_.Reason
if ($_.Configurations) {
$exclusionConfigurations[$_.Path.Replace($root, '').Trim('\').Replace('\', '.').ToLower()] = $_.Configurations
}
else {
$exclusionConfigurations[$_.Path.Replace($root, '').Trim('\').Replace('\', '.').ToLower()] = '*'
}
$exclusionReasons[$_.Path.Replace($root, '').Trim('\').Replace('\', '.').ToLower()] = $_.Reason
}

$jresult = @{
Expand Down Expand Up @@ -88,9 +95,11 @@ $sw = [Diagnostics.Stopwatch]::StartNew()

$SampleSet.GetEnumerator() | ForEach-Object -ThrottleLimit $ThrottleLimit -Parallel {
$LogFilesDirectory = $using:LogFilesDirectory
$exclusionsSet = $using:exclusionsSet
$exclusionConfigurations = $using:exclusionConfigurations
$exclusionReasons = $using:exclusionReasons
$Configurations = $using:Configurations
$Platforms = $using:Platforms
$Verbose = $using:Verbose

$sampleName = $_.Key
$directory = $_.Value
Expand All @@ -107,11 +116,9 @@ $SampleSet.GetEnumerator() | ForEach-Object -ThrottleLimit $ThrottleLimit -Paral
$thisresult = "Not run"
$thisfailset = @()

if ($exclusionsSet.ContainsKey($sampleName)) {
if ($exclusionConfigurations.ContainsKey($sampleName) -and ($exclusionConfigurations[$sampleName].Split(';') | Where-Object { "$configuration|$platform" -like $_ })) {
# Verbose
if ($thisexcluded -eq 0) {
Write-Verbose "[$sampleName] `u{23E9} Excluded and skipped. Reason: $($exclusionsSet[$sampleName])"
}
Write-Verbose "[$sampleName $configuration|$platform] `u{23E9} Excluded and skipped. Reason: $($exclusionReasons[$sampleName])"
$thisexcluded += 1
$thisresult = "Excluded"
}
Expand Down

0 comments on commit d9acf79

Please sign in to comment.