mirror of
https://github.com/irongut/CodeCoverageSummary.git
synced 2026-06-11 15:10:46 +00:00
added ability to fail a workflow #16
This commit is contained in:
@@ -49,11 +49,15 @@ namespace CodeCoverageSummary
|
||||
{
|
||||
fileExt = "txt";
|
||||
output = GenerateTextOutput(summary, badgeUrl, o.Indicators);
|
||||
if (o.FailBelowThreshold)
|
||||
output += $"Minimum allowed line rate is {lowerThreshold * 100:N0}%{Environment.NewLine}";
|
||||
}
|
||||
else if (o.Format.Equals("md", StringComparison.OrdinalIgnoreCase) || o.Format.Equals("markdown", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
fileExt = "md";
|
||||
output = GenerateMarkdownOutput(summary, badgeUrl, o.Indicators);
|
||||
if (o.FailBelowThreshold)
|
||||
output += $"{Environment.NewLine}_Minimum allowed line rate is `{lowerThreshold * 100:N0}%`_{Environment.NewLine}";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -81,6 +85,12 @@ namespace CodeCoverageSummary
|
||||
return -2; // error
|
||||
}
|
||||
|
||||
if (o.FailBelowThreshold && summary.LineRate < lowerThreshold)
|
||||
{
|
||||
Console.WriteLine($"FAIL: Overall line rate below minimum threshold of {lowerThreshold * 100:N0}%.");
|
||||
return -2;
|
||||
}
|
||||
|
||||
return 0; // success
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user