Skip to content

Commit 1010a60

Browse files
Simplify workflow by combining WinUI 2/3 build defintions with a matrix
Only upload test results if either test step was completed (i.e. if build fails and tests don't run, don't try and upload test results that don't exist)
1 parent 6d883b6 commit 1010a60

File tree

1 file changed

+19
-82
lines changed

1 file changed

+19
-82
lines changed

.github/workflows/build.yml

Lines changed: 19 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -40,84 +40,16 @@ jobs:
4040
- name: Check XAML Styling
4141
run: powershell -version 5.1 -command "./ApplyXamlStyling.ps1 -Passive" -ErrorAction Stop
4242

43-
# This workflow contains a single job called "Build-WinUI-2"
44-
Build-WinUI-2:
43+
# Build both Uno.UI/WinUI2/UWP and Uno.WinUI/WinUI3/WindowsAppSDK versions of our packages using a matrix
44+
build:
4545
needs: [Xaml-Style-Check]
4646
runs-on: windows-latest
4747

48-
# Steps represent a sequence of tasks that will be executed as part of the job
49-
steps:
50-
- name: Install .NET 6 SDK
51-
uses: actions/setup-dotnet@v3
52-
with:
53-
dotnet-version: '6.0.202'
54-
55-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
56-
- name: Checkout Repository
57-
uses: actions/checkout@v3
58-
59-
# Restore Tools from Manifest list in the Repository
60-
- name: Restore dotnet tools
61-
run: dotnet tool restore
62-
63-
- name: Run Uno Check to Install Dependencies
64-
run: dotnet tool run uno-check --ci --fix --non-interactive --skip wsl --skip androidemulator --verbose
65-
66-
- name: Add msbuild to PATH
67-
uses: microsoft/[email protected]
68-
69-
- name: Enable all TargetFrameworks
70-
working-directory: ./common/Scripts/
71-
run: powershell -version 5.1 -command "./UseTargetFrameworks.ps1 all" -ErrorAction Stop
72-
73-
- name: Generate solution
74-
run: powershell -version 5.1 -command "./GenerateAllSolution.ps1" -ErrorAction Stop
75-
76-
- name: MSBuild
77-
# working-directory: ./
78-
run: msbuild.exe Toolkit.Labs.All.sln /restore -p:Configuration=Release
79-
80-
# Build All Packages
81-
- name: pack experiments
82-
working-directory: ./common/Scripts/
83-
run: ./PackEachExperiment.ps1 all
84-
85-
# Push Packages to our DevOps Artifacts Feed
86-
- name: Add source
87-
if: ${{github.ref == 'refs/heads/main'}}
88-
run: dotnet nuget add source "https://pkgs.dev.azure.com/dotnet/CommunityToolkit/_packaging/CommunityToolkit-Labs/nuget/v3/index.json" --name LabsFeed --username dummy --password ${{ secrets.DEVOPS_PACKAGE_PUSH_TOKEN }}
89-
90-
- name: Push packages
91-
if: ${{github.ref == 'refs/heads/main'}}
92-
run: dotnet nuget push "**/*.nupkg" --api-key dummy --source LabsFeed --skip-duplicate
93-
94-
# Run tests
95-
- name: Setup VSTest Path
96-
uses: darenm/Setup-VSTest@v1
97-
98-
- name: Install Testspace Module
99-
uses: testspace-com/setup-testspace@v1
100-
with:
101-
domain: ${{ github.repository_owner }}
102-
103-
- name: Run SourceGenerators tests
104-
run: vstest.console.exe ./common/CommunityToolkit.Labs.Core.SourceGenerators.Tests/CommunityToolkit.Labs.Core.SourceGenerators.Tests/bin/Release/net6.0/CommunityToolkit.Labs.Core.SourceGenerators.Tests.dll /logger:"trx;LogFileName=SourceGenerators.trx"
105-
106-
- name: Run experiment tests against UWP
107-
run: vstest.console.exe ./tests/**/CommunityToolkit.Labs.Tests.UWP.build.appxrecipe /Framework:FrameworkUap10 /logger:"trx;LogFileName=UWP.trx"
108-
109-
- name: Run experiment tests against WinAppSDK
110-
run: vstest.console.exe ./tests/**/CommunityToolkit.Labs.Tests.WinAppSdk.build.appxrecipe /Framework:FrameworkUap10 /logger:"trx;LogFileName=WinAppSdk.trx"
111-
112-
- name: Create test reports
113-
run: |
114-
testspace '[WinUI2]./TestResults/*.trx'
115-
if: always()
116-
117-
# This workflow contains a single job called "Build-WinUI-3"
118-
Build-WinUI-3:
119-
needs: [Xaml-Style-Check]
120-
runs-on: windows-latest
48+
# See https://docs.github.com/actions/using-jobs/using-a-matrix-for-your-jobs
49+
strategy:
50+
fail-fast: false # prevent one matrix pipeline from being cancelled if one fails, we want them both to run to completion.
51+
matrix:
52+
platform: [WinUI2, WinUI3]
12153

12254
# Steps represent a sequence of tasks that will be executed as part of the job
12355
steps:
@@ -147,12 +79,12 @@ jobs:
14779
- name: Generate solution
14880
run: powershell -version 5.1 -command "./GenerateAllSolution.ps1" -ErrorAction Stop
14981

150-
- name: Enable WinUI 3
82+
- name: Enable Uno.WinUI (in WinUI3 matrix only)
15183
working-directory: ./common/Scripts/
15284
run: powershell -version 5.1 -command "./UseUnoWinUI.ps1 3" -ErrorAction Stop
85+
if: ${{ matrix.platform == 'WinUI3' }}
15386

15487
- name: MSBuild
155-
# working-directory: ./
15688
run: msbuild.exe Toolkit.Labs.All.sln /restore /nowarn:MSB4011 -p:Configuration=Release
15789

15890
# Build All Packages
@@ -179,21 +111,24 @@ jobs:
179111
domain: ${{ github.repository_owner }}
180112

181113
- name: Run SourceGenerators tests
114+
id: test-generator
182115
run: vstest.console.exe ./common/CommunityToolkit.Labs.Core.SourceGenerators.Tests/CommunityToolkit.Labs.Core.SourceGenerators.Tests/bin/Release/net6.0/CommunityToolkit.Labs.Core.SourceGenerators.Tests.dll /logger:"trx;LogFileName=SourceGenerators.trx"
183116

184117
- name: Run experiment tests against UWP
118+
id: test-uwp
185119
run: vstest.console.exe ./tests/**/CommunityToolkit.Labs.Tests.UWP.build.appxrecipe /Framework:FrameworkUap10 /logger:"trx;LogFileName=UWP.trx"
186120

187121
- name: Run experiment tests against WinAppSDK
122+
id: test-winappsdk
188123
run: vstest.console.exe ./tests/**/CommunityToolkit.Labs.Tests.WinAppSdk.build.appxrecipe /Framework:FrameworkUap10 /logger:"trx;LogFileName=WinAppSdk.trx"
189124

190125
- name: Create test reports
191126
run: |
192-
testspace '[WinUI3]./TestResults/*.trx'
193-
if: always()
127+
testspace '[${{ matrix.platform }}]./TestResults/*.trx'
128+
if: ${{ always() && (steps.test-generator.status == 'completed' || steps.test-uwp.status == 'completed' || steps.test-winappsdk.status == 'completed') }}
194129

195-
# Test/temp job to build a single experiment to ensure our changes work for both our main types of solutions at the moment
196-
experiment:
130+
# Test job to build a single experiment to ensure our changes work for both our main types of solutions at the moment
131+
new-experiment:
197132
needs: [Xaml-Style-Check]
198133
runs-on: windows-latest
199134

@@ -238,15 +173,17 @@ jobs:
238173
domain: ${{ github.repository_owner }}
239174

240175
- name: Run tests in the generated experiment against UWP
176+
id: test-uwp
241177
run: vstest.console.exe ./labs/CiTestExp/**/CiTestExp.Tests.UWP.build.appxrecipe /Framework:FrameworkUap10 /logger:"trx;LogFileName=CiTestExpUWP.trx"
242178

243179
- name: Run tests in the generated experiment against WinAppSDK
180+
id: test-winappsdk
244181
run: vstest.console.exe ./labs/CiTestExp/**/CiTestExp.Tests.WinAppSdk.build.appxrecipe /Framework:FrameworkUap10 /logger:"trx;LogFileName=CiTestExpWinAppSdk.trx"
245182

246183
- name: Create test reports
247184
run: |
248185
testspace '[New Experiment]./TestResults/*.trx'
249-
if: always()
186+
if: ${{ always() && (steps.test-uwp.status == 'completed' || steps.test-winappsdk.status == 'completed') }}
250187

251188
wasm-linux:
252189
needs: [Xaml-Style-Check]

0 commit comments

Comments
 (0)