diff --git a/action.yml b/action.yml index 3c78d26b..2571292f 100644 --- a/action.yml +++ b/action.yml @@ -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 diff --git a/dist/index.js b/dist/index.js index 344f1211..27b60757 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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 }) ); @@ -15983,6 +15988,7 @@ async function action(payload) { showMissingMaxLength, filteredFiles: changedFiles, reportName, + onlySummary, }); await addComment(pullRequestNumber, comment, reportName); @@ -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:"; @@ -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 diff --git a/src/action.js b/src/action.js index bfb574cb..f6f17083 100644 --- a/src/action.js +++ b/src/action.js @@ -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 }) ); @@ -60,6 +65,7 @@ async function action(payload) { showMissingMaxLength, filteredFiles: changedFiles, reportName, + onlySummary, }); await addComment(pullRequestNumber, comment, reportName); @@ -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:"; @@ -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) { + files.push([ + escapeMarkdown(showClassNames ? file.name : file.filename), + `\`${fileTotal}%\``, + showLine ? `\`${fileLines}%\`` : undefined, + showBranch ? `\`${fileBranch}%\`` : undefined, + status(fileTotal), + showMissing ? (fileMissing ? `\`${fileMissing}\`` : " ") : undefined, + ]); + } } // Construct table diff --git a/src/action.test.js b/src/action.test.js index d4d8f30a..6cf68ebf 100644 --- a/src/action.test.js +++ b/src/action.test.js @@ -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"; @@ -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"; @@ -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"; @@ -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"; @@ -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"; @@ -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"; @@ -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"; @@ -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";