Skip to content

Run the Go and TypeScript AppHost tests one at a time - #2595

Open
Laurianti wants to merge 2 commits into
CommunityToolkit:mainfrom
Laurianti:apphost-tests-no-overlap
Open

Laurianti wants to merge 2 commits into
CommunityToolkit:mainfrom
Laurianti:apphost-tests-no-overlap

Conversation

@Laurianti

@Laurianti Laurianti commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Since #2438 added the Go AppHost tests, GoAppHostTests and TypeScriptAppHostTests fail at random in CI. Example, GoAppHostCompiles in Hosting.Chroma.Tests-ubuntu-latest:

error MSB4018: The "GenerateDepsFile" task failed unexpectedly.
error MSB4018: System.IO.IOException: The process cannot access the file '/home/runner/work/Aspire/Aspire/src/CommunityToolkit.Aspire.Hosting.Chroma/bin/Debug/net10.0/CommunityToolkit.Aspire.Hosting.Chroma.deps.json' because it is being used by another process.

The Go and TypeScript AppHosts of an example list the same integration project in aspire.config.json, and aspire restore builds it in place. In 46 test projects the two test classes run in parallel, so two builds write the same files under bin/Debug and obj/Debug at once. On Windows the same collision is a CS2012 (job).

GoAppHostTest.Run and TypeScriptAppHostTest.Run now take a lock shared by the test process around the Aspire CLI commands, so the two builds run one after the other. npm ci only writes to the AppHost directory, so TypeScriptAppHostTest.Run runs it before taking the lock and passes the new -SkipNpmInstall switch to validate-typescript-apphost.ps1. Run on its own, the script still installs the packages.

When the wait is canceled, ProcessTestUtilities.RunProcessAsync now stops the process and its children before the cancellation reaches the caller, so the lock isn't released while a build still runs.

PR Checklist

  • Created a feature/dev branch in your fork (vs. submitting directly from a commit on main)
  • Based off latest main branch of toolkit
  • PR doesn't include merge commits (always rebase on top of our main, if needed)
  • Contains NO breaking changes
  • Every new API (including internal ones) has full XML docs
  • Code follows all style conventions

Other information

Tested on GitHub-hosted runners: each job checks out, builds and runs one test project once, with the command line of the CI. Hosting.ActiveMQ.Tests on Ubuntu: on main 5 of 154 jobs failed with this collision, and the Aspire CLI logs show the two builds overlapping in 153 jobs; with this change 0 of 150 jobs failed and the builds never overlap. The median duration of the test run is the same with and without this change: 123 s and 120 s for Hosting.Chroma.Tests on Ubuntu, 129 s and 126 s for Hosting.Squad.Tests on Windows.

Cancellation of RunProcessAsync, tested on Windows and Linux with a child process that writes a file every 200 ms: before this change the child kept writing after the cancellation, now it is stopped.

The Go and TypeScript AppHosts of an example reference the same integration project, and the Aspire CLI builds it in place. The two test classes run in parallel, so two builds can write the same files under bin/Debug and obj/Debug at once, and one of them fails.

The two helpers now take a lock shared by the test process around the Aspire CLI commands. npm ci only writes to the AppHost directory, so the TypeScript helper runs it before taking the lock.
Copilot AI balanced review requested due to automatic review settings November 24, 2026 14:13
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/CommunityToolkit/Aspire/main/eng/scripts/dogfood-pr.sh | bash -s -- 2595

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/CommunityToolkit/Aspire/main/eng/scripts/dogfood-pr.ps1) } 2595"

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Cancellation can release the build lock while aspire restore and its child processes are still running, allowing another call to start a conflicting build and write concurrently to bin/obj.

1 open issue
What changed in this PR

This PR addresses intermittent CI build collisions introduced by running Go and TypeScript AppHost tests in parallel against the same integration project.

Changes:

  • Adds a process-wide lock shared by both AppHost test helpers.
  • Moves TypeScript’s npm ci outside the lock to preserve parallel dependency installation.
  • Adds -SkipNpmInstall while preserving the validation script’s standalone installation behavior.
File Description
tests/​CommunityToolkit.Aspire.Testing/​TypeScriptAppHostTest.cs Installs npm dependencies before acquiring the shared lock.
tests/​CommunityToolkit.Aspire.Testing/​PolyglotAppHostLock.cs Adds a semaphore-backed lock with a disposable release handle.
tests/​CommunityToolkit.Aspire.Testing/​GoAppHostTest.cs Acquires the shared lock around Go AppHost validation.
eng/​testing/​validate-typescript-apphost.ps1 Allows callers to skip npm installation when already completed.

Review effort: Balanced

Canceling WaitForExitAsync only stops the wait: the process and its children keep running. The AppHost helpers then released their lock while aspire restore could still be writing to bin and obj. RunProcessAsync now kills the process tree and waits for it to exit before the cancellation reaches the caller.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants