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..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,