From a9b887bafac030f2c3ed45de8e9f1921486ffac5 Mon Sep 17 00:00:00 2001 From: marinakalyuzhnaya Date: Thu, 17 Dec 2020 14:18:22 +0100 Subject: [PATCH 01/13] added colors --- src/comment.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/comment.js b/src/comment.js index 8a43ce72..ac3c5f28 100644 --- a/src/comment.js +++ b/src/comment.js @@ -24,9 +24,15 @@ export function commentForMonorepo( const plus = pdiff > 0 ? "+" : ""; const arrow = pdiff === 0 ? "" : pdiff < 0 ? "▾" : "▴"; - const pdiffHtml = baseLcov - ? th(arrow, " ", plus, pdiff.toFixed(2), "%") - : ""; + const getColor = () => { + if (pdiff === 0) return 'inherit'; + if (pdiff < 0) return 'red'; + if (pdiff > 0) return 'green'; + }; + + const diffTh = `
${th(arrow, " ", plus, pdiff.toFixed(2), "%")}
`; + + const pdiffHtml = baseLcov ? diffTh : ""; return `${table( tbody( From d6d387f469679d63810089c73686db7530b3bbe6 Mon Sep 17 00:00:00 2001 From: marinakalyuzhnaya Date: Thu, 17 Dec 2020 14:28:41 +0100 Subject: [PATCH 02/13] build --- dist/main.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/dist/main.js b/dist/main.js index a1cd21b6..0e3fd569 100644 --- a/dist/main.js +++ b/dist/main.js @@ -6046,9 +6046,15 @@ function commentForMonorepo( const plus = pdiff > 0 ? "+" : ""; const arrow = pdiff === 0 ? "" : pdiff < 0 ? "▾" : "▴"; - const pdiffHtml = baseLcov - ? th(arrow, " ", plus, pdiff.toFixed(2), "%") - : ""; + const getColor = () => { + if (pdiff === 0) return 'inherit'; + if (pdiff < 0) return 'red'; + if (pdiff > 0) return 'green'; + }; + + const diffTh = `
${th(arrow, " ", plus, pdiff.toFixed(2), "%")}
`; + + const pdiffHtml = baseLcov ? diffTh : ""; return `${table( tbody( From 6b57d13056518d0c17c2c22876d56bdfcd76590a Mon Sep 17 00:00:00 2001 From: marinakalyuzhnaya Date: Thu, 17 Dec 2020 14:32:06 +0100 Subject: [PATCH 03/13] added emojies --- dist/main.js | 53 ++++++++++++++++++++++++++++++++++++++------------ src/comment.js | 51 +++++++++++++++++++++++++++++++++++++----------- src/index.js | 2 +- 3 files changed, 82 insertions(+), 24 deletions(-) diff --git a/dist/main.js b/dist/main.js index 0e3fd569..3e5dca8c 100644 --- a/dist/main.js +++ b/dist/main.js @@ -6024,6 +6024,28 @@ function uncovered(file, options) { .join(", "); } +/** + * Compares two arrays of objects and returns with unique lines update + * @param {number} pdiff value from diff percentage + * @returns {string} emoji string for negative/positive pdiff + */ +const renderEmoji = pdiff => { + if (pdiff < 0) return "🔴"; + if (pdiff >= 0) return "🟢"; +}; + +/** + * Compares two arrays of objects and returns with unique lines update + * @param {Array} otherArray + * @returns {Function} function with filtering non original lines + */ +const comparer = otherArray => current => + otherArray.filter( + other => + other.lines.found === current.lines.found && + other.lines.hit === current.lines.hit, + ).length === 0; + /** * Github comment for monorepo * @param {Array<{packageName, lcovPath}>} lcovArrayForMonorepo @@ -6046,15 +6068,14 @@ function commentForMonorepo( const plus = pdiff > 0 ? "+" : ""; const arrow = pdiff === 0 ? "" : pdiff < 0 ? "▾" : "▴"; - const getColor = () => { - if (pdiff === 0) return 'inherit'; - if (pdiff < 0) return 'red'; - if (pdiff > 0) return 'green'; - }; - - const diffTh = `
${th(arrow, " ", plus, pdiff.toFixed(2), "%")}
`; + const pdiffHtml = baseLcov ? th(renderEmoji(pdiff), " ", arrow, " ", plus, pdiff.toFixed(2), "%") : ""; + let report = lcovObj.lcov; - const pdiffHtml = baseLcov ? diffTh : ""; + if (baseLcov) { + const onlyInLcov = lcovObj.lcov.filter(comparer(baseLcov)); + const onlyInBefore = baseLcov.filter(comparer(lcovObj.lcov)); + report = onlyInBefore.concat(onlyInLcov); + } return `${table( tbody( @@ -6066,7 +6087,7 @@ function commentForMonorepo( ), )} \n\n ${details( summary("Coverage Report"), - tabulate(lcovObj.lcov, options), + tabulate(report, options), )}
`; }); @@ -6088,7 +6109,15 @@ function comment(lcov, before, options) { const plus = pdiff > 0 ? "+" : ""; const arrow = pdiff === 0 ? "" : pdiff < 0 ? "▾" : "▴"; - const pdiffHtml = before ? th(arrow, " ", plus, pdiff.toFixed(2), "%") : ""; + const pdiffHtml = before ? th(renderEmoji(pdiff), " ", arrow, " ", plus, pdiff.toFixed(2), "%") : ""; + + let report = lcov; + + if (before) { + const onlyInLcov = lcov.filter(comparer(before)); + const onlyInBefore = before.filter(comparer(lcov)); + report = onlyInBefore.concat(onlyInLcov); + } return fragment( `Coverage after merging ${b(options.head)} into ${b( @@ -6096,7 +6125,7 @@ function comment(lcov, before, options) { )}

`, table(tbody(tr(th(percentage(lcov).toFixed(2), "%"), pdiffHtml))), "\n\n", - details(summary("Coverage Report"), tabulate(lcov, options)), + details(summary("Coverage Report"), tabulate(report, options)), ); } @@ -6314,7 +6343,7 @@ async function main() { commit: context.payload.pull_request.head.sha, prefix: `${process.env.GITHUB_WORKSPACE}/`, head: context.payload.pull_request.head.ref, - base: context.payload.pull_request.base.ref, + base: context.payload.pull_request.base.ref }; const lcov = !monorepoBasePath && (await parse$1(raw)); diff --git a/src/comment.js b/src/comment.js index 39421428..8fd6f164 100644 --- a/src/comment.js +++ b/src/comment.js @@ -2,6 +2,28 @@ import { details, summary, b, fragment, table, tbody, tr, th } from "./html"; import { percentage } from "./lcov"; import { tabulate } from "./tabulate"; +/** + * Compares two arrays of objects and returns with unique lines update + * @param {number} pdiff value from diff percentage + * @returns {string} emoji string for negative/positive pdiff + */ +const renderEmoji = pdiff => { + if (pdiff < 0) return "🔴"; + if (pdiff >= 0) return "🟢"; +}; + +/** + * Compares two arrays of objects and returns with unique lines update + * @param {Array} otherArray + * @returns {Function} function with filtering non original lines + */ +const comparer = otherArray => current => + otherArray.filter( + other => + other.lines.found === current.lines.found && + other.lines.hit === current.lines.hit, + ).length === 0; + /** * Github comment for monorepo * @param {Array<{packageName, lcovPath}>} lcovArrayForMonorepo @@ -24,15 +46,14 @@ export function commentForMonorepo( const plus = pdiff > 0 ? "+" : ""; const arrow = pdiff === 0 ? "" : pdiff < 0 ? "▾" : "▴"; - const getColor = () => { - if (pdiff === 0) return 'inherit'; - if (pdiff < 0) return 'red'; - if (pdiff > 0) return 'green'; - }; - - const diffTh = `
${th(arrow, " ", plus, pdiff.toFixed(2), "%")}
`; + const pdiffHtml = baseLcov ? th(renderEmoji(pdiff), " ", arrow, " ", plus, pdiff.toFixed(2), "%") : ""; + let report = lcovObj.lcov; - const pdiffHtml = baseLcov ? diffTh : ""; + if (baseLcov) { + const onlyInLcov = lcovObj.lcov.filter(comparer(baseLcov)); + const onlyInBefore = baseLcov.filter(comparer(lcovObj.lcov)); + report = onlyInBefore.concat(onlyInLcov); + } return `${table( tbody( @@ -44,7 +65,7 @@ export function commentForMonorepo( ), )} \n\n ${details( summary("Coverage Report"), - tabulate(lcovObj.lcov, options), + tabulate(report, options), )}
`; }); @@ -66,7 +87,15 @@ export function comment(lcov, before, options) { const plus = pdiff > 0 ? "+" : ""; const arrow = pdiff === 0 ? "" : pdiff < 0 ? "▾" : "▴"; - const pdiffHtml = before ? th(arrow, " ", plus, pdiff.toFixed(2), "%") : ""; + const pdiffHtml = before ? th(renderEmoji(pdiff), " ", arrow, " ", plus, pdiff.toFixed(2), "%") : ""; + + let report = lcov; + + if (before) { + const onlyInLcov = lcov.filter(comparer(before)); + const onlyInBefore = before.filter(comparer(lcov)); + report = onlyInBefore.concat(onlyInLcov); + } return fragment( `Coverage after merging ${b(options.head)} into ${b( @@ -74,7 +103,7 @@ export function comment(lcov, before, options) { )}

`, table(tbody(tr(th(percentage(lcov).toFixed(2), "%"), pdiffHtml))), "\n\n", - details(summary("Coverage Report"), tabulate(lcov, options)), + details(summary("Coverage Report"), tabulate(report, options)), ); } diff --git a/src/index.js b/src/index.js index 6e1cc294..117831a3 100644 --- a/src/index.js +++ b/src/index.js @@ -108,7 +108,7 @@ async function main() { commit: context.payload.pull_request.head.sha, prefix: `${process.env.GITHUB_WORKSPACE}/`, head: context.payload.pull_request.head.ref, - base: context.payload.pull_request.base.ref, + base: context.payload.pull_request.base.ref }; const lcov = !monorepoBasePath && (await parse(raw)); From 18dc3850666675ba79b25968769ac913df232274 Mon Sep 17 00:00:00 2001 From: marinakalyuzhnaya Date: Fri, 5 Feb 2021 14:30:56 +0100 Subject: [PATCH 04/13] added app name --- action.yml | 3 +++ dist/main.js | 19 +++++++++++-------- src/comment.js | 15 ++++++++------- src/index.js | 4 +++- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/action.yml b/action.yml index 963c3d36..d3e7f3ee 100644 --- a/action.yml +++ b/action.yml @@ -17,6 +17,9 @@ inputs: lcov-base: description: The location of the lcov file for the base branch. Applicable for single repo setup. required: false + app-name: + description: The concrete app name to dispaly on comment + required: false runs: using: node12 main: dist/main.js diff --git a/dist/main.js b/dist/main.js index 3e5dca8c..62cf1c96 100644 --- a/dist/main.js +++ b/dist/main.js @@ -6057,6 +6057,7 @@ function commentForMonorepo( lcovBaseArrayForMonorepo, options, ) { + const { appName, base } = options; const html = lcovArrayForMonorepo.map(lcovObj => { const baseLcov = lcovBaseArrayForMonorepo.find( el => el.packageName === lcovObj.packageName, @@ -6091,10 +6092,9 @@ function commentForMonorepo( )}
`; }); - return fragment( - `Coverage after merging into ${b(options.base)}

`, - html.join(""), - ); + const title = appName ? `Coverage after merging ${appName} into ${b(base)}

` : `Coverage after merging into ${b(base)}

`; + + return fragment(title, html.join("")); } /** @@ -6103,6 +6103,7 @@ function commentForMonorepo( * @param {*} options */ function comment(lcov, before, options) { + const { appName, base } = options; const pbefore = before ? percentage(before) : 0; const pafter = before ? percentage(lcov) : 0; const pdiff = pafter - pbefore; @@ -6119,10 +6120,10 @@ function comment(lcov, before, options) { report = onlyInBefore.concat(onlyInLcov); } + const title = appName ? `Coverage after merging ${appName} into ${b(base)}

` : `Coverage after merging into ${b(base)}

`; + return fragment( - `Coverage after merging ${b(options.head)} into ${b( - options.base, - )}

`, + title, table(tbody(tr(th(percentage(lcov).toFixed(2), "%"), pdiffHtml))), "\n\n", details(summary("Coverage Report"), tabulate(report, options)), @@ -6291,6 +6292,7 @@ async function main() { const token = core$1.getInput("github-token"); const lcovFile = core$1.getInput("lcov-file") || "./coverage/lcov.info"; const baseFile = core$1.getInput("lcov-base"); + const appName = core$1.getInput("app-name"); // Add base path for monorepo const monorepoBasePath = core$1.getInput("monorepo-base-path"); @@ -6343,7 +6345,8 @@ async function main() { commit: context.payload.pull_request.head.sha, prefix: `${process.env.GITHUB_WORKSPACE}/`, head: context.payload.pull_request.head.ref, - base: context.payload.pull_request.base.ref + base: context.payload.pull_request.base.ref, + appName, }; const lcov = !monorepoBasePath && (await parse$1(raw)); diff --git a/src/comment.js b/src/comment.js index 8fd6f164..fbfa65d7 100644 --- a/src/comment.js +++ b/src/comment.js @@ -35,6 +35,7 @@ export function commentForMonorepo( lcovBaseArrayForMonorepo, options, ) { + const { appName, base } = options; const html = lcovArrayForMonorepo.map(lcovObj => { const baseLcov = lcovBaseArrayForMonorepo.find( el => el.packageName === lcovObj.packageName, @@ -69,10 +70,9 @@ export function commentForMonorepo( )}
`; }); - return fragment( - `Coverage after merging into ${b(options.base)}

`, - html.join(""), - ); + const title = appName ? `Coverage after merging ${appName} into ${b(base)}

` : `Coverage after merging into ${b(base)}

`; + + return fragment(title, html.join("")); } /** @@ -81,6 +81,7 @@ export function commentForMonorepo( * @param {*} options */ export function comment(lcov, before, options) { + const { appName, base } = options; const pbefore = before ? percentage(before) : 0; const pafter = before ? percentage(lcov) : 0; const pdiff = pafter - pbefore; @@ -97,10 +98,10 @@ export function comment(lcov, before, options) { report = onlyInBefore.concat(onlyInLcov); } + const title = appName ? `Coverage after merging ${appName} into ${b(base)}

` : `Coverage after merging into ${b(base)}

`; + return fragment( - `Coverage after merging ${b(options.head)} into ${b( - options.base, - )}

`, + title, table(tbody(tr(th(percentage(lcov).toFixed(2), "%"), pdiffHtml))), "\n\n", details(summary("Coverage Report"), tabulate(report, options)), diff --git a/src/index.js b/src/index.js index 117831a3..27bc23d7 100644 --- a/src/index.js +++ b/src/index.js @@ -56,6 +56,7 @@ async function main() { const token = core.getInput("github-token"); const lcovFile = core.getInput("lcov-file") || "./coverage/lcov.info"; const baseFile = core.getInput("lcov-base"); + const appName = core.getInput("app-name"); // Add base path for monorepo const monorepoBasePath = core.getInput("monorepo-base-path"); @@ -108,7 +109,8 @@ async function main() { commit: context.payload.pull_request.head.sha, prefix: `${process.env.GITHUB_WORKSPACE}/`, head: context.payload.pull_request.head.ref, - base: context.payload.pull_request.base.ref + base: context.payload.pull_request.base.ref, + appName, }; const lcov = !monorepoBasePath && (await parse(raw)); From 69546b585be6d01137887c9d20b28cdf8a4b1610 Mon Sep 17 00:00:00 2001 From: marinakalyuzhnaya Date: Fri, 5 Feb 2021 14:47:57 +0100 Subject: [PATCH 05/13] added app name to header --- dist/main.js | 3 ++- src/comment.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dist/main.js b/dist/main.js index 62cf1c96..3a5d358c 100644 --- a/dist/main.js +++ b/dist/main.js @@ -6121,10 +6121,11 @@ function comment(lcov, before, options) { } const title = appName ? `Coverage after merging ${appName} into ${b(base)}

` : `Coverage after merging into ${b(base)}

`; + const header = appName ? tbody(tr(th(appName, percentage(lcov).toFixed(2), '%'), pdiffHtml)) : tbody(tr(th(percentage(lcov).toFixed(2), '%'), pdiffHtml)); return fragment( title, - table(tbody(tr(th(percentage(lcov).toFixed(2), "%"), pdiffHtml))), + table(header), "\n\n", details(summary("Coverage Report"), tabulate(report, options)), ); diff --git a/src/comment.js b/src/comment.js index fbfa65d7..7fdb8ec5 100644 --- a/src/comment.js +++ b/src/comment.js @@ -99,10 +99,11 @@ export function comment(lcov, before, options) { } const title = appName ? `Coverage after merging ${appName} into ${b(base)}

` : `Coverage after merging into ${b(base)}

`; + const header = appName ? tbody(tr(th(appName, percentage(lcov).toFixed(2), '%'), pdiffHtml)) : tbody(tr(th(percentage(lcov).toFixed(2), '%'), pdiffHtml)); return fragment( title, - table(tbody(tr(th(percentage(lcov).toFixed(2), "%"), pdiffHtml))), + table(header), "\n\n", details(summary("Coverage Report"), tabulate(report, options)), ); From 55f1c47e0e9a4beae5d08ee36e39f16561c8c865 Mon Sep 17 00:00:00 2001 From: marinakalyuzhnaya Date: Fri, 5 Feb 2021 14:55:13 +0100 Subject: [PATCH 06/13] added app name to header added th --- dist/main.js | 2 +- src/comment.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/main.js b/dist/main.js index 3a5d358c..ac20adb5 100644 --- a/dist/main.js +++ b/dist/main.js @@ -6121,7 +6121,7 @@ function comment(lcov, before, options) { } const title = appName ? `Coverage after merging ${appName} into ${b(base)}

` : `Coverage after merging into ${b(base)}

`; - const header = appName ? tbody(tr(th(appName, percentage(lcov).toFixed(2), '%'), pdiffHtml)) : tbody(tr(th(percentage(lcov).toFixed(2), '%'), pdiffHtml)); + const header = appName ? tbody(tr(th(appName), th(percentage(lcov).toFixed(2), '%'), pdiffHtml)) : tbody(tr(th(percentage(lcov).toFixed(2), '%'), pdiffHtml)); return fragment( title, diff --git a/src/comment.js b/src/comment.js index 7fdb8ec5..55dc5af2 100644 --- a/src/comment.js +++ b/src/comment.js @@ -99,7 +99,7 @@ export function comment(lcov, before, options) { } const title = appName ? `Coverage after merging ${appName} into ${b(base)}

` : `Coverage after merging into ${b(base)}

`; - const header = appName ? tbody(tr(th(appName, percentage(lcov).toFixed(2), '%'), pdiffHtml)) : tbody(tr(th(percentage(lcov).toFixed(2), '%'), pdiffHtml)); + const header = appName ? tbody(tr(th(appName), th(percentage(lcov).toFixed(2), '%'), pdiffHtml)) : tbody(tr(th(percentage(lcov).toFixed(2), '%'), pdiffHtml)); return fragment( title, From db440388a792e163a430d48cc66d2857cdc048c8 Mon Sep 17 00:00:00 2001 From: marinakalyuzhnaya Date: Fri, 5 Feb 2021 14:56:27 +0100 Subject: [PATCH 07/13] clean-up --- dist/main.js | 6 +++--- src/comment.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dist/main.js b/dist/main.js index ac20adb5..d000af1e 100644 --- a/dist/main.js +++ b/dist/main.js @@ -6057,7 +6057,7 @@ function commentForMonorepo( lcovBaseArrayForMonorepo, options, ) { - const { appName, base } = options; + const { base } = options; const html = lcovArrayForMonorepo.map(lcovObj => { const baseLcov = lcovBaseArrayForMonorepo.find( el => el.packageName === lcovObj.packageName, @@ -6092,7 +6092,7 @@ function commentForMonorepo( )}
`; }); - const title = appName ? `Coverage after merging ${appName} into ${b(base)}

` : `Coverage after merging into ${b(base)}

`; + const title = `Coverage after merging into ${b(base)}

`; return fragment(title, html.join("")); } @@ -6120,7 +6120,7 @@ function comment(lcov, before, options) { report = onlyInBefore.concat(onlyInLcov); } - const title = appName ? `Coverage after merging ${appName} into ${b(base)}

` : `Coverage after merging into ${b(base)}

`; + const title = `Coverage after merging into ${b(base)}

`; const header = appName ? tbody(tr(th(appName), th(percentage(lcov).toFixed(2), '%'), pdiffHtml)) : tbody(tr(th(percentage(lcov).toFixed(2), '%'), pdiffHtml)); return fragment( diff --git a/src/comment.js b/src/comment.js index 55dc5af2..1ed11819 100644 --- a/src/comment.js +++ b/src/comment.js @@ -35,7 +35,7 @@ export function commentForMonorepo( lcovBaseArrayForMonorepo, options, ) { - const { appName, base } = options; + const { base } = options; const html = lcovArrayForMonorepo.map(lcovObj => { const baseLcov = lcovBaseArrayForMonorepo.find( el => el.packageName === lcovObj.packageName, @@ -70,7 +70,7 @@ export function commentForMonorepo( )}
`; }); - const title = appName ? `Coverage after merging ${appName} into ${b(base)}

` : `Coverage after merging into ${b(base)}

`; + const title = `Coverage after merging into ${b(base)}

`; return fragment(title, html.join("")); } @@ -98,7 +98,7 @@ export function comment(lcov, before, options) { report = onlyInBefore.concat(onlyInLcov); } - const title = appName ? `Coverage after merging ${appName} into ${b(base)}

` : `Coverage after merging into ${b(base)}

`; + const title = `Coverage after merging into ${b(base)}

`; const header = appName ? tbody(tr(th(appName), th(percentage(lcov).toFixed(2), '%'), pdiffHtml)) : tbody(tr(th(percentage(lcov).toFixed(2), '%'), pdiffHtml)); return fragment( From 0425f424e497d39a8edb52b3baffe5b9d90a3510 Mon Sep 17 00:00:00 2001 From: marinakalyuzhnaya Date: Fri, 5 Feb 2021 15:11:55 +0100 Subject: [PATCH 08/13] extended hiddenHeader --- dist/main.js | 9 +++++---- src/github.js | 8 ++++---- src/index.js | 1 + 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/dist/main.js b/dist/main.js index d000af1e..950c047c 100644 --- a/dist/main.js +++ b/dist/main.js @@ -6172,11 +6172,10 @@ function diffForMonorepo( // Every comment written by our action will have this hidden // header on top, and will be used to identify which comments // to update/delete etc -const hiddenHeader = ``; -const appendHiddenHeaderToComment = body => hiddenHeader + body; +const appendHiddenHeaderToComment = (body, hiddenHeader) => hiddenHeader + body; -const listComments = async ({ client, context, prNumber, commentHeader }) => { +const listComments = async ({ client, context, prNumber, commentHeader, hiddenHeader }) => { const { data: existingComments } = await client.issues.listComments({ ...context.repo, issue_number: prNumber, @@ -6209,11 +6208,12 @@ const deleteComments = async ({ client, context, comments }) => ), ); -const upsertComment = async ({ client, context, prNumber, body }) => { +const upsertComment = async ({ client, context, prNumber, body, hiddenHeader }) => { const existingComments = await listComments({ client, context, prNumber, + hiddenHeader, }); const last = existingComments.pop(); @@ -6366,6 +6366,7 @@ async function main() { lcovBaseArrayForMonorepo, options, ), + hiddenHeader: appName ? `` : `` }); } diff --git a/src/github.js b/src/github.js index 0783802a..e427ee68 100644 --- a/src/github.js +++ b/src/github.js @@ -11,11 +11,10 @@ // Every comment written by our action will have this hidden // header on top, and will be used to identify which comments // to update/delete etc -const hiddenHeader = ``; -const appendHiddenHeaderToComment = body => hiddenHeader + body; +const appendHiddenHeaderToComment = (body, hiddenHeader) => hiddenHeader + body; -const listComments = async ({ client, context, prNumber, commentHeader }) => { +const listComments = async ({ client, context, prNumber, commentHeader, hiddenHeader }) => { const { data: existingComments } = await client.issues.listComments({ ...context.repo, issue_number: prNumber, @@ -48,11 +47,12 @@ const deleteComments = async ({ client, context, comments }) => ), ); -const upsertComment = async ({ client, context, prNumber, body }) => { +const upsertComment = async ({ client, context, prNumber, body, hiddenHeader }) => { const existingComments = await listComments({ client, context, prNumber, + hiddenHeader, }); const last = existingComments.pop(); diff --git a/src/index.js b/src/index.js index 27bc23d7..96fefff0 100644 --- a/src/index.js +++ b/src/index.js @@ -129,6 +129,7 @@ async function main() { lcovBaseArrayForMonorepo, options, ), + hiddenHeader: appName ? `` : `` }); } From 3c491b62382561b4bc9f958d0f23563214df7122 Mon Sep 17 00:00:00 2001 From: marinakalyuzhnaya Date: Fri, 5 Feb 2021 15:13:53 +0100 Subject: [PATCH 09/13] extended hiddenHeader --- dist/main.js | 12 ++++++------ src/github.js | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/dist/main.js b/dist/main.js index 950c047c..f655959d 100644 --- a/dist/main.js +++ b/dist/main.js @@ -6184,18 +6184,18 @@ const listComments = async ({ client, context, prNumber, commentHeader, hiddenHe return existingComments.filter(({ body }) => body.startsWith(hiddenHeader)); }; -const insertComment = async ({ client, context, prNumber, body }) => +const insertComment = async ({ client, context, prNumber, body }, hiddenHeader) => client.issues.createComment({ ...context.repo, issue_number: prNumber, - body: appendHiddenHeaderToComment(body), + body: appendHiddenHeaderToComment(body, hiddenHeader), }); -const updateComment = async ({ client, context, body, commentId }) => +const updateComment = async ({ client, context, body, commentId }, hiddenHeader) => client.issues.updateComment({ ...context.repo, comment_id: commentId, - body: appendHiddenHeaderToComment(body), + body: appendHiddenHeaderToComment(body, hiddenHeader), }); const deleteComments = async ({ client, context, comments }) => @@ -6229,13 +6229,13 @@ const upsertComment = async ({ client, context, prNumber, body, hiddenHeader }) context, body, commentId: last.id, - }) + }, hiddenHeader) : insertComment({ client, context, prNumber, body, - }); + }, hiddenHeader); }; var github$2 = { diff --git a/src/github.js b/src/github.js index e427ee68..ca6d3406 100644 --- a/src/github.js +++ b/src/github.js @@ -23,18 +23,18 @@ const listComments = async ({ client, context, prNumber, commentHeader, hiddenHe return existingComments.filter(({ body }) => body.startsWith(hiddenHeader)); }; -const insertComment = async ({ client, context, prNumber, body }) => +const insertComment = async ({ client, context, prNumber, body }, hiddenHeader) => client.issues.createComment({ ...context.repo, issue_number: prNumber, - body: appendHiddenHeaderToComment(body), + body: appendHiddenHeaderToComment(body, hiddenHeader), }); -const updateComment = async ({ client, context, body, commentId }) => +const updateComment = async ({ client, context, body, commentId }, hiddenHeader) => client.issues.updateComment({ ...context.repo, comment_id: commentId, - body: appendHiddenHeaderToComment(body), + body: appendHiddenHeaderToComment(body, hiddenHeader), }); const deleteComments = async ({ client, context, comments }) => @@ -68,13 +68,13 @@ const upsertComment = async ({ client, context, prNumber, body, hiddenHeader }) context, body, commentId: last.id, - }) + }, hiddenHeader) : insertComment({ client, context, prNumber, body, - }); + }, hiddenHeader); }; module.exports = { From c7545d346d6be27e5eae92c68693bc0931dd10a9 Mon Sep 17 00:00:00 2001 From: marinakalyuzhnaya Date: Tue, 9 Feb 2021 11:27:55 +0100 Subject: [PATCH 10/13] review changes --- action.yml | 2 +- dist/main.js | 6 +++--- src/comment.js | 4 ++-- src/index.js | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/action.yml b/action.yml index d3e7f3ee..b3ad25a6 100644 --- a/action.yml +++ b/action.yml @@ -18,7 +18,7 @@ inputs: description: The location of the lcov file for the base branch. Applicable for single repo setup. required: false app-name: - description: The concrete app name to dispaly on comment + description: App name to display on comment required: false runs: using: node12 diff --git a/dist/main.js b/dist/main.js index f655959d..56eee5f8 100644 --- a/dist/main.js +++ b/dist/main.js @@ -6030,8 +6030,8 @@ function uncovered(file, options) { * @returns {string} emoji string for negative/positive pdiff */ const renderEmoji = pdiff => { - if (pdiff < 0) return "🔴"; - if (pdiff >= 0) return "🟢"; + if (pdiff.toFixed(2) < 0) return "🔴"; + return "🟢"; }; /** @@ -6366,7 +6366,7 @@ async function main() { lcovBaseArrayForMonorepo, options, ), - hiddenHeader: appName ? `` : `` + hiddenHeader: appName ? `` : `` }); } diff --git a/src/comment.js b/src/comment.js index 1ed11819..5adf3635 100644 --- a/src/comment.js +++ b/src/comment.js @@ -8,8 +8,8 @@ import { tabulate } from "./tabulate"; * @returns {string} emoji string for negative/positive pdiff */ const renderEmoji = pdiff => { - if (pdiff < 0) return "🔴"; - if (pdiff >= 0) return "🟢"; + if (pdiff.toFixed(2) < 0) return "🔴"; + return "🟢"; }; /** diff --git a/src/index.js b/src/index.js index 96fefff0..42027d7e 100644 --- a/src/index.js +++ b/src/index.js @@ -129,7 +129,7 @@ async function main() { lcovBaseArrayForMonorepo, options, ), - hiddenHeader: appName ? `` : `` + hiddenHeader: appName ? `` : `` }); } From 104abb8f0a411e95dcd00d8fc5b21d826f83a5d0 Mon Sep 17 00:00:00 2001 From: marinakalyuzhnaya Date: Tue, 9 Feb 2021 11:50:32 +0100 Subject: [PATCH 11/13] changed emoji to use checkmark --- dist/main.js | 2 +- src/comment.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/main.js b/dist/main.js index 56eee5f8..2698cbd2 100644 --- a/dist/main.js +++ b/dist/main.js @@ -6031,7 +6031,7 @@ function uncovered(file, options) { */ const renderEmoji = pdiff => { if (pdiff.toFixed(2) < 0) return "🔴"; - return "🟢"; + return "✅"; }; /** diff --git a/src/comment.js b/src/comment.js index 5adf3635..93585ec5 100644 --- a/src/comment.js +++ b/src/comment.js @@ -9,7 +9,7 @@ import { tabulate } from "./tabulate"; */ const renderEmoji = pdiff => { if (pdiff.toFixed(2) < 0) return "🔴"; - return "🟢"; + return "✅"; }; /** From f2cd425eab120018073a6e399a40a4dc16368c85 Mon Sep 17 00:00:00 2001 From: marinakalyuzhnaya Date: Tue, 9 Feb 2021 11:54:18 +0100 Subject: [PATCH 12/13] changed emoji to use cross mark --- src/comment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/comment.js b/src/comment.js index 93585ec5..5cc594b0 100644 --- a/src/comment.js +++ b/src/comment.js @@ -8,7 +8,7 @@ import { tabulate } from "./tabulate"; * @returns {string} emoji string for negative/positive pdiff */ const renderEmoji = pdiff => { - if (pdiff.toFixed(2) < 0) return "🔴"; + if (pdiff.toFixed(2) < 0) return "❌"; return "✅"; }; From 6dd9b95f000d38d154db9e6f854fb4b4e51e97c2 Mon Sep 17 00:00:00 2001 From: marinakalyuzhnaya Date: Tue, 9 Feb 2021 11:54:29 +0100 Subject: [PATCH 13/13] changed emoji to use cross mark --- dist/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/main.js b/dist/main.js index 2698cbd2..ec7eeddc 100644 --- a/dist/main.js +++ b/dist/main.js @@ -6030,7 +6030,7 @@ function uncovered(file, options) { * @returns {string} emoji string for negative/positive pdiff */ const renderEmoji = pdiff => { - if (pdiff.toFixed(2) < 0) return "🔴"; + if (pdiff.toFixed(2) < 0) return "❌"; return "✅"; };