added ability to fail a workflow #16

This commit is contained in:
irongut
2021-10-19 23:49:51 +01:00
parent b97bc1147a
commit 02bb824606
3 changed files with 17 additions and 2 deletions
+10
View File
@@ -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
}
}