resolve https://github.com/Siemens-Healthineers/ETWAnalyzer/issues/56… #207
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
name: Build And Test | |
on: | |
workflow_dispatch: | |
push: | |
branches: [ main ] | |
paths-ignore: | |
- '**.yml' | |
pull_request: | |
branches: [ main ] | |
paths-ignore: | |
- '**.yml' | |
jobs: | |
build: | |
runs-on: windows-latest # For a list of available runner types, refer to | |
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on | |
strategy: | |
matrix: | |
onsystem: | |
- 'x64-windows' | |
configuration: [Release] | |
env: | |
Solution_Name: ETWAnalyzer.sln | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: GetStartTime | |
run: | | |
$startTime = [System.Diagnostics.Stopwatch]::GetTimestamp() | |
# store start time in environment which is the github way to share variables between steps | |
"ProfilingStartTime=$startTime" >> $env:GITHUB_ENV | |
shell: powershell | |
# Download custom wpr Profile | |
- name: Download and patch custom recording profile | |
run: | | |
curl https://raw.githubusercontent.com/Alois-xx/FileWriter/master/MultiProfile.wprp > MultiProfile.wprp | |
# We need to remove the Strict="true" attribute in profile because in Azure some CPU counters | |
# are already monitored and wpr will complain even if we do not use a CPU counter recording profile. This is a bug in wpr. | |
$var=(Get-Content -path MultiProfile.wprp -Raw); | |
$replaced=$var.Replace('Strict="true"',''); | |
Write-Host $replaced | |
Set-Content -Value $replaced -Path MultiProfile.wprp | |
# Start Profiling | |
- name: Start Profiling | |
run: | | |
# We record into a file to capture everything. | |
# Since extraction of a large ETL needs many GB of memory we can run out of memory so it is best | |
# to split longer parts like build and test into separate files which are extracted separately | |
wpr -start MultiProfile.wprp!CSwitch -start MultiProfile.wprp!File -start MultiProfile.wprp!Network -filemode | |
# Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild | |
- name: Setup MSBuild.exe | |
uses: microsoft/[email protected] | |
# Print .NET information | |
- name: Get .NET Information | |
run: dotnet --info | |
- name: Build Release | |
run: dotnet build -c Release | |
# Stop Profiling | |
- name: Stop Profiling | |
run: | | |
$stopTime = [System.Diagnostics.Stopwatch]::GetTimestamp() | |
$startStr = ${{ env.ProfilingStartTime }} | |
$startTime = [System.Int64]::Parse($startStr) | |
$runtimeMs = [System.TimeSpan]::FromTicks($stopTime-$startTime).TotalMilliseconds.ToString("F0") | |
$date = Get-Date -format "yyyyMMdd-HHmmss" | |
# construct file name in format which is understood by ETWAnalyzer to later filter by testcase, test duration, .... | |
$fileName = "ProfilingData\Build_$($runtimeMs)ms$($env:ComputerName).$($date).etl" | |
mkdir ProfilingData > $null | |
mkdir Extract > $null | |
wpr -stop $fileName -skipPdbGen | |
"EtlFileName=$fileName" >> $env:GITHUB_ENV | |
- name: Extract | |
run: | | |
.\bin\Release\net6.0-windows\win-x64\ETWAnalyzer -extract all -fd ${{ env.EtlFileName }} -outdir Extract | |
shell: powershell -Command "& '{0}'" | |
# Start Test Profiling | |
- name: Start Test Profiling | |
run: | | |
$startTime = [System.Diagnostics.Stopwatch]::GetTimestamp() | |
"ProfilingStartTime=$startTime" >> $env:GITHUB_ENV | |
wpr -start MultiProfile.wprp!CSwitch -start MultiProfile.wprp!File -start MultiProfile.wprp!Network -filemode | |
# Execute all unit tests in the solution | |
- name: Execute unit tests | |
run: | | |
dotnet test /nodeReuse:false -m:1 -p:ParallelizeTestCollections=false /p:CopyLocalLockFileAssemblies=true --logger GitHubActions --verbosity detailed --settings Test.runsettings --diag:log.txt --collect:"XPlat Code Coverage" --results-directory ./ults --logger trx | |
# Stop Profiling | |
- name: Stop Test Profiling | |
run: | | |
$stopTime = [System.Diagnostics.Stopwatch]::GetTimestamp() | |
$startStr = ${{ env.ProfilingStartTime }} | |
$startTime = [System.Int64]::Parse($startStr) | |
$runtimeMs = [System.TimeSpan]::FromTicks($stopTime-$startTime).TotalMilliseconds.ToString("F0") | |
$date = Get-Date -format "yyyyMMdd-HHmmss" | |
"TestRunTimeMs=$($runtimeMs)ms_$($date)" >> $env:GITHUB_ENV | |
$fileName = "ProfilingData\TestExecution_$($runtimeMs)ms$($env:ComputerName).$($date).etl" | |
wpr -stop $fileName -skipPdbGen | |
"EtlFileName=$fileName" >> $env:GITHUB_ENV | |
- name: Extract Test Profiling Data | |
run: | | |
.\bin\Release\net6.0-windows\win-x64\ETWAnalyzer -extract all -fd ${{ env.EtlFileName }} -outdir Extract | |
shell: powershell -Command "& '{0}'" | |
- name: Upload Profiling Data | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ProfilingData_${{ env.TestRunTimeMs }} | |
path: ProfilingData | |
retention-days: 90 | |
- name: Upload Profiling Extract Data | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Extract_${{ env.TestRunTimeMs }} | |
path: Extract | |
retention-days: 90 | |