Skip to content

Commit

Permalink
Updated sorting and output
Browse files Browse the repository at this point in the history
  • Loading branch information
dmytrostruk committed Oct 19, 2024
1 parent 35bc490 commit 6b9b4ea
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions .github/workflows/check-coverage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ foreach ($assembly in $jsonContent.coverage.assemblies) {

$assemblyTableData += [PSCustomObject]@{
'Assembly Name' = $assemblyName
'Line' = Get-FormattedValue -Coverage $assemblyLineCoverage -UseIcon $isNonExperimentalAssembly
'Branch' = Get-FormattedValue -Coverage $assemblyBranchCoverage -UseIcon $isNonExperimentalAssembly
'Line' = $assemblyLineCoverage
'Branch' = $assemblyBranchCoverage
}
}

Expand All @@ -71,14 +71,21 @@ foreach ($assembly in $jsonContent.coverage.assemblies) {
# Then experimental assemblies, sorted by line and then by branch coverage.
$sortedTable = $assemblyTableData | Sort-Object {
$isNonExperimentalAssembly = $nonExperimentalAssemblies -contains $_.'Assembly Name'

$lineCoverageNumeric = [float]($_.'Line' -replace '%|[^0-9\.]', '')
$branchCoverageNumeric = [float]($_.'Branch' -replace '%|[^0-9\.]', '')

$isNonExperimentalAssembly, $lineCoverageNumeric, $branchCoverageNumeric
$isNonExperimentalAssembly, $_.'Line', $_.'Branch'
} -Descending

$sortedTable | Format-Table -AutoSize
$formattedOutput = $sortedTable | ForEach-Object {
$isNonExperimentalAssembly = $nonExperimentalAssemblies -contains $_.'Assembly Name'

[PSCustomObject]@{
'Assembly Name' = $_.'Assembly Name'
'Line' = Get-FormattedValue -Coverage $_.'Line' -UseIcon $isNonExperimentalAssembly
'Branch ' = Get-FormattedValue -Coverage $_.'Branch' -UseIcon $isNonExperimentalAssembly
}
}

$formattedOutput | Format-Table -AutoSize

if ($coverageBelowThreshold) {
Write-Host "Code coverage is lower than defined threshold: $CoverageThreshold. Stopping the task."
Expand Down

0 comments on commit 6b9b4ea

Please sign in to comment.