-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathAnalyzeTests.ps1
45 lines (39 loc) · 2.74 KB
/
AnalyzeTests.ps1
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
Param(
[Parameter(HelpMessage = "Project to analyze", Mandatory = $false)]
[string] $project = '.'
)
. (Join-Path -Path $PSScriptRoot -ChildPath "..\AL-Go-Helper.ps1" -Resolve)
. (Join-Path -Path $PSScriptRoot 'TestResultAnalyzer.ps1')
$testResultsFile = Join-Path $ENV:GITHUB_WORKSPACE "$project\TestResults.xml"
$testResultsSummaryMD, $testResultsfailuresMD, $testResultsFailuresSummaryMD = GetTestResultSummaryMD -testResultsFile $testResultsFile
$settings = $env:Settings | ConvertFrom-Json
$bcptTestResultsFile = Join-Path $ENV:GITHUB_WORKSPACE "$project\bcptTestResults.json"
$bcptBaseLineFile = Join-Path $ENV:GITHUB_WORKSPACE "$project\bcptBaseLine.json"
$bcptThresholdsFile = Join-Path $ENV:GITHUB_WORKSPACE "$project\bcptThresholds.json"
$bcptSummaryMD = GetBcptSummaryMD `
-bcptTestResultsFile $bcptTestResultsFile `
-baseLinePath $bcptBaseLineFile `
-thresholdsPath $bcptThresholdsFile `
-bcptThresholds ($settings.bcptThresholds | ConvertTo-HashTable)
# If summary fits, we will display it in the GitHub summary
if ($testResultsSummaryMD.Length -gt 65000) {
# If Test results summary is too long, we will not display it in the GitHub summary, instead we will display a message to download the test results
$testResultsSummaryMD = "<i>Test results summary size exceeds GitHub summary capacity. Download **TestResults** artifact to see details.</i>"
}
# If summary AND BCPT summary fits, we will display both in the GitHub summary
if ($testResultsSummaryMD.Length + $bcptSummaryMD.Length -gt 65000) {
# If Combined Test Results and BCPT summary exceeds GitHub summary capacity, we will not display the BCPT summary
$bcptSummaryMD = "<i>Performance test results summary size exceeds GitHub summary capacity. Download **BcptTestResults** artifact to see details.</i>"
}
# If summary AND BCPT summary AND failures summary fits, we will display all in the GitHub summary
if ($testResultsSummaryMD.Length + $testResultsfailuresMD.Length + $bcptSummaryMD.Length -gt 65000) {
# If Combined Test Results, failures and BCPT summary exceeds GitHub summary capacity, we will not display the failures details, only the failures summary
$testResultsfailuresMD = $testResultsFailuresSummaryMD
}
Add-Content -Encoding UTF8 -path $ENV:GITHUB_STEP_SUMMARY -value "## Test results`n`n"
Add-Content -Encoding UTF8 -path $ENV:GITHUB_STEP_SUMMARY -value "$($testResultsSummaryMD.Replace("\n","`n"))`n`n"
Add-Content -Encoding UTF8 -path $ENV:GITHUB_STEP_SUMMARY -value "$($testResultsfailuresMD.Replace("\n","`n"))`n`n"
if ($bcptSummaryMD) {
Add-Content -Encoding UTF8 -path $ENV:GITHUB_STEP_SUMMARY -value "## Performance test results`n`n"
Add-Content -Encoding UTF8 -path $ENV:GITHUB_STEP_SUMMARY -value "$($bcptSummaryMD.Replace("\n","`n"))`n`n"
}