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

Add only_summary Input Option #49

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
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ inputs:
description: 'If files with 100% should be skipped from report.'
required: true
default: true
only_summary:
description: 'Show only the summary, no details per file.'
required: true
default: false
minimum_coverage:
description: 'Minimum allowed coverage percentage as an integer.'
required: true
Expand Down
27 changes: 18 additions & 9 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15942,7 +15942,12 @@ async function action(payload) {
const skipCovered = JSON.parse(
core.getInput("skip_covered", { required: true })
);
const showLine = JSON.parse(core.getInput("show_line", { required: true }));
const onlySummary = JSON.parse(
core.getInput("only_summary", { required: true })
);
const showLine = JSON.parse(
core.getInput("show_line", { required: true })
);
const showBranch = JSON.parse(
core.getInput("show_branch", { required: true })
);
Expand Down Expand Up @@ -15983,6 +15988,7 @@ async function action(payload) {
showMissingMaxLength,
filteredFiles: changedFiles,
reportName,
onlySummary,
});
await addComment(pullRequestNumber, comment, reportName);

Expand All @@ -16003,6 +16009,7 @@ function markdownReport(reports, commit, options) {
showMissingMaxLength = -1,
filteredFiles = null,
reportName = "Coverage Report",
onlySummary = false,
} = options || {};
const status = (total) =>
total >= minimumCoverage ? ":white_check_mark:" : ":x:";
Expand All @@ -16023,14 +16030,16 @@ function markdownReport(reports, commit, options) {
showMissingMaxLength > 0
? crop(file.missing, showMissingMaxLength)
: file.missing;
files.push([
escapeMarkdown(showClassNames ? file.name : file.filename),
`\`${fileTotal}%\``,
showLine ? `\`${fileLines}%\`` : undefined,
showBranch ? `\`${fileBranch}%\`` : undefined,
status(fileTotal),
showMissing ? (fileMissing ? `\`${fileMissing}\`` : " ") : undefined,
]);
if (false === onlySummary) {
files.push([
escapeMarkdown(showClassNames ? file.name : file.filename),
`\`${fileTotal}%\``,
showLine ? `\`${fileLines}%\`` : undefined,
showBranch ? `\`${fileBranch}%\`` : undefined,
status(fileTotal),
showMissing ? (fileMissing ? `\`${fileMissing}\`` : " ") : undefined,
]);
}
}

// Construct table
Expand Down
27 changes: 18 additions & 9 deletions src/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ async function action(payload) {
const skipCovered = JSON.parse(
core.getInput("skip_covered", { required: true })
);
const showLine = JSON.parse(core.getInput("show_line", { required: true }));
const onlySummary = JSON.parse(
core.getInput("only_summary", { required: true })
);
const showLine = JSON.parse(
core.getInput("show_line", { required: true })
);
const showBranch = JSON.parse(
core.getInput("show_branch", { required: true })
);
Expand Down Expand Up @@ -60,6 +65,7 @@ async function action(payload) {
showMissingMaxLength,
filteredFiles: changedFiles,
reportName,
onlySummary,
});
await addComment(pullRequestNumber, comment, reportName);

Expand All @@ -80,6 +86,7 @@ function markdownReport(reports, commit, options) {
showMissingMaxLength = -1,
filteredFiles = null,
reportName = "Coverage Report",
onlySummary = false,
} = options || {};
const status = (total) =>
total >= minimumCoverage ? ":white_check_mark:" : ":x:";
Expand All @@ -100,14 +107,16 @@ function markdownReport(reports, commit, options) {
showMissingMaxLength > 0
? crop(file.missing, showMissingMaxLength)
: file.missing;
files.push([
escapeMarkdown(showClassNames ? file.name : file.filename),
`\`${fileTotal}%\``,
showLine ? `\`${fileLines}%\`` : undefined,
showBranch ? `\`${fileBranch}%\`` : undefined,
status(fileTotal),
showMissing ? (fileMissing ? `\`${fileMissing}\`` : " ") : undefined,
]);
if (false === onlySummary) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add this check to the report.files.filter instead, like !onlySummary &&..

files.push([
escapeMarkdown(showClassNames ? file.name : file.filename),
`\`${fileTotal}%\``,
showLine ? `\`${fileLines}%\`` : undefined,
showBranch ? `\`${fileBranch}%\`` : undefined,
status(fileTotal),
showMissing ? (fileMissing ? `\`${fileMissing}\`` : " ") : undefined,
]);
}
}

// Construct table
Expand Down
8 changes: 8 additions & 0 deletions src/action.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ test("action", async () => {
const { action } = require("./action");
process.env["INPUT_PATH"] = "./src/fixtures/test-branch.xml";
process.env["INPUT_SKIP_COVERED"] = "true";
process.env["INPUT_ONLY_SUMMARY"] = "false";
process.env["INPUT_SHOW_BRANCH"] = "false";
process.env["INPUT_SHOW_LINE"] = "false";
process.env["INPUT_MINIMUM_COVERAGE"] = "100";
Expand All @@ -68,6 +69,7 @@ test("action triggered by workflow event", async () => {
const { action } = require("./action");
process.env["INPUT_PATH"] = "./src/fixtures/test-branch.xml";
process.env["INPUT_SKIP_COVERED"] = "true";
process.env["INPUT_ONLY_SUMMARY"] = "false";
process.env["INPUT_SHOW_BRANCH"] = "false";
process.env["INPUT_SHOW_LINE"] = "false";
process.env["INPUT_MINIMUM_COVERAGE"] = "100";
Expand Down Expand Up @@ -99,6 +101,7 @@ test("action passing pull request number directly", async () => {
const prNumber = 123;
process.env["INPUT_PATH"] = "./src/fixtures/test-branch.xml";
process.env["INPUT_SKIP_COVERED"] = "true";
process.env["INPUT_ONLY_SUMMARY"] = "false";
process.env["INPUT_SHOW_BRANCH"] = "false";
process.env["INPUT_SHOW_LINE"] = "false";
process.env["INPUT_MINIMUM_COVERAGE"] = "100";
Expand Down Expand Up @@ -126,6 +129,7 @@ test("action only changes", async () => {
const { action } = require("./action");
process.env["INPUT_PATH"] = "./src/fixtures/test-branch.xml";
process.env["INPUT_SKIP_COVERED"] = "true";
process.env["INPUT_ONLY_SUMMARY"] = "false";
process.env["INPUT_SHOW_BRANCH"] = "false";
process.env["INPUT_SHOW_LINE"] = "false";
process.env["INPUT_MINIMUM_COVERAGE"] = "100";
Expand Down Expand Up @@ -155,6 +159,7 @@ test("action with report name", async () => {
const { action } = require("./action");
process.env["INPUT_PATH"] = "./src/fixtures/test-branch.xml";
process.env["INPUT_SKIP_COVERED"] = "true";
process.env["INPUT_ONLY_SUMMARY"] = "false";
process.env["INPUT_SHOW_BRANCH"] = "false";
process.env["INPUT_SHOW_LINE"] = "false";
process.env["INPUT_MINIMUM_COVERAGE"] = "100";
Expand Down Expand Up @@ -184,6 +189,7 @@ test("action with crop missing lines", async () => {
const { action } = require("./action");
process.env["INPUT_PATH"] = "./src/fixtures/test-branch.xml";
process.env["INPUT_SKIP_COVERED"] = "true";
process.env["INPUT_ONLY_SUMMARY"] = "false";
process.env["INPUT_SHOW_BRANCH"] = "false";
process.env["INPUT_SHOW_LINE"] = "false";
process.env["INPUT_MINIMUM_COVERAGE"] = "100";
Expand All @@ -209,6 +215,7 @@ test("action failing on coverage below threshold", async () => {
const prNumber = 123;
process.env["INPUT_PATH"] = "./src/fixtures/test-branch.xml";
process.env["INPUT_SKIP_COVERED"] = "true";
process.env["INPUT_ONLY_SUMMARY"] = "false";
process.env["INPUT_SHOW_BRANCH"] = "false";
process.env["INPUT_SHOW_LINE"] = "false";
process.env["INPUT_MINIMUM_COVERAGE"] = "100";
Expand Down Expand Up @@ -243,6 +250,7 @@ test("action not failing on coverage above threshold", async () => {
const prNumber = 123;
process.env["INPUT_PATH"] = "./src/fixtures/test-branch.xml";
process.env["INPUT_SKIP_COVERED"] = "true";
process.env["INPUT_ONLY_SUMMARY"] = "false";
process.env["INPUT_SHOW_BRANCH"] = "false";
process.env["INPUT_SHOW_LINE"] = "false";
process.env["INPUT_MINIMUM_COVERAGE"] = "82";
Expand Down