From 4a0dc323d389fe85fa23f5750f79c6addf3e0c18 Mon Sep 17 00:00:00 2001 From: irongut Date: Mon, 18 Oct 2021 01:24:48 +0100 Subject: [PATCH 1/8] added Thresholds parameter to CLI #15 --- src/CodeCoverageSummary/CommandLineOptions.cs | 3 ++ src/CodeCoverageSummary/GlobalSuppressions.cs | 1 + src/CodeCoverageSummary/Program.cs | 46 ++++++++++++++++++- .../Properties/launchSettings.json | 2 +- 4 files changed, 49 insertions(+), 3 deletions(-) diff --git a/src/CodeCoverageSummary/CommandLineOptions.cs b/src/CodeCoverageSummary/CommandLineOptions.cs index 1b588c9..7a85b0f 100644 --- a/src/CodeCoverageSummary/CommandLineOptions.cs +++ b/src/CodeCoverageSummary/CommandLineOptions.cs @@ -15,5 +15,8 @@ namespace CodeCoverageSummary [Option(longName: "output", Required = false, HelpText = "Output Type - console, file or both.", Default = "console")] public string Output { get; set; } + + [Option(longName: "thresholds", Required = false, HelpText = "Badge colour thresholds.", Default = "50 75")] + public string Thresholds { get; set; } } } diff --git a/src/CodeCoverageSummary/GlobalSuppressions.cs b/src/CodeCoverageSummary/GlobalSuppressions.cs index 920e60b..8163dc6 100644 --- a/src/CodeCoverageSummary/GlobalSuppressions.cs +++ b/src/CodeCoverageSummary/GlobalSuppressions.cs @@ -6,3 +6,4 @@ using System.Diagnostics.CodeAnalysis; [assembly: SuppressMessage("Performance", "RCS1197:Optimize StringBuilder.Append/AppendLine call.", Scope = "type", Target = "~T:CodeCoverageSummary.Program")] +[assembly: SuppressMessage("Style", "IDE0057:Use range operator", Scope = "member", Target = "~M:CodeCoverageSummary.Program.SetThresholds(System.String)")] diff --git a/src/CodeCoverageSummary/Program.cs b/src/CodeCoverageSummary/Program.cs index 27b4c2b..bd801f2 100644 --- a/src/CodeCoverageSummary/Program.cs +++ b/src/CodeCoverageSummary/Program.cs @@ -9,6 +9,9 @@ namespace CodeCoverageSummary { internal static class Program { + private static double lowerThreshold = 0.5; + private static double upperThreshold = 0.75; + private static int Main(string[] args) { return Parser.Default.ParseArguments(args) @@ -32,6 +35,10 @@ namespace CodeCoverageSummary } else { + // set health badge thresholds + if (!string.IsNullOrWhiteSpace(o.Thresholds)) + SetThresholds(o.Thresholds); + // generate badge string badgeUrl = o.Badge ? GenerateBadge(summary) : null; @@ -158,14 +165,49 @@ namespace CodeCoverageSummary } } + private static void SetThresholds(string thresholds) + { + int lowerPercentage; + int upperPercentage = (int)(upperThreshold * 100); + int s = thresholds.IndexOf(" "); + if (s == 0) + { + throw new ArgumentException("Threshold parameter set incorrectly."); + } + else if (s < 0) + { + if (!int.TryParse(thresholds, out lowerPercentage)) + throw new ArgumentException("Threshold parameter set incorrectly."); + } + else + { + if (!int.TryParse(thresholds.Substring(0, s), out lowerPercentage)) + throw new ArgumentException("Threshold parameter set incorrectly."); + + if (!int.TryParse(thresholds.Substring(s + 1), out upperPercentage)) + throw new ArgumentException("Threshold parameter set incorrectly."); + } + lowerThreshold = lowerPercentage / 100.0; + upperThreshold = upperPercentage / 100.0; + + if (lowerThreshold > 1.0) + lowerThreshold = 1.0; + + if (lowerThreshold > upperThreshold) + upperThreshold = lowerThreshold + 0.1; + + if (upperThreshold > 1.0) + upperThreshold = 1.0; + } + private static string GenerateBadge(CodeSummary summary) { string colour; - if (summary.LineRate < 0.5) + if (summary.LineRate < lowerThreshold) { colour = "critical"; } - else if (summary.LineRate < 0.75) + else if (summary.LineRate < upperThreshold) { colour = "yellow"; } diff --git a/src/CodeCoverageSummary/Properties/launchSettings.json b/src/CodeCoverageSummary/Properties/launchSettings.json index 77ec29b..d4e9905 100644 --- a/src/CodeCoverageSummary/Properties/launchSettings.json +++ b/src/CodeCoverageSummary/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "CodeCoverageSummary": { "commandName": "Project", - "commandLineArgs": "../../../../coverage.gcovr.xml --format=md --badge=true" + "commandLineArgs": "../../../../coverage.cobertura.xml --format=md --badge=true --thresholds=\"80 90\"" }, "Docker": { "commandName": "Docker", From ecc89a90a8aee6526adb00cca45d642926b8a183 Mon Sep 17 00:00:00 2001 From: irongut Date: Mon, 18 Oct 2021 01:30:03 +0100 Subject: [PATCH 2/8] added Thresholds parameter to action definition #15 --- action.yml | 6 ++++++ src/CodeCoverageSummary/CommandLineOptions.cs | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index ad67fd2..1b4ef0a 100644 --- a/action.yml +++ b/action.yml @@ -20,6 +20,10 @@ inputs: description: 'Output Type - console (default), file or both.' required: false default: 'console' + thresholds: + description: 'Badge colour threshold percentages, default '50 75'.' + required: false + default: '50 75' runs: using: 'docker' image: 'docker://ghcr.io/irongut/codecoveragesummary:v1.0.5' @@ -31,3 +35,5 @@ runs: - ${{ inputs.format }} - '--output' - ${{ inputs.output }} + - '--thresholds' + - ${{ inputs.thresholds }} diff --git a/src/CodeCoverageSummary/CommandLineOptions.cs b/src/CodeCoverageSummary/CommandLineOptions.cs index 7a85b0f..6565df2 100644 --- a/src/CodeCoverageSummary/CommandLineOptions.cs +++ b/src/CodeCoverageSummary/CommandLineOptions.cs @@ -16,7 +16,7 @@ namespace CodeCoverageSummary [Option(longName: "output", Required = false, HelpText = "Output Type - console, file or both.", Default = "console")] public string Output { get; set; } - [Option(longName: "thresholds", Required = false, HelpText = "Badge colour thresholds.", Default = "50 75")] + [Option(longName: "thresholds", Required = false, HelpText = "Badge colour threshold percentages.", Default = "50 75")] public string Thresholds { get; set; } } } From 6ed1f6c50d142d492449f1d3907cd0578b8e06c2 Mon Sep 17 00:00:00 2001 From: irongut Date: Mon, 18 Oct 2021 23:26:42 +0100 Subject: [PATCH 3/8] added health indicators #14 --- src/CodeCoverageSummary/CommandLineOptions.cs | 3 + src/CodeCoverageSummary/Program.cs | 93 +++++++++---------- 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/src/CodeCoverageSummary/CommandLineOptions.cs b/src/CodeCoverageSummary/CommandLineOptions.cs index 6565df2..3301391 100644 --- a/src/CodeCoverageSummary/CommandLineOptions.cs +++ b/src/CodeCoverageSummary/CommandLineOptions.cs @@ -13,6 +13,9 @@ namespace CodeCoverageSummary [Option(longName: "format", Required = false, HelpText = "Output Format - markdown or text.", Default = "text")] public string Format { get; set; } + [Option(longName: "indicators", Required = false, HelpText = "Include package health indicators in the output - true or false.", Default = true)] + public bool Indicators { get; set; } + [Option(longName: "output", Required = false, HelpText = "Output Type - console, file or both.", Default = "console")] public string Output { get; set; } diff --git a/src/CodeCoverageSummary/Program.cs b/src/CodeCoverageSummary/Program.cs index bd801f2..89ad2c3 100644 --- a/src/CodeCoverageSummary/Program.cs +++ b/src/CodeCoverageSummary/Program.cs @@ -48,12 +48,12 @@ namespace CodeCoverageSummary if (o.Format.Equals("text", StringComparison.OrdinalIgnoreCase)) { fileExt = "txt"; - output = GenerateTextOutput(summary, badgeUrl); + output = GenerateTextOutput(summary, badgeUrl, o.Indicators); } else if (o.Format.Equals("md", StringComparison.OrdinalIgnoreCase) || o.Format.Equals("markdown", StringComparison.OrdinalIgnoreCase)) { fileExt = "md"; - output = GenerateMarkdownOutput(summary, badgeUrl); + output = GenerateMarkdownOutput(summary, badgeUrl, o.Indicators); } else { @@ -218,78 +218,75 @@ namespace CodeCoverageSummary return $"https://img.shields.io/badge/Code%20Coverage-{summary.LineRate * 100:N0}%25-{colour}?style=flat"; } - private static string GenerateTextOutput(CodeSummary summary, string badgeUrl) + private static string GenerateHealthIndicator(double rate) + { + if (rate < lowerThreshold) + { + return "❌"; + } + else if (rate < upperThreshold) + { + return "➖"; + } + else + { + return "✔"; + } + } + + private static string GenerateTextOutput(CodeSummary summary, string badgeUrl, bool indicators) { StringBuilder textOutput = new(); if (!string.IsNullOrWhiteSpace(badgeUrl)) { - textOutput.AppendLine(badgeUrl); - } - - 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}"); - - if (summary.Complexity % 1 == 0) - { - textOutput.AppendLine($"Complexity = {summary.Complexity}"); - } - else - { - textOutput.AppendLine($"Complexity = {summary.Complexity:N4}"); + textOutput.AppendLine(badgeUrl) + .AppendLine(); } foreach (CodeCoverage package in summary.Packages) { - 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}"); - } + textOutput.Append($"{package.Name}: Line Rate = {package.LineRate * 100:N0}%") + .Append($", Branch Rate = {package.BranchRate * 100:N0}%") + .Append((package.Complexity % 1 == 0) ? $", Complexity = {package.Complexity}" : $", Complexity = {package.Complexity:N4}") + .AppendLine(indicators ? $", {GenerateHealthIndicator(package.LineRate)}" : string.Empty); } + textOutput.Append($"Summary: Line Rate = {summary.LineRate * 100:N0}% ({summary.LinesCovered} / {summary.LinesValid})") + .Append($", Branch Rate = {summary.BranchRate * 100:N0}% ({summary.BranchesCovered} / {summary.BranchesValid})") + .Append((summary.Complexity % 1 == 0) ? $", Complexity = {summary.Complexity}" : $", Complexity = {summary.Complexity:N4}") + .AppendLine(indicators ? $", {GenerateHealthIndicator(summary.LineRate)}" : string.Empty); + return textOutput.ToString(); } - private static string GenerateMarkdownOutput(CodeSummary summary, string badgeUrl) + private static string GenerateMarkdownOutput(CodeSummary summary, string badgeUrl, bool indicators) { StringBuilder markdownOutput = new(); if (!string.IsNullOrWhiteSpace(badgeUrl)) { - markdownOutput.AppendLine($"![Code Coverage]({badgeUrl})"); - markdownOutput.AppendLine(""); + markdownOutput.AppendLine($"![Code Coverage]({badgeUrl})") + .AppendLine(); } - markdownOutput.AppendLine("Package | Line Rate | Branch Rate | Complexity") - .AppendLine("-------- | --------- | ----------- | ----------"); + markdownOutput.Append("Package | Line Rate | Branch Rate | Complexity") + .AppendLine(indicators ? " | Health" : string.Empty) + .Append("-------- | --------- | ----------- | ----------") + .AppendLine(indicators ? " | ------" : string.Empty); foreach (CodeCoverage package in summary.Packages) { - 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($"{package.Name} | {package.LineRate * 100:N0}%") + .Append($" | {package.BranchRate * 100:N0}%") + .Append((package.Complexity % 1 == 0) ? $" | {package.Complexity}" : $" | {package.Complexity:N4}" ) + .AppendLine(indicators ? $" | {GenerateHealthIndicator(package.LineRate)}" : string.Empty); } - markdownOutput.Append($"**Summary** | **{summary.LineRate * 100:N0}%** ({summary.LinesCovered} / {summary.LinesValid}) | ") - .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")); - } + markdownOutput.Append($"**Summary** | **{summary.LineRate * 100:N0}%** ({summary.LinesCovered} / {summary.LinesValid})") + .Append($" | **{summary.BranchRate * 100:N0}%** ({summary.BranchesCovered} / {summary.BranchesValid})") + .Append((summary.Complexity % 1 == 0) ? $" | {summary.Complexity}" : $" | {summary.Complexity:N4}") + .AppendLine(indicators ? $" | {GenerateHealthIndicator(summary.LineRate)}" : string.Empty); return markdownOutput.ToString(); } From 7c070aea386905d3c67473352a3d649d4e782222 Mon Sep 17 00:00:00 2001 From: irongut Date: Tue, 19 Oct 2021 00:03:22 +0100 Subject: [PATCH 4/8] fixed issue with bool parameters --- src/CodeCoverageSummary/CommandLineOptions.cs | 13 +++++++++---- .../Properties/launchSettings.json | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/CodeCoverageSummary/CommandLineOptions.cs b/src/CodeCoverageSummary/CommandLineOptions.cs index 3301391..156d73d 100644 --- a/src/CodeCoverageSummary/CommandLineOptions.cs +++ b/src/CodeCoverageSummary/CommandLineOptions.cs @@ -1,4 +1,5 @@ using CommandLine; +using System; namespace CodeCoverageSummary { @@ -7,14 +8,18 @@ namespace CodeCoverageSummary [Value(index: 0, Required = true, HelpText = "Code coverage file to analyse.")] public string Filename { get; set; } - [Option(longName: "badge", Required = false, HelpText = "Include a badge reporting the Line Rate coverage in the output using shields.io - true or false.", Default = false)] - public bool Badge { get; set; } + [Option(longName: "badge", Required = false, HelpText = "Include a badge reporting the Line Rate coverage in the output using shields.io - true or false.", Default = "false")] + public string BadgeString { get; set; } + + public bool Badge => BadgeString.Equals("true", StringComparison.OrdinalIgnoreCase); [Option(longName: "format", Required = false, HelpText = "Output Format - markdown or text.", Default = "text")] public string Format { get; set; } - [Option(longName: "indicators", Required = false, HelpText = "Include package health indicators in the output - true or false.", Default = true)] - public bool Indicators { get; set; } + [Option(longName: "indicators", Required = false, HelpText = "Include package health indicators in the output - true or false.", Default = "true")] + public string IndicatorsString { get; set; } + + public bool Indicators => IndicatorsString.Equals("true", StringComparison.OrdinalIgnoreCase); [Option(longName: "output", Required = false, HelpText = "Output Type - console, file or both.", Default = "console")] public string Output { get; set; } diff --git a/src/CodeCoverageSummary/Properties/launchSettings.json b/src/CodeCoverageSummary/Properties/launchSettings.json index d4e9905..583b9e3 100644 --- a/src/CodeCoverageSummary/Properties/launchSettings.json +++ b/src/CodeCoverageSummary/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "CodeCoverageSummary": { "commandName": "Project", - "commandLineArgs": "../../../../coverage.cobertura.xml --format=md --badge=true --thresholds=\"80 90\"" + "commandLineArgs": "../../../../coverage.cobertura.xml --format=md --badge true --thresholds=\"80 90\"" }, "Docker": { "commandName": "Docker", From d8b1bc5ef2b36ac0edd0bae9ecdada27c0707ae5 Mon Sep 17 00:00:00 2001 From: irongut Date: Tue, 19 Oct 2021 00:28:24 +0100 Subject: [PATCH 5/8] updated CLI help text --- src/CodeCoverageSummary/CommandLineOptions.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/CodeCoverageSummary/CommandLineOptions.cs b/src/CodeCoverageSummary/CommandLineOptions.cs index 156d73d..ca4c016 100644 --- a/src/CodeCoverageSummary/CommandLineOptions.cs +++ b/src/CodeCoverageSummary/CommandLineOptions.cs @@ -8,7 +8,7 @@ namespace CodeCoverageSummary [Value(index: 0, Required = true, HelpText = "Code coverage file to analyse.")] public string Filename { get; set; } - [Option(longName: "badge", Required = false, HelpText = "Include a badge reporting the Line Rate coverage in the output using shields.io - true or false.", Default = "false")] + [Option(longName: "badge", Required = false, HelpText = "Include a Line Rate coverage badge in the output using shields.io - true or false.", Default = "false")] public string BadgeString { get; set; } public bool Badge => BadgeString.Equals("true", StringComparison.OrdinalIgnoreCase); @@ -16,7 +16,7 @@ namespace CodeCoverageSummary [Option(longName: "format", Required = false, HelpText = "Output Format - markdown or text.", Default = "text")] public string Format { get; set; } - [Option(longName: "indicators", Required = false, HelpText = "Include package health indicators in the output - true or false.", Default = "true")] + [Option(longName: "indicators", Required = false, HelpText = "Include health indicators in the output - true or false.", Default = "true")] public string IndicatorsString { get; set; } public bool Indicators => IndicatorsString.Equals("true", StringComparison.OrdinalIgnoreCase); @@ -24,7 +24,7 @@ namespace CodeCoverageSummary [Option(longName: "output", Required = false, HelpText = "Output Type - console, file or both.", Default = "console")] public string Output { get; set; } - [Option(longName: "thresholds", Required = false, HelpText = "Badge colour threshold percentages.", Default = "50 75")] + [Option(longName: "thresholds", Required = false, HelpText = "Badge and health indicator threshold percentages.", Default = "50 75")] public string Thresholds { get; set; } } } From b97bc1147af55c4fdc12eee1ccb66240207fa5e0 Mon Sep 17 00:00:00 2001 From: irongut Date: Tue, 19 Oct 2021 00:29:37 +0100 Subject: [PATCH 6/8] added indicators parameter to action definition #14 --- action.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 1b4ef0a..d80c442 100644 --- a/action.yml +++ b/action.yml @@ -9,19 +9,23 @@ inputs: description: 'Code coverage file to analyse.' required: true badge: - description: 'Include a badge in the output - true / false (default).' + description: 'Include a Line Rate coverage badge in the output using shields.io - true / false (default).' required: false default: 'false' format: description: 'Output Format - markdown or text (default).' required: false default: 'text' + indicators: + description: 'Include health indicators in the output - true (default) / false.' + required: false + default: 'true' output: description: 'Output Type - console (default), file or both.' required: false default: 'console' thresholds: - description: 'Badge colour threshold percentages, default '50 75'.' + description: 'Badge and health indicator threshold percentages, default '50 75'.' required: false default: '50 75' runs: @@ -33,6 +37,8 @@ runs: - ${{ inputs.badge }} - '--format' - ${{ inputs.format }} + - '--indicators' + - ${{ inputs.indicators }} - '--output' - ${{ inputs.output }} - '--thresholds' From 02bb8246068e32719d0260ee2a4d09747545bbe2 Mon Sep 17 00:00:00 2001 From: irongut Date: Tue, 19 Oct 2021 23:49:51 +0100 Subject: [PATCH 7/8] added ability to fail a workflow #16 --- src/CodeCoverageSummary/CommandLineOptions.cs | 7 ++++++- src/CodeCoverageSummary/Program.cs | 10 ++++++++++ src/CodeCoverageSummary/Properties/launchSettings.json | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/CodeCoverageSummary/CommandLineOptions.cs b/src/CodeCoverageSummary/CommandLineOptions.cs index ca4c016..6ca33ec 100644 --- a/src/CodeCoverageSummary/CommandLineOptions.cs +++ b/src/CodeCoverageSummary/CommandLineOptions.cs @@ -13,6 +13,11 @@ namespace CodeCoverageSummary public bool Badge => BadgeString.Equals("true", StringComparison.OrdinalIgnoreCase); + [Option(longName: "fail", Required = false, HelpText = "Fail if overall Line Rate below lower threshold - true or false.", Default = "false")] + public string FailString { get; set; } + + public bool FailBelowThreshold => FailString.Equals("true", StringComparison.OrdinalIgnoreCase); + [Option(longName: "format", Required = false, HelpText = "Output Format - markdown or text.", Default = "text")] public string Format { get; set; } @@ -24,7 +29,7 @@ namespace CodeCoverageSummary [Option(longName: "output", Required = false, HelpText = "Output Type - console, file or both.", Default = "console")] public string Output { get; set; } - [Option(longName: "thresholds", Required = false, HelpText = "Badge and health indicator threshold percentages.", Default = "50 75")] + [Option(longName: "thresholds", Required = false, HelpText = "Threshold percentages for badge and health indicators, lower threshold can also be used to fail the action.", Default = "50 75")] public string Thresholds { get; set; } } } diff --git a/src/CodeCoverageSummary/Program.cs b/src/CodeCoverageSummary/Program.cs index 89ad2c3..ad0e30b 100644 --- a/src/CodeCoverageSummary/Program.cs +++ b/src/CodeCoverageSummary/Program.cs @@ -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 } } diff --git a/src/CodeCoverageSummary/Properties/launchSettings.json b/src/CodeCoverageSummary/Properties/launchSettings.json index 583b9e3..25f7867 100644 --- a/src/CodeCoverageSummary/Properties/launchSettings.json +++ b/src/CodeCoverageSummary/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "CodeCoverageSummary": { "commandName": "Project", - "commandLineArgs": "../../../../coverage.cobertura.xml --format=md --badge true --thresholds=\"80 90\"" + "commandLineArgs": "../../../../coverage.cobertura.xml --format=md --badge true --thresholds=\"85 90\" --fail true" }, "Docker": { "commandName": "Docker", From 2389c9883ac04ae4fa61a755169f779eb2d5e5c2 Mon Sep 17 00:00:00 2001 From: irongut Date: Wed, 20 Oct 2021 00:01:43 +0100 Subject: [PATCH 8/8] added fail_below_min to action definition #16 --- action.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index d80c442..9096f18 100644 --- a/action.yml +++ b/action.yml @@ -12,6 +12,10 @@ inputs: description: 'Include a Line Rate coverage badge in the output using shields.io - true / false (default).' required: false default: 'false' + fail_below_min: + description: 'Fail if overall Line Rate below lower threshold - true / false (default).' + required: false + default: 'false' format: description: 'Output Format - markdown or text (default).' required: false @@ -25,7 +29,7 @@ inputs: required: false default: 'console' thresholds: - description: 'Badge and health indicator threshold percentages, default '50 75'.' + description: 'Threshold percentages for badge and health indicators, lower threshold can also be used to fail the action.' required: false default: '50 75' runs: @@ -35,6 +39,8 @@ runs: - ${{ inputs.filename }} - '--badge' - ${{ inputs.badge }} + - '--fail' + - ${{ inputs.fail_below_min }} - '--format' - ${{ inputs.format }} - '--indicators'