From f023b944f11002596951da367d641753fc681a17 Mon Sep 17 00:00:00 2001 From: Karan Shah Date: Mon, 10 Oct 2022 13:36:33 +0530 Subject: [PATCH] Add support for coverage dir --- action.yml | 4 ++++ dist/main.js | 12 +++++------- src/comment.js | 10 +++------- src/index.js | 2 ++ 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/action.yml b/action.yml index 01ceb29d..685b7a41 100644 --- a/action.yml +++ b/action.yml @@ -38,6 +38,10 @@ inputs: description: String of files that have changed from base branch required: false default: "" + run_id: + description: Run id for the current action run + required: true + default: "-1" outputs: diff_coverage: description: (String - Number) The coverage of this branch (%) diff --git a/dist/main.js b/dist/main.js index f5874182..2a035f00 100644 --- a/dist/main.js +++ b/dist/main.js @@ -23017,16 +23017,12 @@ function diff(headLcov, baseLcov, diffLcov, options) { 2, )}%) does not meet coverage threshold (${pdiffCoverageThresholdStr}%)`; } + const coverage_dir_link = `[Coverage directory download page link (💡 Tip: Use this if comment is clipped)](https://github.com/interviewstreet/frontend-core/actions/runs/${options.run_id})`; return { fragment: fragment( - options.title ? h2(options.title) : title, - options.base - ? `Coverage after merging ${b(options.head)} into ${b( - options.base, - )} will be` - : `Coverage for this commit`, - // Link to download if message exceeds charcs + options.title ? h2(options.title) : h2(title), + span(coverage_dir_link), table( tbody( pdiffLcov @@ -23147,6 +23143,7 @@ async function main$1() { const title = core$1.getInput("title"); const diff_threshold = parseFloat(core$1.getInput("diff_threshold")) || 0; const files_changed = core$1.getInput("files_changed"); + const run_id = parseInt(core$1.getInput("run_id"), 10) || 0; const raw = await fs.promises.readFile(lcovFile, "utf-8").catch(err => null); if (!raw) { @@ -23165,6 +23162,7 @@ async function main$1() { prefix: normalisePath(`${process.env.GITHUB_WORKSPACE}/`), workingDir, diffCoverageThreshold: diff_threshold, + run_id, }; if ( diff --git a/src/comment.js b/src/comment.js index 0c96e1ef..f95d42b7 100644 --- a/src/comment.js +++ b/src/comment.js @@ -49,16 +49,12 @@ export function diff(headLcov, baseLcov, diffLcov, options) { 2, )}%) does not meet coverage threshold (${pdiffCoverageThresholdStr}%)` } + const coverage_dir_link = `[Coverage directory download page link (💡 Tip: Use this if comment is clipped)](https://github.com/interviewstreet/frontend-core/actions/runs/${options.run_id})` return { fragment: fragment( - options.title ? h2(options.title) : title, - options.base - ? `Coverage after merging ${b(options.head)} into ${b( - options.base, - )} will be` - : `Coverage for this commit`, - // Link to download if message exceeds charcs + options.title ? h2(options.title) : h2(title), + span(coverage_dir_link), table( tbody( pdiffLcov diff --git a/src/index.js b/src/index.js index d74bd3ee..85885133 100644 --- a/src/index.js +++ b/src/index.js @@ -27,6 +27,7 @@ async function main() { const title = core.getInput("title") const diff_threshold = parseFloat(core.getInput("diff_threshold")) || 0 const files_changed = core.getInput("files_changed") + const run_id = parseInt(core.getInput("run_id"), 10) || 0 const raw = await fs.readFile(lcovFile, "utf-8").catch(err => null) if (!raw) { @@ -45,6 +46,7 @@ async function main() { prefix: normalisePath(`${process.env.GITHUB_WORKSPACE}/`), workingDir, diffCoverageThreshold: diff_threshold, + run_id, } if (