|
1 | 1 | <Project>
|
2 | 2 |
|
| 3 | + <!-- |
| 4 | + Environment variables: |
| 5 | + - IsGitHubActionsRunner: indicates whether tests are currently run on GitHub Actions; computed, overridable |
| 6 | + - IsAzdoRunner: indicates whether tests are currently run on Azure DevOps; computed, overridable |
| 7 | + - IsHelix: indicates whether tests are currently run on Helix; computed, overridable |
| 8 | +, |
| 9 | + Project capabilities: |
| 10 | + - IsTestProject: indicates whether the project is a test project; default is false; computed, overridable |
| 11 | + - IncludeTestUtilities: indicates whether the test project must not include the TestUtilities project reference; default is false; overridable |
| 12 | + - RunsOnGithubActions: indicates whether tests should run on GitHub Actions (either Windows or Linux); computed |
| 13 | + - RunsOnGithubActionsWindows: indicates whether tests should run on Windows in GitHub Actions; default is true; overridable |
| 14 | + - RunsOnGithubActionsLinux: indicates whether tests should run on Linux in GitHub Actions; default is true; overridable |
| 15 | + - RunsOnAzdo: indicates whether tests should run on Azure DevOps; default is true; overridable |
| 16 | + - RunsOnHelix: indicates whether tests should run on Helix (either Windows or Linux); computed |
| 17 | + - RunsOnHelixWindows: indicates whether tests should run on Windows in Helix; default is true; overridable |
| 18 | + - RunsOnHelixLinux: indicates whether tests should run on Linux in Helix; default is true; overridable |
| 19 | + --> |
| 20 | + |
| 21 | + <PropertyGroup> |
| 22 | + <!-- See https://docs.github.com/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#default-environment-variables --> |
| 23 | + <IsGitHubActionsRunner Condition=" '$(IsGitHubActionsRunner)' == '' and '$(GITHUB_ACTIONS)' == 'true' ">true</IsGitHubActionsRunner> |
| 24 | + |
| 25 | + <!-- See https://learn.microsoft.com/azure/devops/pipelines/build/variables#system-variables --> |
| 26 | + <IsAzdoRunner Condition=" '$(IsAzdoRunner)' == '' and '$(SYSTEM_TEAMPROJECT)' != '' ">true</IsAzdoRunner> |
| 27 | + |
| 28 | + <!-- See https://github.com/dotnet/arcade/blob/main/src/Microsoft.DotNet.Helix/Sdk/Readme.md#common-helix-client-environment-variables --> |
| 29 | + <IsHelix Condition=" '$(IsHelix)' == '' and '$(HELIX_CORRELATION_ID)' != '' ">true</IsHelix> |
| 30 | + </PropertyGroup> |
| 31 | + |
| 32 | + <PropertyGroup> |
| 33 | + <RunsOnGithubActions>false</RunsOnGithubActions> |
| 34 | + <RunsOnGithubActions Condition=" '$(RunsOnGithubActionsWindows)' == 'true' or '$(RunsOnGithubActionsLinux)' == 'true' ">true</RunsOnGithubActions> |
| 35 | + |
| 36 | + <RunsOnHelix>false</RunsOnHelix> |
| 37 | + <RunsOnHelix Condition=" '$(RunsOnHelixWindows)' == 'true' or '$(RunsOnHelixLinux)' == 'true' ">true</RunsOnHelix> |
| 38 | + |
| 39 | + <!-- If a test is run on Helix, then we don't run the test on AzDO --> |
| 40 | + <RunsOnAzdo Condition=" '$(RunsOnHelix)' == 'true' ">false</RunsOnAzdo> |
| 41 | + </PropertyGroup> |
| 42 | + |
| 43 | + <PropertyGroup Condition=" '$(SkipTests)' == '' and '$(IsTestProject)' == 'true' "> |
| 44 | + <!-- Skip tests by default unless explicitly set to false --> |
| 45 | + <SkipTests>true</SkipTests> |
| 46 | + |
| 47 | + <!-- Only run tests if the build is running on GitHub Actions --> |
| 48 | + <SkipTests Condition=" '$(IsGitHubActionsRunner)' == 'true' and '$(RunsOnGithubActions)' == 'true' ">false</SkipTests> |
| 49 | + |
| 50 | + <!-- Only run tests if the build is running on Helix infra --> |
| 51 | + <SkipTests Condition=" '$(IsHelix)' == 'true' and '$(RunsOnHelix)' == 'true' ">false</SkipTests> |
| 52 | + |
| 53 | + <!-- Otherwise, run tests on AzDO CI agents --> |
| 54 | + <SkipTests Condition=" '$(IsAzdoRunner)' == 'true' and '$(RunsOnAzdo)' == 'true' ">false</SkipTests> |
| 55 | + </PropertyGroup> |
| 56 | + |
| 57 | + <ItemGroup Condition=" '$(IsTestProject)' == 'true' and '$(IncludeTestUtilities)' != 'true' "> |
| 58 | + <ProjectReference Include="$(RepoRoot)tests\Aspire.TestUtilities\Aspire.TestUtilities.csproj" /> |
| 59 | + </ItemGroup> |
| 60 | + |
| 61 | + <!-- |
| 62 | + The following target is used to announce the test capabilities of the project. |
| 63 | + --> |
| 64 | + <Target Name="_AnnounceProjectTestCapabilities" BeforeTargets="RunTests" Condition="'$(IsTestProject)' == 'true'"> |
| 65 | + <PropertyGroup> |
| 66 | + <_IsGitHubActionsRunner Condition="'$(IsGitHubActionsRunner)' == ''">false</_IsGitHubActionsRunner> |
| 67 | + <_IsGitHubActionsRunner Condition="'$(IsGitHubActionsRunner)' != ''">$(IsGitHubActionsRunner)</_IsGitHubActionsRunner> |
| 68 | + <_IsAzdoRunner Condition="'$(IsAzdoRunner)' == ''">false</_IsAzdoRunner> |
| 69 | + <_IsAzdoRunner Condition="'$(IsAzdoRunner)' != ''">$(IsAzdoRunner)</_IsAzdoRunner> |
| 70 | + <_IsHelix Condition="'$(IsHelix)' == ''">false</_IsHelix> |
| 71 | + <_IsHelix Condition="'$(IsHelix)' != ''">$(IsHelix)</_IsHelix> |
| 72 | + </PropertyGroup> |
| 73 | + <ItemGroup> |
| 74 | + <_Runner Include=" - GitHub Actions: $(_IsGitHubActionsRunner)" /> |
| 75 | + <_Runner Include=" - Azure DevOps: $(_IsAzdoRunner)" /> |
| 76 | + <_Runner Include=" - Helix: $(_IsHelix)" /> |
| 77 | + <_Capability Include=" - GitHub Actions: $(RunsOnGithubActions) (Windows: $(RunsOnGithubActionsWindows) / Linux: $(RunsOnGithubActionsLinux))" /> |
| 78 | + <_Capability Include=" - Azure DevOps: $(RunsOnAzdo)" /> |
| 79 | + <_Capability Include=" - Helix: $(RunsOnHelix) (Windows: $(RunsOnHelixWindows) / Linux: $(RunsOnHelixLinux))" /> |
| 80 | + </ItemGroup> |
| 81 | + |
| 82 | + <PropertyGroup> |
| 83 | + <_NewLine>%0D%0A</_NewLine> |
| 84 | + <_RunnerList>@(_Runner, '%0D%0A')</_RunnerList> |
| 85 | + <_CapabilityList>@(_Capability, '$(_NewLine)')</_CapabilityList> |
| 86 | + </PropertyGroup> |
| 87 | + |
| 88 | + <Message Text="Project: $(MSBuildProjectName)$(_NewLine)Runner Context:$(_NewLine)$(_RunnerList)$(_NewLine)Capabilities:$(_NewLine)$(_CapabilityList)" /> |
| 89 | + </Target> |
| 90 | + |
3 | 91 | </Project>
|
0 commit comments