diff --git a/README.md b/README.md
index fa9e761..3f9126d 100644
--- a/README.md
+++ b/README.md
@@ -93,6 +93,11 @@ Output Type - `console` (default), `file` or `both`.
Lower and upper threshold percentages for badge and health indicators, lower threshold can also be used to fail the action. Separate the values with a space and enclose them in quotes; default `'50 75'`.
+### `collapsible`
+
+Wrap the markdown table in collapsible ` ` tags - `true` or `false` (default).
+
+
## Outputs
### Text Example
@@ -118,6 +123,23 @@ Minimum allowed line rate is 50%
>
> _Minimum allowed line rate is `50%`_
+### Collapsible Markdown Example
+
+> 
+>
+>
+> Code Coverage Summary
+>
+> Package | Line Rate | Branch Rate | Complexity | Health
+> -------- | --------- | ----------- | ---------- | ------
+> Company.Example | 83% | 69% | 671 | ✔
+> Company.Example.Library | 27% | 100% | 11 | ❌
+> **Summary** | **83%** (1212 / 1460) | **69%** (262 / 378) | 682 | ✔
+>
+>
+>
+> _Minimum allowed line rate is `50%`_
+
## Usage
@@ -174,6 +196,7 @@ jobs:
indicators: true
output: both
thresholds: '60 80'
+ collapsible: true
- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
diff --git a/action.yml b/action.yml
index bb3ee76..51a5198 100644
--- a/action.yml
+++ b/action.yml
@@ -40,6 +40,10 @@ inputs:
description: 'Threshold percentages for badge and health indicators, lower threshold can also be used to fail the action.'
required: false
default: '50 75'
+ collapsible:
+ description: 'Wrap the markdown table in collapsible details tags - true / false (default).'
+ required: false
+ default: 'false'
runs:
using: 'docker'
image: 'docker://ghcr.io/irongut/codecoveragesummary:v1.3.0'
@@ -62,3 +66,5 @@ runs:
- ${{ inputs.output }}
- '--thresholds'
- ${{ inputs.thresholds }}
+ - '--collapsible'
+ - ${{ inputs.collapsible }}
diff --git a/src/CodeCoverageSummary/CommandLineOptions.cs b/src/CodeCoverageSummary/CommandLineOptions.cs
index f525a9f..a02eb81 100644
--- a/src/CodeCoverageSummary/CommandLineOptions.cs
+++ b/src/CodeCoverageSummary/CommandLineOptions.cs
@@ -42,5 +42,10 @@ public class CommandLineOptions
[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; }
+
+ [Option(longName: "collapsible", Required = false, HelpText = "Wrap the markdown table in collapsible details tags - true or false.", Default = "false")]
+ public string CollapsibleString { get; set; }
+
+ public bool Collapsible => CollapsibleString.Equals("true", StringComparison.OrdinalIgnoreCase);
}
}
diff --git a/src/CodeCoverageSummary/Program.cs b/src/CodeCoverageSummary/Program.cs
index f0cc63f..28a497e 100644
--- a/src/CodeCoverageSummary/Program.cs
+++ b/src/CodeCoverageSummary/Program.cs
@@ -88,7 +88,7 @@ private static int Main(string[] args)
else if (o.Format.Equals("md", StringComparison.OrdinalIgnoreCase) || o.Format.Equals("markdown", StringComparison.OrdinalIgnoreCase))
{
fileExt = "md";
- output = GenerateMarkdownOutput(summary, badgeUrl, o.Indicators, hideBranchRate, o.HideComplexity);
+ output = GenerateMarkdownOutput(summary, badgeUrl, o.Indicators, hideBranchRate, o.HideComplexity, o.Collapsible);
if (o.FailBelowThreshold)
output += $"{Environment.NewLine}_Minimum allowed line rate is `{lowerThreshold * 100:N0}%`_{Environment.NewLine}";
}
@@ -329,7 +329,7 @@ private static string GenerateTextOutput(CodeSummary summary, string badgeUrl, b
return textOutput.ToString();
}
- private static string GenerateMarkdownOutput(CodeSummary summary, string badgeUrl, bool indicators, bool hideBranchRate, bool hideComplexity)
+ private static string GenerateMarkdownOutput(CodeSummary summary, string badgeUrl, bool indicators, bool hideBranchRate, bool hideComplexity, bool collapsible)
{
StringBuilder markdownOutput = new();
@@ -339,6 +339,13 @@ private static string GenerateMarkdownOutput(CodeSummary summary, string badgeUr
.AppendLine();
}
+ if (collapsible)
+ {
+ markdownOutput.AppendLine("")
+ .AppendLine("Expand for details
")
+ .AppendLine();
+ }
+
markdownOutput.Append("Package | Line Rate")
.Append(hideBranchRate ? string.Empty : " | Branch Rate")
.Append(hideComplexity ? string.Empty : " | Complexity")
@@ -361,6 +368,12 @@ private static string GenerateMarkdownOutput(CodeSummary summary, string badgeUr
.Append(hideComplexity ? string.Empty : (summary.Complexity % 1 == 0) ? $" | **{summary.Complexity}**" : $" | **{summary.Complexity:N4}**")
.AppendLine(indicators ? $" | {GenerateHealthIndicator(summary.LineRate)}" : string.Empty);
+ if (collapsible)
+ {
+ markdownOutput.AppendLine()
+ .AppendLine(" ");
+ }
+
return markdownOutput.ToString();
}
}