Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoAdonis committed May 1, 2023
2 parents c25e09d + 46db93c commit 75f9286
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
40 changes: 30 additions & 10 deletions .github/scripts/Build-ChangedSamples.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

2 changes: 1 addition & 1 deletion .github/workflows/ci-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:

- name: Get changed files
id: get-changed-files
uses: tj-actions/changed-files@v27
uses: tj-actions/changed-files@v35
with:
separator: ","

Expand Down

0 comments on commit 75f9286

Please sign in to comment.