-
Notifications
You must be signed in to change notification settings - Fork 11
139 lines (119 loc) · 6.11 KB
/
BuildAndTest.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
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@v4
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 -start MultiProfile.wprp!Frequency -filemode
# Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v2
# Print .NET information
- name: Get .NET Information
run: dotnet --info
- name: Nuget Restore
run: msbuild -t:restore
- name: Build Release
run: msbuild "/p:Configuration=Release;Platform=x64"
# 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\net8.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 ETWAnalyzer_uTest /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
dotnet test ETWAnalyzer_iTest /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\net8.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@v4
with:
name: ProfilingData_${{ env.TestRunTimeMs }}
path: ProfilingData
retention-days: 90
- name: Upload Profiling Extract Data
if: always()
uses: actions/upload-artifact@v4
with:
name: Extract_${{ env.TestRunTimeMs }}
path: Extract
retention-days: 90