Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
Expand Down Expand Up @@ -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
Expand All @@ -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 }}`

Copilot AI Aug 22, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'link' parameter is being added to the GitHub API call for updating comments, but this is not a valid parameter for the github.rest.issues.updateComment API. This will likely cause the API call to fail or ignore the parameter.

Copilot uses AI. Check for mistakes.

Copilot AI Aug 22, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'link' parameter is being added to the GitHub API call for creating comments, but this is not a valid parameter for the github.rest.issues.createComment API. This will likely cause the API call to fail or ignore the parameter.

Copilot uses AI. Check for mistakes.
})
}
53 changes: 50 additions & 3 deletions src/build-comment-body.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,32 @@ module.exports = (ctx) => {
return `<img src="${imageLink}" />`;
}

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 ` | <a href="${htmlUrl}" target="_blank">📊 HTML Report</a>`;
};

const buildExpectedValue = (entityData) => {
return (entityData.expected > NO_VALUE) ? `🎯 ${entityData.expected}% 🎯` : '';
}
Expand All @@ -91,8 +117,9 @@ module.exports = (ctx) => {

const hasFailure = viewSummaryData.some(it => it.isFailed);
const statusSymbol = hasFailure ? '🔴' : '🟢';
const htmlReportLink = buildHtmlReportLink(checkRun);
const viewCellValue = `
<td rowspan=3>${statusSymbol} <a href="${checkRun.url}">${checkRun.viewName}</a></td>
<td rowspan=3>${statusSymbol} <a href="${checkRun.url}">${checkRun.viewName}</a>${htmlReportLink}</td>
`.trim();

const foldExpectedColumn = obtainUniqueValuesSet(viewSummaryData, it => it.expected).size === 1;
Expand All @@ -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);
Expand All @@ -116,6 +143,14 @@ module.exports = (ctx) => {
${actualColumnHtml}
</tr>`.trim().replace(/^ +/gm, '');
}).join('\n');

const htmlReportLinkBelow = buildHtmlReportLink(checkRun);
if (htmlReportLinkBelow) {
const linkText = htmlReportLinkBelow.replace(' | ', '');
return tableRows + '\n<tr><td colspan="4" style="text-align: center; padding-top: 10px;">' + linkText + '</td></tr>';
}

return tableRows;
}

const renderHeaders = () => {
Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/create-check-runs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading