Skip to content

Fix CI template test conflicts by implementing template isolation #63153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 6, 2025

The CI job for local development validation was disabled due to conflicts with concurrent template tests. When both the Helix template tests and the local development validation job ran simultaneously, they would interfere with each other's template engine state, causing build failures.

Root Cause

The issue occurred because two different template testing workflows were accessing shared global state:

  1. Helix template tests (in default-build.yml) already used proper isolation via --debug:custom-hive
  2. Local development validation (in ci-public.yml) used global template installation in the user profile

This led to race conditions when both jobs tried to install/uninstall templates concurrently:

# Problematic: Global template installation
dotnet new install $PackagePath

Solution

Modified src/ProjectTemplates/scripts/Test-Template.psm1 to use the same isolation strategy as the Helix template tests:

# Isolated: Each test run gets its own template hive
$CustomHivePath = "$PSScriptRoot/.templatehive-$templateName"
dotnet new install $PackagePath --debug:disable-sdk-templates --debug:custom-hive $CustomHivePath
dotnet new $templateName --debug:custom-hive $CustomHivePath --debug:disable-sdk-templates

Key improvements:

  • Unique custom hive per test run prevents template installation conflicts
  • SDK template exclusion ensures complete isolation from system templates
  • Automatic cleanup in finally blocks prevents state leakage between runs
  • Process-scoped environment variables avoid global pollution

The solution mirrors the proven isolation pattern already used by Helix template tests, ensuring both workflows can run concurrently without conflicts.

Testing

  • Verified PowerShell module syntax loads correctly
  • Template isolation commands match existing successful patterns in the codebase
  • Re-enabled the previously disabled CI job by changing condition: 'false' to condition: 'true'

Fixes #63149.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copy link
Contributor

Greetings human! You've submitted a PR that modifies code that is shared with https://github.com/dotnet/runtime . Please make sure you synchronize this code with the changes in that repo!

@Copilot Copilot AI changed the title [WIP] CI template tests are not passing at the same time as local developmnet validation tests Fix CI template test conflicts by implementing template isolation Aug 6, 2025
@Copilot Copilot AI requested a review from ilonatommy August 6, 2025 16:46
Copilot finished work on behalf of ilonatommy August 6, 2025 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CI template tests are not passing at the same time as local developmnet validation tests
2 participants