Update build.yml to test including process dumps #431
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://docs.github.com/actions/using-workflows/about-workflows | |
# https://docs.github.com/actions/using-workflows/workflow-syntax-for-github-actions | |
name: CI | |
# Controls when the action will run. | |
on: | |
# Triggers the workflow on push or pull request events but only for the main branch | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
env: | |
DOTNET_VERSION: ${{ '8.0.x' }} | |
ENABLE_DIAGNOSTICS: true | |
#COREHOST_TRACE: 1 | |
COREHOST_TRACEFILE: corehosttrace.log | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# This workflow contains a single job called "Xaml-Style-Check" | |
Xaml-Style-Check: | |
runs-on: windows-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
- name: Install .NET SDK v${{ env.DOTNET_VERSION }} | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
# Restore Tools from Manifest list in the Repository | |
- name: Restore dotnet tools | |
run: dotnet tool restore | |
- name: Check XAML Styling | |
run: powershell -version 5.1 -command "./ApplyXamlStyling.ps1 -Passive" -ErrorAction Stop | |
test-tooling: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install .NET SDK v${{ env.DOTNET_VERSION }} | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- name: .NET Info (if diagnostics) | |
if: ${{ env.ENABLE_DIAGNOSTICS == 'true' }} | |
run: dotnet --info | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: dotnet build | |
working-directory: ./ | |
run: dotnet build /bl CommunityToolkit.Tooling.sln -p:Configuration=Release | |
# Run tests | |
- name: Install Testspace Module | |
uses: testspace-com/setup-testspace@v1 | |
with: | |
domain: ${{ github.repository_owner }} | |
- name: Run tests against Source Generators | |
run: dotnet test --logger "trx;LogFileName=sourceGeneratorTestResults.trx" -p:Configuration=Release | |
- name: Create test reports | |
run: | | |
testspace '[Source Generators]./**/TestResults/*.trx' | |
if: ${{ always() }} | |
- name: Artifact - Diagnostic Logs | |
uses: actions/upload-artifact@v4 | |
if: ${{ (env.ENABLE_DIAGNOSTICS == 'true' || env.COREHOST_TRACE != '') && always() }} | |
with: | |
name: test-tooling-logs | |
path: ./**/*.*log | |
# Test job to build the project template | |
project-template: | |
runs-on: windows-latest | |
env: | |
HEADS_DIRECTORY: tooling/ProjectHeads | |
PROJECT_DIRECTORY: tooling/ProjectTemplate | |
steps: | |
- name: Configure Pagefile | |
uses: al-cheb/[email protected] | |
with: | |
minimum-size: 32GB | |
maximum-size: 32GB | |
disk-root: "C:" | |
- name: Install .NET SDK v${{ env.DOTNET_VERSION }} | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- name: .NET Info (if diagnostics) | |
if: ${{ env.ENABLE_DIAGNOSTICS == 'true' }} | |
run: dotnet --info | |
- name: Enable git long paths | |
run: git config --system core.longpaths true | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
path: 'tooling' | |
- name: Copy props files to root | |
shell: pwsh | |
working-directory: ./ | |
run: copy ./tooling/.github/workflows/config/* ./ | |
- name: Add msbuild to PATH | |
uses: microsoft/setup-msbuild@v2 | |
- name: Add project heads to ProjectTemplate | |
working-directory: ./${{ env.PROJECT_DIRECTORY }} | |
run: ${{ github.workspace }}/${{ env.HEADS_DIRECTORY }}/GenerateSingleSampleHeads.ps1 -componentPath ${{ github.workspace }}/${{ env.PROJECT_DIRECTORY }} | |
# Build and use template for creating new experiments | |
- name: Build ProjectTemplate | |
working-directory: ./${{ env.PROJECT_DIRECTORY }} | |
run: msbuild.exe ProjectTemplate.sln /restore /nowarn:MSB4011 -p:Configuration=Debug | |
# Test job to build a single experiment to ensure our changes work for both our main types of solutions at the moment | |
new-experiment: | |
runs-on: windows-latest | |
env: | |
HEADS_DIRECTORY: tooling/ProjectHeads | |
PROJECT_DIRECTORY: tooling/ProjectTemplate | |
TEST_PROJECT_NAME: CiTestExp | |
TEST_PROJECT_DIRECTORY: components/CiTestExp | |
steps: | |
- name: Configure Pagefile | |
uses: al-cheb/[email protected] | |
with: | |
minimum-size: 32GB | |
maximum-size: 32GB | |
disk-root: "C:" | |
- name: Enable Crash Dumps | |
if: ${{ env.ENABLE_DIAGNOSTICS == 'true' }} | |
shell: pwsh | |
run: | | |
# If we set the registry from a 32-bit process on a 64-bit machine, we will set the "virtualized" syswow registry. | |
# For crash dump collection we always want to set the "native" registry, so we make sure to invoke the native cmd.exe | |
$nativeCmdPath = "$env:SystemRoot\system32\cmd.exe" | |
if([Environment]::Is64BitOperatingSystem -and ![Environment]::Is64BitProcess) | |
{ | |
# The "sysnative" path is a 'magic' path that allows a 32-bit process to invoke the native 64-bit cmd.exe. | |
$nativeCmdPath = "$env:SystemRoot\sysnative\cmd.exe" | |
} | |
if(!$dumpFolder) | |
{ | |
$dumpFolder = "C:\dumps" | |
} | |
function Enable-CrashDumpsForProcesses { | |
Param([string[]]$namesOfProcessesForDumpCollection) | |
foreach($procName in $namesOfProcessesForDumpCollection ) | |
{ | |
Write-Host "Enabling local crash dumps for $procName" | |
& $nativeCmdPath /c reg add "HKLM\Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\$procName" /v DumpFolder /t REG_EXPAND_SZ /d $dumpFolder /f | |
& $nativeCmdPath /c reg add "HKLM\Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\$procName" /v DumpType /t REG_DWORD /d 2 /f | |
& $nativeCmdPath /c reg add "HKLM\Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\$procName" /v DumpCount /t REG_DWORD /d 3 /f | |
} | |
} | |
# enable dump collection for our test apps: | |
$namesOfProcessesForDumpCollection = @( | |
"CommunityToolkit.Tests.Uwp.exe", | |
"CommunityToolkit.Tests.WinAppSdk.exe", | |
"CiTestExp.Tests.Uwp.exe", | |
"CiTestExp.Tests.WinAppSdk.exe", | |
"Labs.CiTestExp.Tests.Uwp.exe", | |
"Labs.CiTestExp.Tests.AppSdk.exe", | |
"Labs.CiTestExp.Tests.Uwp_1.0.0.0_x64__1v6rh0sdhj24c.exe", | |
"Labs.CiTestExp.Tests.AppSdk_1.0.0.0_x64__1v6rh0sdhj24c.exe", | |
"VSTest.Console.exe") | |
Enable-CrashDumpsForProcesses $namesOfProcessesForDumpCollection | |
- name: Install .NET SDK v${{ env.DOTNET_VERSION }} | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- name: .NET Info (if diagnostics) | |
if: ${{ env.ENABLE_DIAGNOSTICS == 'true' }} | |
run: dotnet --info | |
- name: Enable git long paths | |
run: git config --system core.longpaths true | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
path: 'tooling' | |
- name: Copy props and config files to root and setup structure | |
shell: pwsh | |
working-directory: ./ | |
run: | | |
copy ./tooling/.github/workflows/config/* ./ | |
mkdir ./.config | |
copy ./tooling/.config/dotnet-tools.json ./.config/dotnet-tools.json | |
mkdir ./components | |
- name: Add msbuild to PATH | |
uses: microsoft/setup-msbuild@v2 | |
# Restore Tools from Manifest list in the Repository | |
- name: Restore dotnet tools | |
working-directory: ./ | |
run: dotnet tool restore | |
# Create a new experiment from the template and test using that | |
- name: Install template | |
working-directory: ${{ env.PROJECT_DIRECTORY }} | |
run: dotnet new --install ./ | |
- name: Create new experiment | |
working-directory: ./components | |
run: dotnet new ctk-component -n ${{ env.TEST_PROJECT_NAME }} | |
- name: Add project heads to ${{ env.TEST_PROJECT_NAME }} | |
working-directory: ./${{ env.TEST_PROJECT_DIRECTORY }} | |
run: ${{ github.workspace }}/${{ env.HEADS_DIRECTORY }}/GenerateSingleSampleHeads.ps1 -componentPath ${{ github.workspace }}/${{ env.TEST_PROJECT_DIRECTORY }} | |
- name: MSBuild | |
working-directory: ./${{ env.TEST_PROJECT_DIRECTORY }} | |
run: msbuild.exe ${{ env.TEST_PROJECT_NAME }}.sln /restore /nowarn:MSB4011 -p:Configuration=Release | |
# Run tests | |
- name: Setup VSTest Path | |
uses: darenm/setup-vstest@3a16d909a1f3bbc65b52f8270d475d905e7d3e44 | |
- name: Install Testspace Module | |
uses: testspace-com/setup-testspace@v1 | |
with: | |
domain: ${{ github.repository_owner }} | |
- name: Run tests in the generated experiment against UWP | |
id: test-uwp | |
run: vstest.console.exe ./components/${{ env.TEST_PROJECT_NAME }}/**/${{ env.TEST_PROJECT_NAME }}.Tests.UWP.build.appxrecipe /Framework:FrameworkUap10 /logger:"trx;LogFileName=${{ env.TEST_PROJECT_NAME }}UWP.trx" | |
- name: Run tests in the generated experiment against WinAppSDK | |
id: test-winappsdk | |
run: vstest.console.exe ./components/${{ env.TEST_PROJECT_NAME }}/**/${{ env.TEST_PROJECT_NAME }}.Tests.WinAppSdk.build.appxrecipe /Framework:FrameworkUap10 /logger:"trx;LogFileName=${{ env.TEST_PROJECT_NAME }}WinAppSdk.trx" | |
- name: Create test reports | |
run: | | |
testspace '[New Experiment]./TestResults/*.trx' | |
if: ${{ always() && (steps.test-uwp.conclusion == 'success' || steps.test-winappsdk.conclusion == 'success') }} | |
- name: Artifact - Diagnostic Logs | |
uses: actions/upload-artifact@v4 | |
if: ${{ (env.ENABLE_DIAGNOSTICS == 'true' || env.COREHOST_TRACE != '') && always() }} | |
with: | |
name: new-experiment-logs | |
path: ./**/*.*log | |
- name: Artifact - Process Dumps | |
uses: actions/upload-artifact@v4 | |
if: ${{ (env.ENABLE_DIAGNOSTICS == 'true' || env.COREHOST_TRACE != '') && always() }} | |
with: | |
name: new-experiment-dumps | |
path: C:/dumps/*.*dmp | |
wasm-linux: | |
runs-on: ubuntu-latest | |
env: | |
HEADS_DIRECTORY: tooling/ProjectHeads | |
TEST_PROJECT_NAME: CiTestExp | |
steps: | |
- name: Install .NET SDK v${{ env.DOTNET_VERSION }} | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- name: .NET Info (if diagnostics) | |
if: ${{ env.ENABLE_DIAGNOSTICS == 'true' }} | |
run: dotnet --info | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
path: 'tooling' | |
- name: Copy props and config files to root and setup structure | |
shell: pwsh | |
working-directory: ./ | |
run: | | |
copy ./tooling/.github/workflows/config/* ./ | |
mkdir ./.config | |
copy ./tooling/.config/dotnet-tools.json ./.config/dotnet-tools.json | |
mkdir ./components | |
# Restore Tools from Manifest list in the Repository | |
- name: Restore dotnet tools | |
working-directory: ./ | |
run: dotnet tool restore | |
# Create a new experiment from the template and test using that | |
- name: Install template | |
working-directory: ${{ env.PROJECT_DIRECTORY }} | |
run: dotnet new --install ./ | |
- name: Create new experiment | |
working-directory: ./components | |
run: dotnet new ctk-component -n ${{ env.TEST_PROJECT_NAME }} | |
- name: Generate solution | |
shell: pwsh | |
working-directory: ./ | |
run: ./tooling/GenerateAllSolution.ps1${{ env.ENABLE_DIAGNOSTICS == 'true' && ' -UseDiagnostics' || '' }} | |
# Issue with Comment Links currently, see: https://github.com/mrlacey/CommentLinks/issues/38 | |
# See launch.json configuration file for analogous command we're emulating here to build LINK: ../../.vscode/launch.json:CommunityToolkit.App.Wasm.csproj | |
- name: dotnet build | |
working-directory: ./${{ env.HEADS_DIRECTORY }}/AllComponents/Wasm/ | |
run: dotnet build /r /bl /p:UnoSourceGeneratorUseGenerationHost=true /p:UnoSourceGeneratorUseGenerationController=false | |
# TODO: Do we want to run tests here? Can we do that on linux easily? | |
- name: Artifact - Diagnostic Logs | |
uses: actions/upload-artifact@v4 | |
if: ${{ (env.ENABLE_DIAGNOSTICS == 'true' || env.COREHOST_TRACE != '') && always() }} | |
with: | |
name: linux-logs | |
path: ./**/*.*log |