-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Page Scripting test result visualizer & updated test analyzer logic. #1423
base: main
Are you sure you want to change the base?
Changes from all commits
cfa1cf5
d847c20
d6eb5d3
548333f
ff3c795
c8ab211
8c97234
dc18262
a963376
6f277ed
8a0e951
0500101
0999647
6c3ed9c
82522f4
f7cc15b
d172421
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,55 @@ | ||
Param( | ||
[Parameter(HelpMessage = "Project to analyze", Mandatory = $false)] | ||
[string] $project = '.' | ||
[string] $project = '.', | ||
[Parameter(HelpMessage = "Tests to analyze", Mandatory = $false)] | ||
[ValidateSet('normal', 'bcpt', 'pageScripting')] | ||
[string] $testType = 'normal' | ||
) | ||
|
||
. (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 | ||
$testResultsSummaryMD = '' | ||
$testResultsfailuresMD = '' | ||
$testResultsFailuresSummaryMD = '' | ||
|
||
$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 ($testType -eq 'normal') { | ||
$testResultsFile = Join-Path $ENV:GITHUB_WORKSPACE "$project\TestResults.xml" | ||
$testResultsSummaryMD, $testResultsfailuresMD, $testResultsFailuresSummaryMD = GetTestResultSummaryMD -testResultsFile $testResultsFile | ||
$testTitle = "Test results" | ||
} | ||
elseif ($testType -eq 'bcpt') { | ||
$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" | ||
$testResultsSummaryMD = GetBcptSummaryMD ` | ||
-bcptTestResultsFile $bcptTestResultsFile ` | ||
-baseLinePath $bcptBaseLineFile ` | ||
-thresholdsPath $bcptThresholdsFile ` | ||
-bcptThresholds ($settings.bcptThresholds | ConvertTo-HashTable) | ||
$testTitle = "Performance test results" | ||
} | ||
elseif ($testType -eq 'pageScripting') { | ||
$testResultsFile = Join-Path $ENV:GITHUB_WORKSPACE "$project\PageScriptingTestResults.xml" | ||
$testResultsSummaryMD, $testResultsfailuresMD, $testResultsFailuresSummaryMD = GetPageScriptingTestResultSummaryMD -testResultsFile $testResultsFile | ||
$testTitle = "Page Scripting test results" | ||
} | ||
else { | ||
Write-Host "::error:: Unknown test type: $testsToAnalyze" | ||
return '' | ||
} | ||
|
||
# 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 | ||
if ($testResultsSummaryMD.Length + $testResultsfailuresMD.Length -gt 65000) { | ||
# If Combined Test Results and failures 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 "## $testTitle`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" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,7 +163,7 @@ function GetBcptSummaryMD { | |
|
||
$bcpt = ReadBcptFile -bcptTestResultsFile $bcptTestResultsFile | ||
if (-not $bcpt) { | ||
return '' | ||
return '<i>No test results found</i>' | ||
} | ||
$baseLine = ReadBcptFile -bcptTestResultsFile $baseLinePath | ||
if ($baseLine) { | ||
|
@@ -322,3 +322,76 @@ function GetBcptSummaryMD { | |
|
||
$summarySb.ToString() | ||
} | ||
|
||
function GetPageScriptingTestResultSummaryMD { | ||
Param( | ||
[string] $testResultsFile | ||
) | ||
|
||
$summarySb = [System.Text.StringBuilder]::new() | ||
$failuresSb = [System.Text.StringBuilder]::new() | ||
|
||
if (Test-Path -Path $testResultsFile -PathType Leaf) { | ||
$testResults = [xml](Get-Content -path $testResultsFile -Encoding UTF8) | ||
$totalTests = 0 | ||
$totalTime = 0.0 | ||
$totalFailed = 0 | ||
$totalSkipped = 0 | ||
|
||
if ($testResults.testsuites) { | ||
$totalTests = $testResults.testsuites.tests | ||
$totalTime = $testResults.testsuites.time | ||
$totalFailed = $testResults.testsuites.failures | ||
$totalSkipped = $testResults.testsuites.skipped | ||
$totalPassed = $totalTests - $totalFailed - $totalSkipped | ||
|
||
#Write total summary for all test suites | ||
Write-Host "$totalTests tests, $totalPassed passed, $totalFailed failed, $totalSkipped skipped, $totalTime seconds" | ||
$summarySb.AppendLine('|Suite|Tests|Passed|Failed|Skipped|Time|') | Out-Null | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PowerShell generating Markdown is extremely hard to read. Is there a way to define some MD templates with placeholders that could be used to generate the end-goal MD? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll try see if I can come up with something that is easier to debug / code review. |
||
$summarySb.AppendLine('|:---|---:|---:|---:|---:|---:|') | Out-Null | ||
foreach($testsuite in $testResults.testsuites.testsuite) { | ||
$suiteTests = $testsuite.tests | ||
$suiteTime = $testsuite.time | ||
$suiteFailed = $testsuite.failures | ||
$suiteSkipped = $testsuite.skipped | ||
$suitePassed = $suiteTests - $suiteFailed - $suiteSkipped | ||
$summarySb.AppendLine("|$($testsuite.name)|$suiteTests|$suitePassed$statusOk|$suiteFailed$statusError|$suiteSkipped$statusSkipped|$suiteTime|") | Out-Null | ||
|
||
if ($suiteFailed -gt 0 ) { | ||
$failuresSb.Append("<details><summary><i>$testsuite.name, $suiteTests tests, $suitePassed passed, $suiteFailed failed, $suiteSkipped skipped, $suiteTime seconds</i></summary>") | Out-Null | ||
foreach($testcase in $testsuite.testcase) { | ||
$testName = Split-Path ($testcase.name -replace '\(', '' -replace '\)', '') -Leaf | ||
if ($testcase.failure) { | ||
Write-Host " - Error: $($testcase.failure.message)" | ||
Write-Host " Stacktrace:" | ||
Write-Host " $($testcase.failure."#cdata-section".Trim().Replace("`n","`n "))" | ||
$failuresSb.Append("<details><summary><i>$($testName), Failure</i></summary>") | Out-Null | ||
$failuresSb.Append("<i> Error: $($testcase.failure.message)</i><br/>") | Out-Null | ||
$failuresSb.Append("<i> Stack trace</i><br/>") | Out-Null | ||
$failuresSb.Append("<i> $($testcase.failure."#cdata-section")</i><br/>") | Out-Null | ||
$failuresSb.Append("</details>") | Out-Null | ||
} | ||
} | ||
$failuresSb.Append("</details>") | Out-Null | ||
} | ||
} | ||
} | ||
if ($totalFailed -gt 0) { | ||
$failuresSummaryMD = "<i>$totalFailed failing tests, download test results to see details</i>" | ||
$failuresSb.Insert(0,"<details><summary>$failuresSummaryMD</summary>") | Out-Null | ||
$failuresSb.Append("</details>") | Out-Null | ||
} | ||
else { | ||
$failuresSummaryMD = "<i>No test failures</i>" | ||
$failuresSb.Append($failuresSummaryMD) | Out-Null | ||
} | ||
} | ||
else { | ||
$summarySb.Append("<i>No test results found</i>") | Out-Null | ||
$failuresSummaryMD = '' | ||
} | ||
|
||
$summarySb.ToString() | ||
$failuresSb.ToString() | ||
$failuresSummaryMD | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,7 +94,7 @@ jobs: | |
shell: ${{ inputs.shell }} | ||
project: ${{ inputs.project }} | ||
buildMode: ${{ inputs.buildMode }} | ||
get: useCompilerFolder,keyVaultCodesignCertificateName,doNotSignApps,doNotRunTests,artifact,generateDependencyArtifact,trustedSigning,useGitSubmodules | ||
get: useCompilerFolder,keyVaultCodesignCertificateName,doNotSignApps,doNotRunTests,doNotRunBcptTests,doNotRunpageScriptingTests,artifact,generateDependencyArtifact,trustedSigning,useGitSubmodules | ||
|
||
- name: Read secrets | ||
id: ReadSecrets | ||
|
@@ -254,6 +254,25 @@ jobs: | |
with: | ||
shell: ${{ inputs.shell }} | ||
project: ${{ inputs.project }} | ||
testType: "normal" | ||
|
||
- name: Analyze BCPT Test Results | ||
id: analyzeTestResultsBCPT | ||
if: (success() || failure()) && env.doNotRunBcptTests == 'False' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this env variable set? I believe it needs to be included in "Read Settings", line 97. Same for |
||
uses: microsoft/AL-Go-Actions/AnalyzeTests@main | ||
with: | ||
shell: ${{ inputs.shell }} | ||
project: ${{ inputs.project }} | ||
testType: "bcpt" | ||
|
||
- name: Analyze Page Scripting Test Results | ||
id: analyzeTestResultsPageScripting | ||
if: (success() || failure()) && env.doNotRunpageScriptingTests == 'False' | ||
uses: microsoft/AL-Go-Actions/AnalyzeTests@main | ||
with: | ||
shell: ${{ inputs.shell }} | ||
project: ${{ inputs.project }} | ||
testType: "pageScripting" | ||
|
||
- name: Cleanup | ||
if: always() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the action has output.
OUTPUT variables
might need to be cleaned up.