From 80532c215b19a5012f9d35fe60c00dcdeec84108 Mon Sep 17 00:00:00 2001 From: ajax-romaniuk-o Date: Fri, 22 Aug 2025 14:30:35 +0300 Subject: [PATCH 1/3] CPI-0: experiments --- action.yaml | 14 +++++++++++--- src/build-comment-body.js | 27 +++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/action.yaml b/action.yaml index 469b32e..59a8115 100644 --- a/action.yaml +++ b/action.yaml @@ -25,6 +25,11 @@ inputs: required: false default: 'delta-coverage' + additional-data: + description: 'Base path for HTML coverage reports (e.g., snapshot/backend/coverage/example-service/pr-2822/17153419223/).' + required: false + default: '' + outputs: badges-dir: description: 'Directory with generated badges.' @@ -143,7 +148,8 @@ runs: checkRunsContent: `${{ steps.create-check-runs.outputs.check-runs }}`, commentTitle: '${{ inputs.title }}', commentMarker: `${{ steps.comment-marker.outputs.result }}`, - core: core + core: core, + additionalData: `${{ inputs.additional-data }}` }); - name: Update or Create Comment @@ -158,13 +164,15 @@ runs: owner: context.repo.owner, repo: context.repo.repo, comment_id: '${{ steps.find-comment.outputs.result }}', - body: ${{ steps.build-message.outputs.result }} + body: ${{ steps.build-message.outputs.result }}, + link: `${{ inputs.additional-data }}` }) } else { github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: ${{ steps.build-message.outputs.result }} + body: ${{ steps.build-message.outputs.result }}, + link: `${{ inputs.additional-data }}` }) } diff --git a/src/build-comment-body.js b/src/build-comment-body.js index f1d9c33..8a2b4ca 100644 --- a/src/build-comment-body.js +++ b/src/build-comment-body.js @@ -69,6 +69,18 @@ module.exports = (ctx) => { return ``; } + const buildHtmlReportLink = (checkRun) => { + if (!ctx.additionalData) return ''; + + // Створюємо URL до HTML звіту на основі additional-data та view + const baseUrl = ctx.additionalData.trim(); + if (!baseUrl) return ''; + + // Додаємо view та /html/index.html + const htmlUrl = `${baseUrl}/${checkRun.viewName.toLowerCase()}/html/index.html`; + return ` | 📊 HTML Report`; + }; + const buildExpectedValue = (entityData) => { return (entityData.expected > NO_VALUE) ? `🎯 ${entityData.expected}% 🎯` : ''; } @@ -91,8 +103,9 @@ module.exports = (ctx) => { const hasFailure = viewSummaryData.some(it => it.isFailed); const statusSymbol = hasFailure ? '🔴' : '🟢'; + const htmlReportLink = buildHtmlReportLink(checkRun); const viewCellValue = ` - ${statusSymbol} ${checkRun.viewName} + ${statusSymbol} ${checkRun.viewName}${htmlReportLink} `.trim(); const foldExpectedColumn = obtainUniqueValuesSet(viewSummaryData, it => it.expected).size === 1; @@ -128,7 +141,17 @@ module.exports = (ctx) => { const workflowRunLink = `[Run ${workflowNum}](${workflowUrl})`; const formattedDate = workflowRunDate.toLocaleString('en-US', options); - return `${workflowRunLink} | \`${formattedDate}\``; + + let result = `${workflowRunLink} | \`${formattedDate}\``; + + // Додаємо загальний HTML report link, якщо є additional-data + if (ctx.additionalData && ctx.additionalData.trim()) { + const baseUrl = ctx.additionalData.trim(); + const aggregatedHtmlUrl = `${baseUrl}/aggregated/html/index.html`; + result += ` | [📊 Full Coverage Report](${aggregatedHtmlUrl})`; + } + + return result; }; const checkRuns = JSON.parse(ctx.checkRunsContent); From 692984edc267a5677b144e41ec506924c2ec6956 Mon Sep 17 00:00:00 2001 From: ajax-romaniuk-o Date: Fri, 22 Aug 2025 15:09:45 +0300 Subject: [PATCH 2/3] CPI-0: experiments --- action.yaml | 9 +++------ src/build-comment-body.js | 27 ++------------------------- 2 files changed, 5 insertions(+), 31 deletions(-) diff --git a/action.yaml b/action.yaml index 59a8115..f71b074 100644 --- a/action.yaml +++ b/action.yaml @@ -148,8 +148,7 @@ runs: checkRunsContent: `${{ steps.create-check-runs.outputs.check-runs }}`, commentTitle: '${{ inputs.title }}', commentMarker: `${{ steps.comment-marker.outputs.result }}`, - core: core, - additionalData: `${{ inputs.additional-data }}` + core: core }); - name: Update or Create Comment @@ -164,15 +163,13 @@ runs: owner: context.repo.owner, repo: context.repo.repo, comment_id: '${{ steps.find-comment.outputs.result }}', - body: ${{ steps.build-message.outputs.result }}, - link: `${{ inputs.additional-data }}` + body: ${{ steps.build-message.outputs.result }} }) } else { github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: ${{ steps.build-message.outputs.result }}, - link: `${{ inputs.additional-data }}` + body: ${{ steps.build-message.outputs.result }} }) } diff --git a/src/build-comment-body.js b/src/build-comment-body.js index 8a2b4ca..f1d9c33 100644 --- a/src/build-comment-body.js +++ b/src/build-comment-body.js @@ -69,18 +69,6 @@ module.exports = (ctx) => { return ``; } - const buildHtmlReportLink = (checkRun) => { - if (!ctx.additionalData) return ''; - - // Створюємо URL до HTML звіту на основі additional-data та view - const baseUrl = ctx.additionalData.trim(); - if (!baseUrl) return ''; - - // Додаємо view та /html/index.html - const htmlUrl = `${baseUrl}/${checkRun.viewName.toLowerCase()}/html/index.html`; - return ` | 📊 HTML Report`; - }; - const buildExpectedValue = (entityData) => { return (entityData.expected > NO_VALUE) ? `🎯 ${entityData.expected}% 🎯` : ''; } @@ -103,9 +91,8 @@ module.exports = (ctx) => { const hasFailure = viewSummaryData.some(it => it.isFailed); const statusSymbol = hasFailure ? '🔴' : '🟢'; - const htmlReportLink = buildHtmlReportLink(checkRun); const viewCellValue = ` - ${statusSymbol} ${checkRun.viewName}${htmlReportLink} + ${statusSymbol} ${checkRun.viewName} `.trim(); const foldExpectedColumn = obtainUniqueValuesSet(viewSummaryData, it => it.expected).size === 1; @@ -141,17 +128,7 @@ module.exports = (ctx) => { const workflowRunLink = `[Run ${workflowNum}](${workflowUrl})`; const formattedDate = workflowRunDate.toLocaleString('en-US', options); - - let result = `${workflowRunLink} | \`${formattedDate}\``; - - // Додаємо загальний HTML report link, якщо є additional-data - if (ctx.additionalData && ctx.additionalData.trim()) { - const baseUrl = ctx.additionalData.trim(); - const aggregatedHtmlUrl = `${baseUrl}/aggregated/html/index.html`; - result += ` | [📊 Full Coverage Report](${aggregatedHtmlUrl})`; - } - - return result; + return `${workflowRunLink} | \`${formattedDate}\``; }; const checkRuns = JSON.parse(ctx.checkRunsContent); From 32bd00159b6a39c574bcd58c1afc579f4d7d66ca Mon Sep 17 00:00:00 2001 From: ajax-romaniuk-o Date: Fri, 22 Aug 2025 15:39:25 +0300 Subject: [PATCH 3/3] CPI-0: experiments --- action.yaml | 9 ++++--- src/build-comment-body.js | 53 ++++++++++++++++++++++++++++++++++++--- src/create-check-runs.js | 1 + 3 files changed, 57 insertions(+), 6 deletions(-) diff --git a/action.yaml b/action.yaml index f71b074..59a8115 100644 --- a/action.yaml +++ b/action.yaml @@ -148,7 +148,8 @@ runs: checkRunsContent: `${{ steps.create-check-runs.outputs.check-runs }}`, commentTitle: '${{ inputs.title }}', commentMarker: `${{ steps.comment-marker.outputs.result }}`, - core: core + core: core, + additionalData: `${{ inputs.additional-data }}` }); - name: Update or Create Comment @@ -163,13 +164,15 @@ runs: owner: context.repo.owner, repo: context.repo.repo, comment_id: '${{ steps.find-comment.outputs.result }}', - body: ${{ steps.build-message.outputs.result }} + body: ${{ steps.build-message.outputs.result }}, + link: `${{ inputs.additional-data }}` }) } else { github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: ${{ steps.build-message.outputs.result }} + body: ${{ steps.build-message.outputs.result }}, + link: `${{ inputs.additional-data }}` }) } diff --git a/src/build-comment-body.js b/src/build-comment-body.js index f1d9c33..f1c5298 100644 --- a/src/build-comment-body.js +++ b/src/build-comment-body.js @@ -69,6 +69,32 @@ module.exports = (ctx) => { return ``; } + const buildHtmlReportLink = (checkRun) => { + if (!ctx.additionalData || ctx.additionalData.trim() === '') return ''; + + let baseUrl = ctx.additionalData.trim(); + + if (baseUrl.endsWith('/')) { + baseUrl = baseUrl.slice(0, -1); + } + + let viewPath = checkRun.view; + if (viewPath === 'functionalTest') { + viewPath = 'functional-test'; + } else if (viewPath === 'integrationTest') { + viewPath = 'integration-test'; + } else if (viewPath === 'unitTest') { + viewPath = 'unit-test'; + } else if (viewPath === 'componentTest') { + viewPath = 'component-test'; + } else if (viewPath === 'archUnitTest') { + viewPath = 'arch-unit-test'; + } + + const htmlUrl = `${baseUrl}/${viewPath}/html/index.html`; + return ` | 📊 HTML Report`; + }; + const buildExpectedValue = (entityData) => { return (entityData.expected > NO_VALUE) ? `🎯 ${entityData.expected}% 🎯` : ''; } @@ -91,8 +117,9 @@ module.exports = (ctx) => { const hasFailure = viewSummaryData.some(it => it.isFailed); const statusSymbol = hasFailure ? '🔴' : '🟢'; + const htmlReportLink = buildHtmlReportLink(checkRun); const viewCellValue = ` - ${statusSymbol} ${checkRun.viewName} + ${statusSymbol} ${checkRun.viewName}${htmlReportLink} `.trim(); const foldExpectedColumn = obtainUniqueValuesSet(viewSummaryData, it => it.expected).size === 1; @@ -101,7 +128,7 @@ module.exports = (ctx) => { const foldActualColumn = actualUniqueValues.size === 1 && (foldExpectedColumn || actualUniqueValues.has(NO_VALUE)); - return viewSummaryData.map((entityData, index) => { + const tableRows = viewSummaryData.map((entityData, index) => { const viewCellInRow = (index === 0) ? viewCellValue : ''; const actualColumnHtml = buildCoverageValueColumnHtml(entityData, index, foldActualColumn, buildProgressImg); @@ -116,6 +143,14 @@ module.exports = (ctx) => { ${actualColumnHtml} `.trim().replace(/^ +/gm, ''); }).join('\n'); + + const htmlReportLinkBelow = buildHtmlReportLink(checkRun); + if (htmlReportLinkBelow) { + const linkText = htmlReportLinkBelow.replace(' | ', ''); + return tableRows + '\n' + linkText + ''; + } + + return tableRows; } const renderHeaders = () => { @@ -128,7 +163,19 @@ module.exports = (ctx) => { const workflowRunLink = `[Run ${workflowNum}](${workflowUrl})`; const formattedDate = workflowRunDate.toLocaleString('en-US', options); - return `${workflowRunLink} | \`${formattedDate}\``; + + let result = `${workflowRunLink} | \`${formattedDate}\``; + + if (ctx.additionalData && ctx.additionalData.trim() !== '') { + let baseUrl = ctx.additionalData.trim(); + if (baseUrl.endsWith('/')) { + baseUrl = baseUrl.slice(0, -1); + } + const aggregatedHtmlUrl = `${baseUrl}/aggregated/html/index.html`; + result += ` | [📊 Full Coverage Report](${aggregatedHtmlUrl})`; + } + + return result; }; const checkRuns = JSON.parse(ctx.checkRunsContent); diff --git a/src/create-check-runs.js b/src/create-check-runs.js index aed5ec0..b2a632b 100644 --- a/src/create-check-runs.js +++ b/src/create-check-runs.js @@ -48,6 +48,7 @@ module.exports = async (ctx) => { }); return { viewName: viewName, + view: view.view, verifications: view.verifications, coverageRules: view.coverageRulesConfig, url: response.data.html_url,