Make build/test worktree-aware and add same-worktree lock#737
Make build/test worktree-aware and add same-worktree lock#737johnml1135 wants to merge 2 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the repo’s PowerShell build/test tooling to be worktree-aware, enabling safer concurrent workflows across multiple git worktrees while enforcing single active scripted workflow per worktree via a lock.
Changes:
- Add same-worktree exclusivity using a named mutex +
Output/WorktreeRun.lock.jsonmetadata (with optionalFW_BUILD_STARTED_BY/-StartedByactor tagging). - Scope process cleanup and file-lock retry cleanup to the current worktree root (
$PSScriptRoot) so other worktrees aren’t affected. - Change
build.ps1default MSBuild node reuse to-NodeReuse $falseto reduce cross-worktree contention, and document the new behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
build.ps1 |
Acquires worktree lock, scopes cleanup by repo root, defaults -NodeReuse to false, and passes -SkipWorktreeLock to child test.ps1 under -RunTests. |
test.ps1 |
Adds optional -StartedBy, supports -SkipWorktreeLock, scopes cleanup by repo root, and releases lock in finally. |
Build/Agent/FwBuildHelpers.psm1 |
Implements Enter-WorktreeLock/Exit-WorktreeLock, adds worktree-aware filtering to Stop-ConflictingProcesses, and extends Invoke-WithFileLockRetry with optional -RepoRoot. |
.github/instructions/build.instructions.md |
Documents worktree-aware cleanup, same-worktree lock behavior, and -NodeReuse default change. |
.github/instructions/testing.instructions.md |
Documents worktree-aware behavior and lock reuse for build.ps1 -RunTests. |
ReadMe.md |
Adds a concise overview of concurrent worktree behavior and lock tagging. |
7681b09 to
4ce9d95
Compare
|
I see you added this here and in build.ps1, but I don't see build.ps1 passing it to the tests when -RunTests is used. |
ea9cbbd to
37dfba4
Compare
37dfba4 to
b738d41
Compare
|
Update:
That keeps the PR focused on the worktree-lock behavior while addressing the test handoff issue you flagged. |
|
Shouldn't this be $SkipWorktreeLock? |
jasonleenaylor
left a comment
There was a problem hiding this comment.
@jasonleenaylor partially reviewed 6 files and all commit messages, made 1 comment, and resolved 1 discussion.
Reviewable status: 3 of 7 files reviewed, all discussions resolved.
Summary
Output/WorktreeRun.lock.jsonmetadata.FW_BUILD_STARTED_BYor-StartedBy.build.ps1 -RunTestsworking by having childtest.ps1reuse the parent lock (-SkipWorktreeLock).build.ps1 -NodeReusetofalsefor safer multi-worktree behavior.Files
build.ps1test.ps1Build/Agent/FwBuildHelpers.psm1.github/instructions/build.instructions.md.github/instructions/testing.instructions.mdReadMe.mdValidation
build.ps1orBuild/Agent/FwBuildHelpers.psm1.test.ps1(vstestOutputassigned but not used).This change is