Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added ability to only show files not meeting minimum coverage #129

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ Default is no crop.

(Note: "…" is appended to a cropped string)

### `show_minimum_coverage_files`

Show files that meet minimum coverage requirements
Defaults to `true`

### `link_missing_lines`

Link missing line numbers. This only has an effect when `show_missing` is set to `true`.
Expand Down
8 changes: 8 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38908,6 +38908,9 @@ async function action(payload) {
showMissingMaxLength = showMissingMaxLength
? parseInt(showMissingMaxLength)
: -1;
const showMinimumCoverageFiles = JSON.parse(
core.getInput("show_minimum_coverage_files", { required: false }) || "true",
);
const linkMissingLines = JSON.parse(
core.getInput("link_missing_lines", { required: false }) || "false",
);
Expand All @@ -38930,6 +38933,7 @@ async function action(payload) {
showClassNames,
showMissing,
showMissingMaxLength,
showMinimumCoverageFiles,
linkMissingLines,
linkMissingLinesSourceDir,
filteredFiles: changedFiles,
Expand Down Expand Up @@ -39024,6 +39028,7 @@ function markdownReport(reports, commit, options) {
showClassNames = false,
showMissing = false,
showMissingMaxLength = -1,
showMinimumCoverageFiles = true,
linkMissingLines = false,
linkMissingLinesSourceDir = null,
filteredFiles = null,
Expand All @@ -39042,6 +39047,9 @@ function markdownReport(reports, commit, options) {
const fileTotal = Math.floor(file.total);
const fileLines = Math.floor(file.line);
const fileBranch = Math.floor(file.branch);
if (!showMinimumCoverageFiles && fileTotal > minimumCoverage) {
continue;
}
files.push([
escapeMarkdown(showClassNames ? file.name : file.filename),
`\`${fileTotal}%\``,
Expand Down
8 changes: 8 additions & 0 deletions src/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ async function action(payload) {
showMissingMaxLength = showMissingMaxLength
? parseInt(showMissingMaxLength)
: -1;
const showMinimumCoverageFiles = JSON.parse(
core.getInput("show_minimum_coverage_files", { required: false }) || "true",
);
const linkMissingLines = JSON.parse(
core.getInput("link_missing_lines", { required: false }) || "false",
);
Expand All @@ -63,6 +66,7 @@ async function action(payload) {
showClassNames,
showMissing,
showMissingMaxLength,
showMinimumCoverageFiles,
linkMissingLines,
linkMissingLinesSourceDir,
filteredFiles: changedFiles,
Expand Down Expand Up @@ -157,6 +161,7 @@ function markdownReport(reports, commit, options) {
showClassNames = false,
showMissing = false,
showMissingMaxLength = -1,
showMinimumCoverageFiles = true,
linkMissingLines = false,
linkMissingLinesSourceDir = null,
filteredFiles = null,
Expand All @@ -175,6 +180,9 @@ function markdownReport(reports, commit, options) {
const fileTotal = Math.floor(file.total);
const fileLines = Math.floor(file.line);
const fileBranch = Math.floor(file.branch);
if (!showMinimumCoverageFiles && fileTotal > minimumCoverage) {
continue;
}
files.push([
escapeMarkdown(showClassNames ? file.name : file.filename),
`\`${fileTotal}%\``,
Expand Down
17 changes: 17 additions & 0 deletions src/action.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,23 @@ _Minimum allowed coverage is \`100%\`_

_Minimum allowed coverage is \`100%\`_

<p align="right">Generated by :monkey: cobertura-action against deadbeef </p>`);

expect(
markdownReport([dummyReport], commit, {
minimumCoverage: 76,
showMinimumCoverageFiles: false,
}),
).toBe(`<strong>${defaultReportName}</strong>

| File | Coverage | |
| - | :-: | :-: |
| **All files** | \`77%\` | :white_check_mark: |
| bar.py | \`75%\` | :x: |
| foo.py | \`75%\` | :x: |

_Minimum allowed coverage is \`76%\`_

<p align="right">Generated by :monkey: cobertura-action against deadbeef </p>`);
});

Expand Down