Fix modifiedApps incremental builds for projects with external appFolders#2194
Conversation
…l appFolders When a project is nested (e.g. build/projects/MyProject) and its appFolders reference sources outside the project via ../ paths, the modifiedApps incremental build mode failed to match any unmodified apps for baseline download. This caused all apps to be recompiled on every PR even when only one file changed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes incremental builds in modifiedApps mode for projects whose appFolders resolve to paths outside the project directory (via ../), ensuring unmodified apps can be downloaded from the baseline workflow run instead of always being rebuilt.
Changes:
- Replace brittle
SubString(2)-based folder matching with a new helper that resolves project-relative folders and converts them to repo-relative paths for comparison. - Add Pester coverage for both nested-project (
../paths) and standard (.\paths) layouts to prevent regressions.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| Actions/DetermineProjectsToBuild/DetermineProjectsToBuild.psm1 | Fixes skip/download folder matching by resolving to absolute paths and converting to repo-relative paths before comparing with $skipFolders. |
| Tests/DetermineProjectsToBuild.Test.ps1 | Adds two tests validating correct unmodified-app detection for external appFolders and standard in-project folders. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ae2b4f5 to
5375ac4
Compare
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@copilot Can you please add release notes. Also, fix the PSScriptAnalyzer alerts. |
@Groenbech96 can you please summon @copilot for a couple of more things? |
Summary
When
incrementalBuilds.modeis set tomodifiedAppsand a project references app folders outside its own directory via../paths, unmodified apps are never downloaded from the baseline workflow run. Instead, every app is recompiled on every PR — even when only a single file changed.The bug
Get-UnmodifiedAppsFromBaselineWorkflowRunneeds to match entries from$settings.appFolders(project-relative paths) against$skipFolders(repo-relative paths). The old code assumed all resolved folder paths start with.\and usedSubString(2)to strip that prefix:This works when apps live inside the project folder (paths like
.\app), but breaks when apps live outside (paths like..\..\..\src\Apps\SomeApp\App).Toy example to illustrate
Consider a repo layout where a project at
build/projects/MyProjectreferences apps atsrc/:After
ResolveProjectFoldersresolves the glob from the project directory,$settings.appFolderscontains:Meanwhile,
$skipFolders(fromGetFoldersFromAllProjects, resolved from the repo root) contains:The old matching logic did:
$_.SubString(2)on..\..\..\src\Apps\Reporting\App\..\..\src\Apps\Reporting\Appbuild\projects\MyProject\..\..\src\Apps\Reporting\App$skipFolderssrc\Apps\Reporting\AppThe result:
$downloadAppFoldersis always empty → no artifacts downloaded from baseline → all apps recompiled.For comparison, the standard layout (apps inside the project) works because paths start with
.\:$_.SubString(2)on.\appappapp$skipFoldersappThe fix
Replace the
SubString(2)hack with proper path resolution. A new helperConvertTo-RepoRelativePathresolves each project-relative folder to an absolute path viaJoin-Path -Resolve, then strips the base folder prefix to produce a clean repo-relative path that matches$skipFoldersexactly:This works for both layouts:
$settings.appFoldersentry$skipFolders?..\..\..\src\Apps\Reporting\AppD:\a\repo\src\Apps\Reporting\Appsrc\Apps\Reporting\App.\appD:\a\repo\appappTests
Two new Pester tests added to
DetermineProjectsToBuild.Test.ps1:../paths — creates a repo layout where apps are outside the project folder. Fails without the fix (Download appFolders: - None), passes with the fix.Test plan