Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-cli-native-archives.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
matrix:
targets:
- os: ubuntu-latest
runner: ubuntu-latest
runner: 8-core-ubuntu-latest
rids: linux-x64
- os: windows-latest
runner: windows-latest
Expand Down
34 changes: 17 additions & 17 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,16 @@ jobs:
# from the repo always use restored dotnet. For tests run from outside
# the repo we install system dotnet earlier in the build

- name: Setup vars (Linux)
if: ${{ inputs.os == 'ubuntu-latest' || inputs.os == 'macos-latest' }}
- name: Setup vars (Linux/macOS)
if: ${{ runner.os != 'Windows' }}
run: |
echo "DOTNET_SCRIPT=./dotnet.sh" >> $GITHUB_ENV
echo "BUILD_SCRIPT=./build.sh" >> $GITHUB_ENV
echo "TEST_RUN_PATH=${{ github.workspace }}/run-tests" >> $GITHUB_ENV
echo ${{ github.workspace }}/.dotnet >> $GITHUB_PATH

- name: Setup vars (Windows)
if: ${{ inputs.os == 'windows-latest' }}
if: ${{ runner.os == 'Windows' }}
run: |
echo "DOTNET_SCRIPT=.\dotnet.cmd" >> $env:GITHUB_ENV
echo "BUILD_SCRIPT=.\build.cmd" >> $env:GITHUB_ENV
Expand All @@ -112,7 +112,7 @@ jobs:
DOTNET_INSTALL_DIR: ${{ env.DOTNET_ROOT }}

- name: Trust HTTPS development certificate (Linux)
if: inputs.os == 'ubuntu-latest'
if: runner.os == 'Linux'
# Allow the task to succeed on partial trust.
# Remove this workaround once https://github.com/dotnet/aspnetcore/pull/65392 has shipped
run: |
Expand All @@ -127,7 +127,7 @@ jobs:

- name: Verify Docker is running
# nested docker containers not supported on windows
if: inputs.os == 'ubuntu-latest'
if: runner.os == 'Linux'
run: docker info

- name: Download built nugets
Expand All @@ -148,12 +148,12 @@ jobs:
id: compute_rid
shell: pwsh
run: |
$os = "${{ inputs.os }}"
switch ($os) {
'ubuntu-latest' { $rid = 'linux-x64' }
'macos-latest' { $rid = 'osx-arm64' }
'windows-latest'{ $rid = 'win-x64' }
Default { Write-Error "Unknown OS '$os' for RID mapping"; exit 1 }
$runnerOs = "${{ runner.os }}"
switch ($runnerOs) {
'Linux' { $rid = 'linux-x64' }
'macOS' { $rid = 'osx-arm64' }
'Windows' { $rid = 'win-x64' }
Default { Write-Error "Unknown runner.os '$runnerOs' for RID mapping"; exit 1 }
}
Write-Host "Using RID=$rid"
"RID=$rid" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Expand Down Expand Up @@ -195,7 +195,7 @@ jobs:
/bl:${{ github.workspace }}/artifacts/log/Debug/InstallSdkForTesting.binlog

- name: Install Azure Functions Core Tools
if: inputs.os == 'ubuntu-latest' && (inputs.testShortName == 'Playground' || inputs.testShortName == 'Azure')
if: runner.os == 'Linux' && (inputs.testShortName == 'Playground' || inputs.testShortName == 'Azure')
run: |
npm i -g azure-functions-core-tools@4 --unsafe-perm true

Expand Down Expand Up @@ -292,7 +292,7 @@ jobs:
uses: ./.github/actions/unlock-macos-keychain

- name: Run nuget dependent tests (Linux/macOS)
if: ${{ inputs.requiresNugets && (inputs.os == 'ubuntu-latest' || inputs.os == 'macos-latest') }}
if: ${{ inputs.requiresNugets && runner.os != 'Windows' }}
working-directory: ${{ github.workspace }}/run-tests/
env:
ASPIRE__TEST__DCPLOGBASEPATH: ${{ github.workspace }}/testresults/dcp
Expand Down Expand Up @@ -333,7 +333,7 @@ jobs:
exit $TEST_EXIT_CODE

- name: Run nuget dependent tests (Windows)
if: ${{ inputs.requiresNugets && inputs.os == 'windows-latest' }}
if: ${{ inputs.requiresNugets && runner.os == 'Windows' }}
working-directory: ${{ github.workspace }}/run-tests/
shell: pwsh
env:
Expand Down Expand Up @@ -378,7 +378,7 @@ jobs:
}

- name: Run tests (Linux/macOS)
if: ${{ ! inputs.requiresNugets && (inputs.os == 'ubuntu-latest' || inputs.os == 'macos-latest') }}
if: ${{ ! inputs.requiresNugets && runner.os != 'Windows' }}
id: run-tests-unix
env:
ASPIRE__TEST__DCPLOGBASEPATH: ${{ github.workspace }}/testresults/dcp
Expand Down Expand Up @@ -422,7 +422,7 @@ jobs:
exit $TEST_EXIT_CODE

- name: Run tests (Windows)
if: ${{ ! inputs.requiresNugets && inputs.os == 'windows-latest' }}
if: ${{ ! inputs.requiresNugets && runner.os == 'Windows' }}
id: run-tests-windows
shell: pwsh
env:
Expand Down Expand Up @@ -517,7 +517,7 @@ jobs:
Write-Host "✓ Test execution completed successfully (found $validFileCount valid .trx file(s))"

- name: Dump docker info
if: ${{ always() && inputs.os == 'ubuntu-latest' }}
if: ${{ always() && runner.os == 'Linux' }}
run: |
docker container ls --all
docker container ls --all --format json
Expand Down
23 changes: 22 additions & 1 deletion docs/ci/TestingOnCI.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ This invokes `eng/TestEnumerationRunsheetBuilder/TestEnumerationRunsheetBuilder.
- `testSessionTimeout`, `testHangTimeout` values
- `uncollectedTestsSessionTimeout`, `uncollectedTestsHangTimeout` values
- `splitTests` flag
- `runners` object (optional, only present when custom runners are configured)

### Phase 2: Test Partition Discovery

Expand Down Expand Up @@ -108,7 +109,8 @@ After all projects build, `eng/AfterSolutionBuild.targets` runs `eng/scripts/bui
"supportedOSes": ["linux"],
"requiresNugets": false,
"testSessionTimeout": "30m",
"extraTestArgs": "--filter-trait \"Partition=Docker\""
"extraTestArgs": "--filter-trait \"Partition=Docker\"",
"runners": { "macos": "macos-latest-xlarge" }
}
]
}
Expand Down Expand Up @@ -247,6 +249,25 @@ For tests that require Playwright browser automation:

This flag is tracked in the test metadata and controls whether Playwright browsers are installed during the test build step.

## Custom GitHub Actions Runners

By default, tests run on `ubuntu-latest`, `windows-latest`, and `macos-latest`. To override the runner for a specific OS (e.g., to use larger runners or specific OS versions), set the corresponding property in the test project's `.csproj`:

```xml
<PropertyGroup>
<!-- Use a larger macOS runner for this test project -->
<GithubActionsRunnerMacOS>macos-latest-xlarge</GithubActionsRunnerMacOS>

<!-- Use a specific Ubuntu version -->
<GithubActionsRunnerLinux>ubuntu-24.04</GithubActionsRunnerLinux>

<!-- Use a specific Windows version -->
<GithubActionsRunnerWindows>windows-2022</GithubActionsRunnerWindows>
</PropertyGroup>
```

Only set the properties you need to override — unset properties use the default runners. The overrides are emitted as a `runners` object in the test metadata JSON and flow through the canonical matrix to the GitHub Actions expansion, where they replace the default `runs-on` value for the corresponding OS.

## Deployment Tests

Deployment end-to-end tests have a separate flow from the standard test matrix:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@
<_UncollectedTestsHangTimeout Condition="'$(UncollectedTestsHangTimeout)' != ''">$(UncollectedTestsHangTimeout)</_UncollectedTestsHangTimeout>
<_UncollectedTestsHangTimeout Condition="'$(UncollectedTestsHangTimeout)' == ''">10m</_UncollectedTestsHangTimeout>

<!-- Build custom runners JSON (only include keys that are explicitly set) -->
<_RunnersJsonParts />
<_RunnersJsonParts Condition="'$(GithubActionsRunnerWindows)' != ''">$(_RunnersJsonParts)"windows": "$(GithubActionsRunnerWindows)",</_RunnersJsonParts>
<_RunnersJsonParts Condition="'$(GithubActionsRunnerLinux)' != ''">$(_RunnersJsonParts)"linux": "$(GithubActionsRunnerLinux)",</_RunnersJsonParts>
<_RunnersJsonParts Condition="'$(GithubActionsRunnerMacOS)' != ''">$(_RunnersJsonParts)"macos": "$(GithubActionsRunnerMacOS)",</_RunnersJsonParts>
<_RunnersJsonParts Condition="'$(_RunnersJsonParts)' != ''">$(_RunnersJsonParts.TrimEnd(','))</_RunnersJsonParts>
<_RunnersJsonLine Condition="'$(_RunnersJsonParts)' != ''">,
"runners": {$(_RunnersJsonParts)}</_RunnersJsonLine>

<!-- Build metadata JSON -->
<_MetadataJson>{
"projectName": "$(MSBuildProjectName)",
Expand All @@ -103,7 +112,7 @@
"testSessionTimeout": "$(_TestSessionTimeout)",
"testHangTimeout": "$(_TestHangTimeout)",
"uncollectedTestsSessionTimeout": "$(_UncollectedTestsSessionTimeout)",
"uncollectedTestsHangTimeout": "$(_UncollectedTestsHangTimeout)"
"uncollectedTestsHangTimeout": "$(_UncollectedTestsHangTimeout)"$(_RunnersJsonLine)
}</_MetadataJson>

<!-- Use TestArchiveTestsDir if set (for Templates/EndToEnd tests), otherwise use default helix dir -->
Expand Down
5 changes: 5 additions & 0 deletions eng/Testing.targets
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
- RunOnAzdoHelix: indicates whether tests should run on Helix (either Windows or Linux); computed.
- RunOnAzdoHelixWindows: indicates whether tests should run on Windows in Helix; default is true; overridable.
- RunOnAzdoHelixLinux: indicates whether tests should run on Linux in Helix; default is true; overridable.

Custom GitHub Actions runners (optional):
- GithubActionsRunnerWindows: custom GitHub Actions runner for Windows tests; default is unset (uses 'windows-latest'); overridable.
- GithubActionsRunnerLinux: custom GitHub Actions runner for Linux tests; default is unset (uses 'ubuntu-latest'); overridable.
- GithubActionsRunnerMacOS: custom GitHub Actions runner for macOS tests; default is unset (uses 'macos-latest'); overridable.
-->

<PropertyGroup>
Expand Down
15 changes: 15 additions & 0 deletions eng/scripts/build-test-matrix.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ function New-RegularTestEntry {
# Add supported OSes
$entry['supportedOSes'] = @($Metadata.supportedOSes)

# Pass through custom runners if specified
if ($Metadata.PSObject.Properties['runners'] -and $Metadata.runners) {
$entry['runners'] = $Metadata.runners
}

return Complete-EntryWithDefaults $entry
}

Expand Down Expand Up @@ -174,6 +179,11 @@ function New-CollectionTestEntry {
$entry['supportedOSes'] = @($Metadata.supportedOSes)
}

# Pass through custom runners if specified
if ($Metadata.PSObject.Properties['runners'] -and $Metadata.runners) {
$entry['runners'] = $Metadata.runners
}

return Complete-EntryWithDefaults $entry
}

Expand Down Expand Up @@ -215,6 +225,11 @@ function New-ClassTestEntry {
$entry['supportedOSes'] = @($Metadata.supportedOSes)
}

# Pass through custom runners if specified
if ($Metadata.PSObject.Properties['runners'] -and $Metadata.runners) {
$entry['runners'] = $Metadata.runners
}

return Complete-EntryWithDefaults $entry
}

Expand Down
12 changes: 10 additions & 2 deletions eng/scripts/expand-test-matrix-github.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,16 @@ function Expand-MatrixEntriesByOS {
}
}

# Add GitHub-specific runner
$expandedEntry['runs-on'] = $runnerMap[$osLower]
# Add GitHub-specific runner (use custom runner if specified and non-empty, otherwise default)
$hasRunners = $entry.PSObject.Properties.Name -contains 'runners'
$customRunner = $null
if ($hasRunners -and $entry.runners) {
$runnerProp = $entry.runners.PSObject.Properties[$osLower]
if ($runnerProp -and -not [string]::IsNullOrWhiteSpace([string]$runnerProp.Value)) {
$customRunner = [string]$runnerProp.Value
}
}
$expandedEntry['runs-on'] = if ($customRunner) { $customRunner } else { $runnerMap[$osLower] }

$expandedEntries += [PSCustomObject]$expandedEntry
}
Expand Down
2 changes: 2 additions & 0 deletions tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<!-- Split tests into partitions for CI parallelization -->
<SplitTestsOnCI>true</SplitTestsOnCI>
<TestClassNamePrefixForCI>Aspire.Hosting.Tests</TestClassNamePrefixForCI>

<GithubActionsRunnerLinux>8-core-ubuntu-latest</GithubActionsRunnerLinux>
</PropertyGroup>

<ItemGroup>
Expand Down
Loading
Loading