Skip to content

Commit 4d9c244

Browse files
Adds the WinUI 2/3 Build script from the main repository as an additional job to test changes to tooling against our main code-base
1 parent f841534 commit 4d9c244

File tree

1 file changed

+117
-3
lines changed

1 file changed

+117
-3
lines changed

.github/workflows/build.yml

+117-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ env:
2020
ENABLE_DIAGNOSTICS: false
2121
#COREHOST_TRACE: 1
2222
COREHOST_TRACEFILE: corehosttrace.log
23+
MULTI_TARGET_DIRECTORY: tooling/MultiTarget
24+
HEADS_DIRECTORY: tooling/ProjectHeads
2325

2426
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
2527
jobs:
@@ -91,7 +93,6 @@ jobs:
9193
project-template:
9294
runs-on: windows-latest
9395
env:
94-
HEADS_DIRECTORY: tooling/ProjectHeads
9596
PROJECT_DIRECTORY: tooling/ProjectTemplate
9697

9798
steps:
@@ -141,7 +142,6 @@ jobs:
141142
new-experiment:
142143
runs-on: windows-latest
143144
env:
144-
HEADS_DIRECTORY: tooling/ProjectHeads
145145
PROJECT_DIRECTORY: tooling/ProjectTemplate
146146
TEST_PROJECT_NAME: CiTestExp
147147
TEST_PROJECT_DIRECTORY: components/CiTestExp
@@ -238,7 +238,6 @@ jobs:
238238
wasm-linux:
239239
runs-on: ubuntu-latest
240240
env:
241-
HEADS_DIRECTORY: tooling/ProjectHeads
242241
TEST_PROJECT_NAME: CiTestExp
243242

244243
steps:
@@ -299,3 +298,118 @@ jobs:
299298
with:
300299
name: linux-logs
301300
path: ./**/*.*log
301+
302+
# Modified copy from build step at https://github.com/CommunityToolkit/Windows/blob/main/.github/workflows/build.yml#L52-L152
303+
main-repo:
304+
runs-on: windows-latest
305+
306+
# See https://docs.github.com/actions/using-jobs/using-a-matrix-for-your-jobs
307+
strategy:
308+
fail-fast: false # prevent one matrix pipeline from being cancelled if one fails, we want them both to run to completion.
309+
matrix:
310+
platform: [WinUI2, WinUI3]
311+
312+
env:
313+
# faux-ternary expression to select which platforms to build for each platform vs. duplicating step below.
314+
TARGET_PLATFORMS: ${{ matrix.platform != 'WinUI3' && 'all' || 'all-uwp' }}
315+
TEST_PLATFORM: ${{ matrix.platform != 'WinUI3' && 'UWP' || 'WinAppSdk' }}
316+
317+
# Steps represent a sequence of tasks that will be executed as part of the job
318+
steps:
319+
- name: Install .NET SDK v${{ env.DOTNET_VERSION }}
320+
uses: actions/setup-dotnet@v3
321+
with:
322+
dotnet-version: ${{ env.DOTNET_VERSION }}
323+
324+
- name: .NET Info (if diagnostics)
325+
if: ${{ env.ENABLE_DIAGNOSTICS == 'true' }}
326+
run: dotnet --info
327+
328+
# Modified - Check out the main repo's repository first
329+
- name: Checkout Main Repository
330+
uses: actions/checkout@v3
331+
with:
332+
repository: CommunityToolkit/Windows
333+
ref: main
334+
335+
# Checks-out Current tooling changes as the submodule
336+
- name: Checkout Tooling Repository
337+
uses: actions/checkout@v3
338+
with:
339+
path: tooling
340+
clean: false
341+
342+
# TODO: Everything below these two checkout steps are the same, can we next in a yml for a composited build?
343+
# Restore Tools from Manifest list in the Repository
344+
- name: Restore dotnet tools
345+
run: dotnet tool restore
346+
347+
- name: Run Uno Check to Install Dependencies
348+
run: dotnet tool run uno-check --ci --fix --non-interactive --skip wsl --skip androidemulator --verbose
349+
350+
- name: Add msbuild to PATH
351+
uses: microsoft/setup-msbuild@v1.3.1
352+
353+
- name: Enable ${{ env.TARGET_PLATFORMS }} TargetFrameworks
354+
working-directory: ./${{ env.MULTI_TARGET_DIRECTORY }}
355+
run: powershell -version 5.1 -command "./UseTargetFrameworks.ps1 ${{ env.TARGET_PLATFORMS }}" -ErrorAction Stop
356+
357+
- name: Generate solution w/ ${{ env.TEST_PLATFORM }} Tests
358+
working-directory: ./
359+
run: powershell -version 5.1 -command "./tooling/GenerateAllSolution.ps1 -IncludeHeads ${{ env.TEST_PLATFORM }}${{ env.ENABLE_DIAGNOSTICS == 'true' && ' -UseDiagnostics' || '' }}" -ErrorAction Stop
360+
361+
- name: Enable Uno.WinUI (in WinUI3 matrix only)
362+
working-directory: ./${{ env.MULTI_TARGET_DIRECTORY }}
363+
run: powershell -version 5.1 -command "./UseUnoWinUI.ps1 3" -ErrorAction Stop
364+
if: ${{ matrix.platform == 'WinUI3' }}
365+
366+
- name: MSBuild
367+
run: msbuild.exe CommunityToolkit.AllComponents.sln /restore /nowarn:MSB4011 -p:Configuration=Release -m -p:UseDotNetNativeToolchain=false
368+
369+
# Build All Packages
370+
- name: pack experiments
371+
working-directory: ./tooling/Scripts/
372+
run: ./PackEachExperiment.ps1 all
373+
374+
# Push Packages to our DevOps Artifacts Feed (see nuget.config)
375+
- name: Add source
376+
if: ${{ github.ref == 'refs/heads/main' }}
377+
run: dotnet nuget update source MainLatest --username dummy --password ${{ secrets.DEVOPS_PACKAGE_PUSH_TOKEN }}
378+
379+
- name: Push packages
380+
if: ${{ github.ref == 'refs/heads/main' }}
381+
run: dotnet nuget push "**/*.nupkg" --api-key dummy --source MainLatest --skip-duplicate
382+
383+
# Run tests
384+
- name: Setup VSTest Path
385+
uses: darenm/Setup-VSTest@v1
386+
387+
- name: Install Testspace Module
388+
uses: testspace-com/setup-testspace@v1
389+
with:
390+
domain: ${{ github.repository_owner }}
391+
392+
- name: Run SourceGenerators tests
393+
id: test-generator
394+
run: vstest.console.exe ./tooling/CommunityToolkit.Tooling.SampleGen.Tests/bin/Release/net6.0/CommunityToolkit.Tooling.SampleGen.Tests.dll /logger:"trx;LogFileName=SourceGenerators.trx"
395+
396+
- name: Run experiment tests against ${{ env.TEST_PLATFORM }}
397+
id: test-platform
398+
run: vstest.console.exe ./tooling/**/CommunityToolkit.Tests.${{ env.TEST_PLATFORM }}.build.appxrecipe /Framework:FrameworkUap10 /logger:"trx;LogFileName=${{ env.TEST_PLATFORM }}.trx"
399+
400+
- name: Create test reports
401+
run: |
402+
testspace '[${{ matrix.platform }}]./TestResults/*.trx'
403+
if: ${{ always() && (steps.test-generator.conclusion == 'success' || steps.test-platform.conclusion == 'success') }}
404+
405+
- name: Artifact - Diagnostic Logs
406+
uses: actions/upload-artifact@v3
407+
if: ${{ (env.ENABLE_DIAGNOSTICS == 'true' || env.COREHOST_TRACE != '') && always() }}
408+
with:
409+
name: build-logs
410+
path: ./**/*.*log
411+
412+
- name: Windows System Error Log
413+
shell: pwsh
414+
working-directory: ./
415+
run: Get-EventLog -LogName System -EntryType Error | Format-List

0 commit comments

Comments
 (0)