add mermaid diagramm to pr comment

This commit is contained in:
jpaul 2023-11-21 16:18:50 +01:00
parent ab28789618
commit e3535f6ae8
4 changed files with 109 additions and 18 deletions

View File

@ -43,6 +43,10 @@ inputs:
required: false
description: 'Post a comment containing a Native Image build report on pull requests.'
default: 'false'
native-image-pr-comparison:
required: false
description: 'Post a comment containing a comparison between the Native Image of the pr-branch and the pr-base-branch on pull.'
default: 'false'
version:
required: false
description: 'GraalVM version (release, latest, dev).'

39
dist/cleanup/index.js generated vendored
View File

@ -74427,6 +74427,7 @@ const BYTES_TO_GiB = 1024 * 1024 * 1024;
const DOCS_BASE = 'https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/BuildOutput.md';
const INPUT_NI_JOB_REPORTS = 'native-image-job-reports';
const INPUT_NI_PR_REPORTS = 'native-image-pr-reports';
const INPUT_NI_PR_COMPARISON = 'native-image-pr-comparison';
const NATIVE_IMAGE_CONFIG_FILE = (0, path_1.join)((0, os_1.tmpdir)(), 'native-image-options.properties');
const NATIVE_IMAGE_CONFIG_FILE_ENV = 'NATIVE_IMAGE_CONFIG_FILE';
function setUpNativeImageBuildReports(isGraalVMforJDK17OrLater, graalVMVersion) {
@ -74458,9 +74459,6 @@ function generateReports() {
return;
}
const buildOutput = JSON.parse(fs.readFileSync(BUILD_OUTPUT_JSON_PATH, 'utf8'));
const treeSha = yield (0, utils_1.createTree)(JSON.stringify(buildOutput));
yield (0, utils_1.createRef)(treeSha);
const prMetrics = JSON.parse(yield (0, utils_1.getPrBaseBranchMetrics)());
const report = createReport(buildOutput);
if (areJobReportsEnabled()) {
core.summary.addRaw(report);
@ -74469,8 +74467,12 @@ function generateReports() {
if (arePRReportsEnabled()) {
yield (0, utils_1.createPRComment)(report);
}
const prBaseReport = createPRComparison(buildOutput, prMetrics);
yield (0, utils_1.createPRComment)(prBaseReport);
const treeSha = yield (0, utils_1.createTree)(JSON.stringify(buildOutput));
yield (0, utils_1.createRef)(treeSha);
if (arePRBaseComparisonEnabled()) {
const prMetrics = JSON.parse(yield (0, utils_1.getPrBaseBranchMetrics)());
yield (0, utils_1.createPRComment)(createPRComparison(buildOutput, prMetrics));
}
}
});
}
@ -74481,6 +74483,9 @@ function areJobReportsEnabled() {
function arePRReportsEnabled() {
return (0, utils_1.isPREvent)() && core.getInput(INPUT_NI_PR_REPORTS) === 'true';
}
function arePRBaseComparisonEnabled() {
return (0, utils_1.isPREvent)() && core.getInput(INPUT_NI_PR_COMPARISON) === 'true';
}
function getNativeImageOptionsFile() {
let optionsFile = process.env[NATIVE_IMAGE_CONFIG_FILE_ENV];
if (optionsFile === undefined) {
@ -74548,6 +74553,30 @@ function createPRComparison(dataRecent, dataBase) {
</tbody>
</table>
\`\`\`mermaid
gantt
title Native Image Size Details
todayMarker off
dateFormat X
axisFormat %s
section Code area
${recentBranch} (${bytesToHuman(detailsRecent.code_area.bytes)}) : active, 0, ${detailsRecent.code_area.bytes / 1000000}
${baseBranch} (${bytesToHuman(detailsBase.code_area.bytes)}) : 0, ${detailsBase.code_area.bytes / 1000000}
section Image heap
${recentBranch} (${bytesToHuman(detailsRecent.image_heap.bytes)}) : active, 0, ${detailsRecent.image_heap.bytes / 1000000}
${baseBranch} (${bytesToHuman(detailsBase.image_heap.bytes)}) : 0, ${detailsBase.image_heap.bytes / 1000000}
section Other data
${recentBranch} (${bytesToHuman(otherBytesRecent)}) : active, 0, ${otherBytesRecent / 1000000}
${baseBranch} (${bytesToHuman(otherBytesBase)}) : 0, ${otherBytesBase / 1000000}
section Total
${recentBranch} (${bytesToHuman(detailsRecent.total_bytes)}) : active, 0, ${detailsRecent.total_bytes / 1000000}
${baseBranch} (${bytesToHuman(detailsBase.total_bytes)}) : 0, ${detailsBase.total_bytes / 1000000}
\`\`\`
<em>Report generated by <a href="https://github.com/marketplace/actions/github-action-for-graalvm" target="_blank">setup-graalvm</a>.</em>`;
}
function createReport(data) {

39
dist/main/index.js generated vendored
View File

@ -74526,6 +74526,7 @@ const BYTES_TO_GiB = 1024 * 1024 * 1024;
const DOCS_BASE = 'https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/BuildOutput.md';
const INPUT_NI_JOB_REPORTS = 'native-image-job-reports';
const INPUT_NI_PR_REPORTS = 'native-image-pr-reports';
const INPUT_NI_PR_COMPARISON = 'native-image-pr-comparison';
const NATIVE_IMAGE_CONFIG_FILE = (0, path_1.join)((0, os_1.tmpdir)(), 'native-image-options.properties');
const NATIVE_IMAGE_CONFIG_FILE_ENV = 'NATIVE_IMAGE_CONFIG_FILE';
function setUpNativeImageBuildReports(isGraalVMforJDK17OrLater, graalVMVersion) {
@ -74557,9 +74558,6 @@ function generateReports() {
return;
}
const buildOutput = JSON.parse(fs.readFileSync(BUILD_OUTPUT_JSON_PATH, 'utf8'));
const treeSha = yield (0, utils_1.createTree)(JSON.stringify(buildOutput));
yield (0, utils_1.createRef)(treeSha);
const prMetrics = JSON.parse(yield (0, utils_1.getPrBaseBranchMetrics)());
const report = createReport(buildOutput);
if (areJobReportsEnabled()) {
core.summary.addRaw(report);
@ -74568,8 +74566,12 @@ function generateReports() {
if (arePRReportsEnabled()) {
yield (0, utils_1.createPRComment)(report);
}
const prBaseReport = createPRComparison(buildOutput, prMetrics);
yield (0, utils_1.createPRComment)(prBaseReport);
const treeSha = yield (0, utils_1.createTree)(JSON.stringify(buildOutput));
yield (0, utils_1.createRef)(treeSha);
if (arePRBaseComparisonEnabled()) {
const prMetrics = JSON.parse(yield (0, utils_1.getPrBaseBranchMetrics)());
yield (0, utils_1.createPRComment)(createPRComparison(buildOutput, prMetrics));
}
}
});
}
@ -74580,6 +74582,9 @@ function areJobReportsEnabled() {
function arePRReportsEnabled() {
return (0, utils_1.isPREvent)() && core.getInput(INPUT_NI_PR_REPORTS) === 'true';
}
function arePRBaseComparisonEnabled() {
return (0, utils_1.isPREvent)() && core.getInput(INPUT_NI_PR_COMPARISON) === 'true';
}
function getNativeImageOptionsFile() {
let optionsFile = process.env[NATIVE_IMAGE_CONFIG_FILE_ENV];
if (optionsFile === undefined) {
@ -74647,6 +74652,30 @@ function createPRComparison(dataRecent, dataBase) {
</tbody>
</table>
\`\`\`mermaid
gantt
title Native Image Size Details
todayMarker off
dateFormat X
axisFormat %s
section Code area
${recentBranch} (${bytesToHuman(detailsRecent.code_area.bytes)}) : active, 0, ${detailsRecent.code_area.bytes / 1000000}
${baseBranch} (${bytesToHuman(detailsBase.code_area.bytes)}) : 0, ${detailsBase.code_area.bytes / 1000000}
section Image heap
${recentBranch} (${bytesToHuman(detailsRecent.image_heap.bytes)}) : active, 0, ${detailsRecent.image_heap.bytes / 1000000}
${baseBranch} (${bytesToHuman(detailsBase.image_heap.bytes)}) : 0, ${detailsBase.image_heap.bytes / 1000000}
section Other data
${recentBranch} (${bytesToHuman(otherBytesRecent)}) : active, 0, ${otherBytesRecent / 1000000}
${baseBranch} (${bytesToHuman(otherBytesBase)}) : 0, ${otherBytesBase / 1000000}
section Total
${recentBranch} (${bytesToHuman(detailsRecent.total_bytes)}) : active, 0, ${detailsRecent.total_bytes / 1000000}
${baseBranch} (${bytesToHuman(detailsBase.total_bytes)}) : 0, ${detailsBase.total_bytes / 1000000}
\`\`\`
<em>Report generated by <a href="https://github.com/marketplace/actions/github-action-for-graalvm" target="_blank">setup-graalvm</a>.</em>`;
}
function createReport(data) {

View File

@ -15,6 +15,7 @@ const DOCS_BASE =
'https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/BuildOutput.md'
const INPUT_NI_JOB_REPORTS = 'native-image-job-reports'
const INPUT_NI_PR_REPORTS = 'native-image-pr-reports'
const INPUT_NI_PR_COMPARISON = 'native-image-pr-comparison'
const NATIVE_IMAGE_CONFIG_FILE = join(
tmpdir(),
'native-image-options.properties'
@ -128,12 +129,6 @@ export async function generateReports(): Promise<void> {
fs.readFileSync(BUILD_OUTPUT_JSON_PATH, 'utf8')
)
const treeSha = await createTree(JSON.stringify(buildOutput))
await createRef(treeSha)
const prMetrics: BuildOutput = JSON.parse(
await getPrBaseBranchMetrics()
)
const report = createReport(buildOutput)
if (areJobReportsEnabled()) {
core.summary.addRaw(report)
@ -142,8 +137,14 @@ export async function generateReports(): Promise<void> {
if (arePRReportsEnabled()) {
await createPRComment(report)
}
const prBaseReport = createPRComparison(buildOutput, prMetrics)
await createPRComment(prBaseReport)
const treeSha = await createTree(JSON.stringify(buildOutput))
await createRef(treeSha)
if (arePRBaseComparisonEnabled()) {
const prMetrics: BuildOutput = JSON.parse(
await getPrBaseBranchMetrics()
)
await createPRComment(createPRComparison(buildOutput, prMetrics))
}
}
}
@ -155,6 +156,10 @@ function arePRReportsEnabled(): boolean {
return isPREvent() && core.getInput(INPUT_NI_PR_REPORTS) === 'true'
}
function arePRBaseComparisonEnabled(): boolean {
return isPREvent() && core.getInput(INPUT_NI_PR_COMPARISON) === 'true'
}
function getNativeImageOptionsFile(): string {
let optionsFile = process.env[NATIVE_IMAGE_CONFIG_FILE_ENV]
if (optionsFile === undefined) {
@ -228,6 +233,30 @@ function createPRComparison(dataRecent: BuildOutput, dataBase: BuildOutput): str
</tbody>
</table>
\`\`\`mermaid
gantt
title Native Image Size Details
todayMarker off
dateFormat X
axisFormat %s
section Code area
${recentBranch} (${bytesToHuman(detailsRecent.code_area.bytes)}) : active, 0, ${detailsRecent.code_area.bytes / 1000000}
${baseBranch} (${bytesToHuman(detailsBase.code_area.bytes)}) : 0, ${detailsBase.code_area.bytes / 1000000}
section Image heap
${recentBranch} (${bytesToHuman(detailsRecent.image_heap.bytes)}) : active, 0, ${detailsRecent.image_heap.bytes / 1000000}
${baseBranch} (${bytesToHuman(detailsBase.image_heap.bytes)}) : 0, ${detailsBase.image_heap.bytes / 1000000}
section Other data
${recentBranch} (${bytesToHuman(otherBytesRecent)}) : active, 0, ${otherBytesRecent / 1000000}
${baseBranch} (${bytesToHuman(otherBytesBase)}) : 0, ${otherBytesBase / 1000000}
section Total
${recentBranch} (${bytesToHuman(detailsRecent.total_bytes)}) : active, 0, ${detailsRecent.total_bytes / 1000000}
${baseBranch} (${bytesToHuman(detailsBase.total_bytes)}) : 0, ${detailsBase.total_bytes / 1000000}
\`\`\`
<em>Report generated by <a href="https://github.com/marketplace/actions/github-action-for-graalvm" target="_blank">setup-graalvm</a>.</em>`
}