Compare commits

..

9 Commits

Author SHA1 Message Date
irongut 473d18e3ad prepare v1.0.5 2021-09-27 20:21:03 +01:00
irongut 61d10948c8 merge PR #10 Make compatible with gcovr 2021-09-27 19:44:43 +01:00
irongut 7cd8fe49e9 improved decimal complexity output #9 2021-09-27 19:41:59 +01:00
irongut 174c97ac3d handle empty package names #9 2021-09-26 01:49:23 +01:00
irongut 9b11daeca8 handle Complexity as an int or percentage #9 2021-09-26 00:58:44 +01:00
irongut 6db46e287e handle missing package attributes better 2021-09-26 00:01:55 +01:00
irongut c5d12d4a89 prepare v1.0.4 2021-09-25 21:48:17 +01:00
irongut cae1cbcdad merge PR #8 Bump docker image to v1.0.3 in action.yml from reallyreallyreal/master
Bump docker image to v1.0.3 in action.yml
2021-09-25 21:24:23 +01:00
Jonathan Derrough ed258b1479 Bump docker image to v1.0.3 in action.yml 2021-09-25 12:09:21 +07:00
7 changed files with 1104 additions and 16 deletions
+2 -2
View File
@@ -52,7 +52,7 @@ Company.Example.Library: Line Rate = 27%, Branch Rate = 100%, Complexity = 11
```yaml ```yaml
name: Code Coverage Summary Report name: Code Coverage Summary Report
uses: irongut/CodeCoverageSummary@v1.0.3 uses: irongut/CodeCoverageSummary@v1.0.5
with: with:
filename: coverage/coverage.cobertura.xml filename: coverage/coverage.cobertura.xml
``` ```
@@ -94,7 +94,7 @@ jobs:
run: cp coverage/**/coverage.cobertura.xml coverage/coverage.cobertura.xml run: cp coverage/**/coverage.cobertura.xml coverage/coverage.cobertura.xml
- name: Code Coverage Summary Report - name: Code Coverage Summary Report
uses: irongut/CodeCoverageSummary@v1.0.3 uses: irongut/CodeCoverageSummary@v1.0.5
with: with:
filename: coverage/coverage.cobertura.xml filename: coverage/coverage.cobertura.xml
badge: true badge: true
+1 -1
View File
@@ -22,7 +22,7 @@ inputs:
default: 'console' default: 'console'
runs: runs:
using: 'docker' using: 'docker'
image: 'docker://ghcr.io/irongut/codecoveragesummary:v1.0.2' image: 'docker://ghcr.io/irongut/codecoveragesummary:v1.0.5'
args: args:
- ${{ inputs.filename }} - ${{ inputs.filename }}
- '--badge' - '--badge'
@@ -14,7 +14,7 @@
<RepositoryUrl>https://github.com/irongut/CodeCoverageSummary</RepositoryUrl> <RepositoryUrl>https://github.com/irongut/CodeCoverageSummary</RepositoryUrl>
<RepositoryType>git</RepositoryType> <RepositoryType>git</RepositoryType>
<PackageTags>coverage test-coverage cobertura action code-coverage coverlet github-actions</PackageTags> <PackageTags>coverage test-coverage cobertura action code-coverage coverlet github-actions</PackageTags>
<Version>1.0.3</Version> <Version>1.0.5</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
+2 -2
View File
@@ -10,7 +10,7 @@ namespace CodeCoverageSummary
public double BranchRate { get; set; } public double BranchRate { get; set; }
public int Complexity { get; set; } public double Complexity { get; set; }
} }
public class CodeSummary public class CodeSummary
@@ -27,7 +27,7 @@ namespace CodeCoverageSummary
public int BranchesValid { get; set; } public int BranchesValid { get; set; }
public int Complexity { get; set; } public double Complexity { get; set; }
public List<CodeCoverage> Packages { get; set; } public List<CodeCoverage> Packages { get; set; }
+42 -9
View File
@@ -134,17 +134,19 @@ namespace CodeCoverageSummary
var packages = from item in coverage.Descendants("package") var packages = from item in coverage.Descendants("package")
select item; select item;
int i = 1;
foreach (var item in packages) foreach (var item in packages)
{ {
CodeCoverage packageCoverage = new() CodeCoverage packageCoverage = new()
{ {
Name = item.Attribute("name").Value, Name = string.IsNullOrWhiteSpace(item.Attribute("name").Value) ? $"Package {i}" : item.Attribute("name").Value,
LineRate = double.Parse(item.Attribute("line-rate").Value), LineRate = double.Parse(item.Attribute("line-rate")?.Value ?? "0"),
BranchRate = double.Parse(item.Attribute("branch-rate").Value), BranchRate = double.Parse(item.Attribute("branch-rate")?.Value ?? "0"),
Complexity = int.Parse(item.Attribute("complexity")?.Value ?? "0") Complexity = double.Parse(item.Attribute("complexity")?.Value ?? "0")
}; };
summary.Packages.Add(packageCoverage); summary.Packages.Add(packageCoverage);
summary.Complexity += packageCoverage.Complexity; summary.Complexity += packageCoverage.Complexity;
i++;
} }
return summary; return summary;
@@ -184,12 +186,27 @@ namespace CodeCoverageSummary
} }
textOutput.AppendLine($"Line Rate = {summary.LineRate * 100:N0}%, Lines Covered = {summary.LinesCovered} / {summary.LinesValid}") textOutput.AppendLine($"Line Rate = {summary.LineRate * 100:N0}%, Lines Covered = {summary.LinesCovered} / {summary.LinesValid}")
.AppendLine($"Branch Rate = {summary.BranchRate * 100:N0}%, Branches Covered = {summary.BranchesCovered} / {summary.BranchesValid}") .AppendLine($"Branch Rate = {summary.BranchRate * 100:N0}%, Branches Covered = {summary.BranchesCovered} / {summary.BranchesValid}");
.AppendLine($"Complexity = {summary.Complexity}");
if (summary.Complexity % 1 == 0)
{
textOutput.AppendLine($"Complexity = {summary.Complexity}");
}
else
{
textOutput.AppendLine($"Complexity = {summary.Complexity:N4}");
}
foreach (CodeCoverage package in summary.Packages) foreach (CodeCoverage package in summary.Packages)
{ {
textOutput.AppendLine($"{package.Name}: Line Rate = {package.LineRate * 100:N0}%, Branch Rate = {package.BranchRate * 100:N0}%, Complexity = {package.Complexity}"); if (package.Complexity % 1 == 0)
{
textOutput.AppendLine($"{package.Name}: Line Rate = {package.LineRate * 100:N0}%, Branch Rate = {package.BranchRate * 100:N0}%, Complexity = {package.Complexity}");
}
else
{
textOutput.AppendLine($"{package.Name}: Line Rate = {package.LineRate * 100:N0}%, Branch Rate = {package.BranchRate * 100:N0}%, Complexity = {package.Complexity:N4}");
}
} }
return textOutput.ToString(); return textOutput.ToString();
@@ -210,11 +227,27 @@ namespace CodeCoverageSummary
foreach (CodeCoverage package in summary.Packages) foreach (CodeCoverage package in summary.Packages)
{ {
markdownOutput.AppendLine($"{package.Name} | {package.LineRate * 100:N0}% | {package.BranchRate * 100:N0}% | {package.Complexity}"); if (package.Complexity % 1 == 0)
{
markdownOutput.AppendLine($"{package.Name} | {package.LineRate * 100:N0}% | {package.BranchRate * 100:N0}% | {package.Complexity}");
}
else
{
markdownOutput.AppendLine($"{package.Name} | {package.LineRate * 100:N0}% | {package.BranchRate * 100:N0}% | {package.Complexity:N4}");
}
} }
markdownOutput.Append($"**Summary** | **{summary.LineRate * 100:N0}%** ({summary.LinesCovered} / {summary.LinesValid}) | ") markdownOutput.Append($"**Summary** | **{summary.LineRate * 100:N0}%** ({summary.LinesCovered} / {summary.LinesValid}) | ")
.AppendLine($"**{summary.BranchRate * 100:N0}%** ({summary.BranchesCovered} / {summary.BranchesValid}) | {summary.Complexity}"); .Append($"**{summary.BranchRate * 100:N0}%** ({summary.BranchesCovered} / {summary.BranchesValid}) | ");
if (summary.Complexity % 1 == 0)
{
markdownOutput.AppendLine(summary.Complexity.ToString());
}
else
{
markdownOutput.AppendLine(summary.Complexity.ToString("N4"));
}
return markdownOutput.ToString(); return markdownOutput.ToString();
} }
@@ -1,7 +1,8 @@
{ {
"profiles": { "profiles": {
"CodeCoverageSummary": { "CodeCoverageSummary": {
"commandName": "Project" "commandName": "Project",
"commandLineArgs": "../../../../coverage.gcovr.xml --format=md --badge=true"
}, },
"Docker": { "Docker": {
"commandName": "Docker", "commandName": "Docker",
File diff suppressed because it is too large Load Diff