Skip to content

Commit 6ca2de9

Browse files
authored
[CI] Add PR validation on macOS (#9287)
1 parent 2291fb9 commit 6ca2de9

File tree

17 files changed

+102
-18
lines changed

17 files changed

+102
-18
lines changed

.github/actions/enumerate-tests/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ runs:
6969
"integrations_tests_matrix=$jsonString"
7070
"integrations_tests_matrix=$jsonString" | Out-File -FilePath $env:GITHUB_OUTPUT
7171
72-
- name: Generate tests matrix
72+
- name: Generate templates matrix
7373
id: generate_templates_matrix
7474
if: ${{ inputs.includeTemplates }}
7575
shell: pwsh

.github/workflows/run-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
}
6060
6161
- name: Setup vars (Linux)
62-
if: ${{ inputs.os == 'ubuntu-latest' }}
62+
if: ${{ inputs.os == 'ubuntu-latest' || inputs.os == 'macos-latest' }}
6363
run: |
6464
echo "DOTNET_SCRIPT=./dotnet.sh" >> $GITHUB_ENV
6565
echo "BUILD_SCRIPT=./build.sh" >> $GITHUB_ENV
@@ -277,7 +277,7 @@ jobs:
277277
path: result-*.rst
278278

279279
- name: Dump docker info
280-
if: always()
280+
if: ${{ always() && inputs.os == 'ubuntu-latest' }}
281281
run: |
282282
docker container ls --all
283283
docker container ls --all --format json

.github/workflows/tests-outerloop.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ jobs:
103103
$OS = "ubuntu"
104104
} elseif ($trxFile.FullName -match "windows") {
105105
$OS = "windows"
106+
} elseif ($trxFile.FullName -match "macos") {
107+
$OS = "macos"
106108
} else {
107109
$OS = "unknown"
108110
}

.github/workflows/tests.yml

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,22 @@ jobs:
3636
includeIntegrations: true
3737
includeTemplates: true
3838

39+
setup_for_tests_macos:
40+
name: Setup for tests (macOS)
41+
if: ${{ github.repository_owner == 'dotnet' }}
42+
runs-on: macos-latest
43+
outputs:
44+
integrations_tests_matrix: ${{ steps.generate_tests_matrix.outputs.integrations_tests_matrix }}
45+
templates_tests_matrix: ${{ steps.generate_tests_matrix.outputs.templates_tests_matrix }}
46+
steps:
47+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
48+
49+
- uses: ./.github/actions/enumerate-tests
50+
id: generate_tests_matrix
51+
with:
52+
includeIntegrations: true
53+
includeTemplates: true
54+
3955
setup_for_tests_win:
4056
name: Setup for tests (Windows)
4157
if: ${{ github.repository_owner == 'dotnet' }}
@@ -84,6 +100,19 @@ jobs:
84100
os: "ubuntu-latest"
85101
extraTestArgs: "--filter-not-trait \"quarantined=true\""
86102

103+
integrations_test_macos:
104+
uses: ./.github/workflows/run-tests.yml
105+
name: Integrations macos
106+
needs: setup_for_tests_macos
107+
strategy:
108+
fail-fast: false
109+
matrix:
110+
${{ fromJson(needs.setup_for_tests_macos.outputs.integrations_tests_matrix) }}
111+
with:
112+
testShortName: ${{ matrix.shortname }}
113+
os: "macos-latest"
114+
extraTestArgs: "--filter-not-trait \"quarantined=true\""
115+
87116
integrations_test_win:
88117
uses: ./.github/workflows/run-tests.yml
89118
name: Integrations Windows
@@ -114,6 +143,23 @@ jobs:
114143
requiresNugets: true
115144
requiresTestSdk: true
116145

146+
templates_test_macos:
147+
name: Templates macos
148+
uses: ./.github/workflows/run-tests.yml
149+
needs: [setup_for_tests_macos, build_packages]
150+
strategy:
151+
fail-fast: false
152+
matrix: ${{ fromJson(needs.setup_for_tests_macos.outputs.templates_tests_matrix) }}
153+
with:
154+
testShortName: ${{ matrix.shortname }}
155+
os: "macos-latest"
156+
testProjectPath: tests/Aspire.Templates.Tests/Aspire.Templates.Tests.csproj
157+
testSessionTimeout: 20m
158+
testHangTimeout: 12m
159+
extraTestArgs: "--filter-not-trait quarantined=true --filter-class Aspire.Templates.Tests.${{ matrix.shortname }}"
160+
requiresNugets: true
161+
requiresTestSdk: true
162+
117163
templates_test_win:
118164
name: Templates Windows
119165
uses: ./.github/workflows/run-tests.yml
@@ -137,7 +183,7 @@ jobs:
137183
needs: build_packages
138184
with:
139185
testShortName: EndToEnd
140-
# EndToEnd is not run on Windows due to missing Docker support
186+
# EndToEnd is not run on Windows/macOS due to missing Docker support
141187
os: ubuntu-latest
142188
testProjectPath: tests/Aspire.EndToEnd.Tests/Aspire.EndToEnd.Tests.csproj
143189
requiresNugets: true
@@ -146,7 +192,7 @@ jobs:
146192
if: ${{ always() && github.repository_owner == 'dotnet' }}
147193
runs-on: ubuntu-latest
148194
name: Final Results
149-
needs: [ integrations_test_lin, integrations_test_win, templates_test_lin, templates_test_win, endtoend_tests ]
195+
needs: [ integrations_test_lin, integrations_test_win, integrations_test_macos, templates_test_lin, templates_test_win, templates_test_macos, endtoend_tests ]
150196
steps:
151197
- name: Checkout code
152198
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -170,6 +216,12 @@ jobs:
170216
merge-multiple: true
171217
path: ${{ github.workspace }}/testresults/windows-latest
172218

219+
- uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
220+
with:
221+
pattern: logs-*-macos-latest
222+
merge-multiple: true
223+
path: testresults/macos-latest
224+
173225
- name: Upload test results
174226
if: always()
175227
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1

eng/QuarantinedTestRunsheetBuilder/QuarantinedTestRunsheetBuilder.targets

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131

132132
<_TestRunnerWindows>./eng/build.ps1</_TestRunnerWindows>
133133
<_TestRunnerLinux>./eng/build.sh</_TestRunnerLinux>
134+
<_TestRunnerMacOS>./eng/build.sh</_TestRunnerMacOS>
134135
<_TestCommand>-restore -build -test -projects &quot;$(_RelativeTestProjectPath)&quot; /bl:&quot;$(_RelativeTestBinLog)&quot; -c $(Configuration) -ci /p:RunQuarantinedTests=true /p:CI=false</_TestCommand>
135136

136137
<!--
@@ -144,6 +145,7 @@
144145

145146
<_TestRunsheetWindows>{ "label": "w: $(_TestRunsheet)", "project": "$(_TestRunsheet)", "os": "windows-latest", "command": "./eng/build.ps1 $(_TestCommand)" }</_TestRunsheetWindows>
146147
<_TestRunsheetLinux>{ "label": "l: $(_TestRunsheet)", "project": "$(_TestRunsheet)", "os": "ubuntu-latest", "command": "./eng/build.sh $(_TestCommand)" }</_TestRunsheetLinux>
148+
<_TestRunsheetMacOS>{ "label": "m: $(_TestRunsheet)", "project": "$(_TestRunsheet)", "os": "macos-latest", "command": "./eng/build.sh $(_TestCommand)" }</_TestRunsheetMacOS>
147149
</PropertyGroup>
148150

149151
<WriteLinesToFile
@@ -152,13 +154,18 @@
152154
Lines="$(_TestRunsheetWindows)"
153155
Overwrite="true"
154156
WriteOnlyWhenDifferent="true" />
155-
156157
<WriteLinesToFile
157158
Condition=" '$(RunOnGithubActionsLinux)' == 'true' and '$(_HasQuarantinedTests)' == 'true' "
158159
File="$(ArtifactsTmpDir)/$(_TestRunsheet).linux.runsheet.json"
159160
Lines="$(_TestRunsheetLinux)"
160161
Overwrite="true"
161162
WriteOnlyWhenDifferent="true" />
163+
<WriteLinesToFile
164+
Condition=" '$(RunOnGithubActionsMacOS)' == 'true' and '$(_HasQuarantinedTests)' == 'true' "
165+
File="$(ArtifactsTmpDir)/$(_TestRunsheet).macos.runsheet.json"
166+
Lines="$(_TestRunsheetMacOS)"
167+
Overwrite="true"
168+
WriteOnlyWhenDifferent="true" />
162169

163170
<!--
164171
On Linux there's a bug in MSBuild, which "normalises" all slashes (see https://github.com/dotnet/msbuild/issues/3468).
@@ -168,6 +175,8 @@
168175
Condition=" '$(RunOnGithubActionsWindows)' == 'true' and '$(_HasQuarantinedTests)' == 'true' and '$(BuildOs)' != 'windows' " />
169176
<Exec Command="pwsh -Command &quot;(Get-Content -Path '$(ArtifactsTmpDir)/$(_TestRunsheet).linux.runsheet.json') -replace '/\&quot;', '\\\&quot;' | Set-Content -Path '$(ArtifactsTmpDir)/$(_TestRunsheet).linux.runsheet.json'&quot; "
170177
Condition=" '$(RunOnGithubActionsLinux)' == 'true' and '$(_HasQuarantinedTests)' == 'true' and '$(BuildOs)' != 'windows' " />
178+
<Exec Command="pwsh -Command &quot;(Get-Content -Path '$(ArtifactsTmpDir)/$(_TestRunsheet).macos.runsheet.json') -replace '/\&quot;', '\\\&quot;' | Set-Content -Path '$(ArtifactsTmpDir)/$(_TestRunsheet).macos.runsheet.json'&quot; "
179+
Condition=" '$(RunOnGithubActionsMacOS)' == 'true' and '$(_HasQuarantinedTests)' == 'true' and '$(BuildOs)' != 'windows' " />
171180

172181
<!--
173182
The final piece of the puzzle is in eng/AfterSolutionBuild.targets, where we combine the runsheets from all the test projects into a single runsheet.

eng/TestRunsheetBuilder/TestRunsheetBuilder.targets

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
<_TestRunsheet>$([System.String]::Copy('$(MSBuildProjectName)').Replace('Aspire.', ''))</_TestRunsheet>
5454
<_TestRunsheetFileNameWindows>$(ArtifactsTmpDir)/$(_TestRunsheet).win.runsheet.json</_TestRunsheetFileNameWindows>
5555
<_TestRunsheetFileNameLinux>$(ArtifactsTmpDir)/$(_TestRunsheet).linux.runsheet.json</_TestRunsheetFileNameLinux>
56+
<_TestRunsheetFileNameMacOS>$(ArtifactsTmpDir)/$(_TestRunsheet).macos.runsheet.json</_TestRunsheetFileNameMacOS>
5657

5758
<_TestBinLog>$([MSBuild]::NormalizePath($(ArtifactsLogDir), '$(_TestRunsheet).binlog'))</_TestBinLog>
5859

@@ -61,6 +62,7 @@
6162

6263
<_TestRunnerWindows>./eng/build.ps1</_TestRunnerWindows>
6364
<_TestRunnerLinux>./eng/build.sh</_TestRunnerLinux>
65+
<_TestRunnerMacOS>./eng/build.sh</_TestRunnerMacOS>
6466
<_TestCommand>-restore -build -test -projects &quot;$(_RelativeTestProjectPath)&quot; /bl:&quot;$(_RelativeTestBinLog)&quot; -c $(Configuration) -ci</_TestCommand>
6567

6668
<!-- Tests requiring packages must be run in the "out of repo" mode -->
@@ -72,11 +74,13 @@
7274

7375
<_TestRunsheetWindows>{ "label": "w: $(_TestRunsheet)", "project": "$(_TestRunsheet)", "os": "windows-latest", "command": "./eng/build.ps1 $(_TestCommand)" }</_TestRunsheetWindows>
7476
<_TestRunsheetLinux>{ "label": "l: $(_TestRunsheet)", "project": "$(_TestRunsheet)", "os": "ubuntu-latest", "command": "$(_PreCommand)./eng/build.sh $(_TestCommand)" }</_TestRunsheetLinux>
77+
<_TestRunsheetMacOS>{ "label": "m: $(_TestRunsheet)", "project": "$(_TestRunsheet)", "os": "macos-latest", "command": "$(_PreCommand)./eng/build.sh $(_TestCommand)" }</_TestRunsheetMacOS>
7578
</PropertyGroup>
7679

7780
<ItemGroup>
7881
<_OutputFiles Include="$(_TestRunsheetFileNameWindows)" />
7982
<_OutputFiles Include="$(_TestRunsheetFileNameLinux)" />
83+
<_OutputFiles Include="$(_TestRunsheetFileNameMacOS)" />
8084
</ItemGroup>
8185

8286
<MakeDir Directories="@(_OutputFiles->'%(RootDir)%(Directory)')"/>
@@ -94,6 +98,12 @@
9498
Lines="$(_TestRunsheetLinux)"
9599
Overwrite="true"
96100
WriteOnlyWhenDifferent="true" />
101+
<WriteLinesToFile
102+
Condition=" '$(RunOnGithubActionsMacOS)' == 'true' and '$(_CreateRunsheet)' == 'true' "
103+
File="$(_TestRunsheetFileNameMacOS)"
104+
Lines="$(_TestRunsheetMacOS)"
105+
Overwrite="true"
106+
WriteOnlyWhenDifferent="true" />
97107

98108
<!--
99109
On Linux there's a bug in MSBuild, which "normalises" all slashes (see https://github.com/dotnet/msbuild/issues/3468).
@@ -103,6 +113,8 @@
103113
Condition=" Exists('$(_TestRunsheetFileNameWindows)') and '$(BuildOs)' != 'windows' " />
104114
<Exec Command="pwsh -Command &quot;(Get-Content -Path '$(_TestRunsheetFileNameLinux)') -replace '/\&quot;', '\\\&quot;' | Set-Content -Path '$(_TestRunsheetFileNameLinux)'&quot; "
105115
Condition=" Exists('$(_TestRunsheetFileNameLinux)') and '$(BuildOs)' != 'windows' " />
116+
<Exec Command="pwsh -Command &quot;(Get-Content -Path '$(_TestRunsheetFileNameMacOS)') -replace '/\&quot;', '\\\&quot;' | Set-Content -Path '$(_TestRunsheetFileNameMacOS)'&quot; "
117+
Condition=" Exists('$(_TestRunsheetFileNameMacOS)') and '$(BuildOs)' != 'windows' " />
106118

107119
<!--
108120
The final piece of the puzzle is in eng/AfterSolutionBuild.targets, where we combine the runsheets from all the test projects into a single runsheet.

eng/Testing.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<!-- By default any test can run on all test platforms -->
66
<RunOnGithubActionsWindows>true</RunOnGithubActionsWindows>
77
<RunOnGithubActionsLinux>true</RunOnGithubActionsLinux>
8+
<RunOnGithubActionsMacOS>true</RunOnGithubActionsMacOS>
89
<RunOnAzdoCIWindows>true</RunOnAzdoCIWindows>
910
<RunOnAzdoCILinux>true</RunOnAzdoCILinux>
1011
<RunOnAzdoHelixWindows>true</RunOnAzdoHelixWindows>

eng/Testing.targets

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
- IncludeTestUtilities: indicates whether the test project must not include the TestUtilities project reference; default is false; overridable.
1212
1313
Project requirements:
14-
- RunOnGithubActions: indicates whether tests should run on GitHub Actions (either Windows or Linux); computed.
14+
- RunOnGithubActions: indicates whether tests should run on GitHub Actions (either Windows or Linux or macOS); computed.
1515
- RunOnGithubActionsWindows: indicates whether tests should run on Windows in GitHub Actions; default is true; overridable.
16+
- RunOnGithubActionsMacOS: indicates whether tests should run on MacOS in GitHub Actions; default is true; overridable.
1617
- RunOnGithubActionsLinux: indicates whether tests should run on Linux in GitHub Actions; default is true; overridable.
1718
- RunOnAzdoCI: indicates whether tests should run on Azure DevOps (either Windows or Linux); always false, if RunOnAzdoHelix=true; computed.
1819
- RunOnAzdoCIWindows: indicates whether tests should run on Windows in Azure DevOps; default is true; overridable.
@@ -42,7 +43,7 @@
4243

4344
<PropertyGroup>
4445
<RunOnGithubActions>false</RunOnGithubActions>
45-
<RunOnGithubActions Condition=" '$(RunOnGithubActionsWindows)' == 'true' or '$(RunOnGithubActionsLinux)' == 'true' ">true</RunOnGithubActions>
46+
<RunOnGithubActions Condition=" '$(RunOnGithubActionsWindows)' == 'true' or '$(RunOnGithubActionsLinux)' == 'true' or '$(RunOnGithubActionsMacOS)' == 'true' ">true</RunOnGithubActions>
4647

4748
<RunOnAzdoHelix>false</RunOnAzdoHelix>
4849
<RunOnAzdoHelix Condition=" '$(RunOnAzdoHelixWindows)' == 'true' or '$(RunOnAzdoHelixLinux)' == 'true' ">true</RunOnAzdoHelix>
@@ -90,7 +91,7 @@
9091
<_Runner Include=" - GitHub Actions: $(_IsGitHubActionsRunner)" />
9192
<_Runner Include=" - Azure DevOps: $(_IsAzdoCIRunner)" />
9293
<_Runner Include=" - Helix: $(_IsAzdoHelixRunner)" />
93-
<_Requirement Include=" - GitHub Actions: $(RunOnGithubActions) (Windows: $(RunOnGithubActionsWindows) / Linux: $(RunOnGithubActionsLinux))" />
94+
<_Requirement Include=" - GitHub Actions: $(RunOnGithubActions) (Windows: $(RunOnGithubActionsWindows) / Linux: $(RunOnGithubActionsLinux) / MacOS: $(RunOnGithubActionsMacOS))" />
9495
<_Requirement Include=" - Azure DevOps: $(RunOnAzdoCI) (Windows: $(RunOnAzdoCIWindows) / Linux: $(RunOnAzdoCILinux))" />
9596
<_Requirement Include=" - Helix: $(RunOnAzdoHelix) (Windows: $(RunOnAzdoHelixWindows) / Linux: $(RunOnAzdoHelixLinux))" />
9697
</ItemGroup>

tests/Aspire.Dashboard.Tests/FormatHelpersTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Globalization;
55
using Aspire.Dashboard.Model;
66
using Aspire.Dashboard.Utils;
7+
using Aspire.TestUtilities;
78
using Microsoft.Extensions.Logging.Abstractions;
89
using Xunit;
910

@@ -75,6 +76,7 @@ public void FormatDateTime_WithMilliseconds_FinnishCulture(string expected, Mill
7576
[InlineData("15/06/2009 1:45:30.1234567 pm", MillisecondsDisplay.Full, "2009-06-15T13:45:30.1234567Z")]
7677
[InlineData("15/06/2009 1:45:30 pm", MillisecondsDisplay.None, "2009-06-15T13:45:30.0000000Z")]
7778
[InlineData("15/06/2009 1:45:30 pm", MillisecondsDisplay.None, "2009-06-15T13:45:30.1234567Z")]
79+
[ActiveIssue("https://github.com/dotnet/aspire/issues/9151", typeof(PlatformDetection), nameof(PlatformDetection.IsMacOS))]
7880
public void FormatDateTime_WithMilliseconds_NewZealandCulture(string expected, MillisecondsDisplay includeMilliseconds, string value)
7981
{
8082
var date = GetLocalDateTime(value);

tests/Aspire.Dashboard.Tests/Integration/Playwright/AppBarTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ await AsyncTestHelpers.AssertIsTrueRetryAsync(
6565
}
6666

6767
[Fact]
68-
[QuarantinedTest("https://github.com/dotnet/aspire/issues/9152")]
68+
[ActiveIssue("https://github.com/dotnet/aspire/issues/9152", typeof(PlatformDetection), nameof(PlatformDetection.IsMacOS))]
6969
public async Task AppBar_Change_Theme_ReloadPage()
7070
{
7171
// Arrange

0 commit comments

Comments
 (0)