diff options
| author | Adonais Romero González <[email protected]> | 2023-05-01 15:28:26 -0700 |
|---|---|---|
| committer | Adonais Romero González <[email protected]> | 2023-05-01 15:28:26 -0700 |
| commit | 75f92869610aae4fee19eca3eeb2af0fccd37948 (patch) | |
| tree | d6073e08df962356508c928b96977093bc6ecbc1 /.github/scripts/Build-ChangedSamples.ps1 | |
| parent | c25e09d5d97a284adf83e3824527c133ad69fd6d (diff) | |
| parent | 46db93c4c0542166457f5504010b402a9426ab1d (diff) | |
Merge branch 'main' into develop
Diffstat (limited to '.github/scripts/Build-ChangedSamples.ps1')
| -rw-r--r-- | .github/scripts/Build-ChangedSamples.ps1 | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/.github/scripts/Build-ChangedSamples.ps1 b/.github/scripts/Build-ChangedSamples.ps1 index 82096cd6..b669a16a 100644 --- a/.github/scripts/Build-ChangedSamples.ps1 +++ b/.github/scripts/Build-ChangedSamples.ps1 @@ -10,31 +10,51 @@ if ($PSBoundParameters.ContainsKey('Verbose')) { $root = (Get-Location).Path -# To include in CI gate +# Search for samples (directories) to build $sampleSet = @{} -foreach ($file in $ChangedFiles) -{ +$buildAll = $false +foreach ($file in $ChangedFiles) { if (-not (Test-Path $file)) { Write-Verbose "`u{2754} Changed file $file cannot be found" continue } $dir = (Get-Item $file).DirectoryName - while ((-not ($slnItems = (Get-ChildItem $dir '*.sln'))) -and ($dir -ne $root)) + $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") { + $buildAll = $true + } + if ($dir -like "$root\.github\scripts" -or $dir -like "$root\.github\scripts\*") { + $buildAll = $true + } + if ($dir -like "$root\.github\workflows" -or $dir -like "$root\.github\workflows\*") { + $buildAll = $true + } + if ($buildAll) { + Write-Verbose "`u{2754} Full build triggered by change in file $file" + break + } + + while ((-not ($slnItems = (Get-ChildItem $dir '*.sln'))) -and ($dir -ne $root)) { $dir = (Get-Item $dir).Parent.FullName } - if ($dir -eq $root) - { - Write-Verbose "`u{2754} Changed file $file does not match a sample." + if ($dir -eq $root) { + Write-Verbose "`u{2754} Changed file $file does not match a sample" continue } $sampleName = $dir.Replace($root, '').Trim('\').Replace('\', '.').ToLower() Write-Verbose "`u{1F50E} Found sample [$sampleName] at $dir from changed file $file" - if (-not ($sampleSet.ContainsKey($sampleName))) - { + if (-not ($sampleSet.ContainsKey($sampleName))) { $sampleSet[$sampleName] = $dir } } -.\Build-SampleSet -SampleSet $sampleSet -Verbose:$Verbose -LogFilesDirectory (Join-Path $root "_logs") +if ($buildAll) { + .\Build-AllSamples -Verbose:$Verbose -LogFilesDirectory (Join-Path $root "_logs") +} +else { + .\Build-SampleSet -SampleSet $sampleSet -Verbose:$Verbose -LogFilesDirectory (Join-Path $root "_logs") +} |
