From b6de86dd23be160c3d3be790bae8a53c4f312bd5 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Thu, 16 Nov 2023 20:24:02 +0100 Subject: [PATCH] Add some markers for Develocity build scans --- .../buildreporter/githubactions/BuildReporter.java | 8 ++++++++ .../githubactions/WorkflowConstants.java | 2 ++ .../githubactions/WorkflowReportFormatter.java | 12 ++++++++---- .../WorkflowReportFormatter/checkRunReportSummary.md | 2 +- .../WorkflowReportFormatter/commentReport.md | 6 ++++-- 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/build-reporter-github-actions/src/main/java/io/quarkus/bot/buildreporter/githubactions/BuildReporter.java b/build-reporter-github-actions/src/main/java/io/quarkus/bot/buildreporter/githubactions/BuildReporter.java index 00dd545..896566f 100644 --- a/build-reporter-github-actions/src/main/java/io/quarkus/bot/buildreporter/githubactions/BuildReporter.java +++ b/build-reporter-github-actions/src/main/java/io/quarkus/bot/buildreporter/githubactions/BuildReporter.java @@ -65,10 +65,14 @@ public Optional generateReportComment(GHWorkflowRun workflowRun, Optional checkRunOptional = createCheckRun(workflowRun, buildReporterConfig, workflowContext, artifactsAvailable, workflowReport); + String workflowRunIdMarker = String.format(WorkflowConstants.WORKFLOW_RUN_ID_MARKER, workflowRun.getId()); + String reportComment = workflowReportFormatter.getReportComment(workflowReport, artifactsAvailable, checkRunOptional.orElse(null), WorkflowConstants.MESSAGE_ID_ACTIVE, + workflowRunIdMarker, + WorkflowConstants.BUILD_SCANS_CHECK_RUN_MARKER, true, true, workflowReportJobIncludeStrategy); @@ -77,6 +81,8 @@ public Optional generateReportComment(GHWorkflowRun workflowRun, artifactsAvailable, checkRunOptional.orElse(null), WorkflowConstants.MESSAGE_ID_ACTIVE, + workflowRunIdMarker, + WorkflowConstants.BUILD_SCANS_CHECK_RUN_MARKER, false, true, workflowReportJobIncludeStrategy); @@ -86,6 +92,8 @@ public Optional generateReportComment(GHWorkflowRun workflowRun, artifactsAvailable, checkRunOptional.orElse(null), WorkflowConstants.MESSAGE_ID_ACTIVE, + workflowRunIdMarker, + WorkflowConstants.BUILD_SCANS_CHECK_RUN_MARKER, false, false, workflowReportJobIncludeStrategy); diff --git a/build-reporter-github-actions/src/main/java/io/quarkus/bot/buildreporter/githubactions/WorkflowConstants.java b/build-reporter-github-actions/src/main/java/io/quarkus/bot/buildreporter/githubactions/WorkflowConstants.java index 9a06124..314442b 100644 --- a/build-reporter-github-actions/src/main/java/io/quarkus/bot/buildreporter/githubactions/WorkflowConstants.java +++ b/build-reporter-github-actions/src/main/java/io/quarkus/bot/buildreporter/githubactions/WorkflowConstants.java @@ -14,6 +14,8 @@ public class WorkflowConstants { public static final String MESSAGE_ID_ACTIVE = ""; public static final String MESSAGE_ID_HIDDEN = ""; + public static final String WORKFLOW_RUN_ID_MARKER = ""; + public static final String BUILD_SCANS_CHECK_RUN_MARKER = ""; public static final String HIDE_MESSAGE_PREFIX = """ --- > :waning_crescent_moon: **_This workflow status is outdated as a new workflow run has been triggered._** diff --git a/build-reporter-github-actions/src/main/java/io/quarkus/bot/buildreporter/githubactions/WorkflowReportFormatter.java b/build-reporter-github-actions/src/main/java/io/quarkus/bot/buildreporter/githubactions/WorkflowReportFormatter.java index eb5547a..82777fc 100644 --- a/build-reporter-github-actions/src/main/java/io/quarkus/bot/buildreporter/githubactions/WorkflowReportFormatter.java +++ b/build-reporter-github-actions/src/main/java/io/quarkus/bot/buildreporter/githubactions/WorkflowReportFormatter.java @@ -23,10 +23,13 @@ public String getCheckRunReport(WorkflowReport report, boolean includeStackTrace } public String getReportComment(WorkflowReport report, boolean artifactsAvailable, GHCheckRun checkRun, - String messageIdActive, boolean includeStackTraces, boolean includeFailureLinks, + String messageIdActive, String workflowRunId, String buildScansCheckRunMarker, + boolean includeStackTraces, boolean includeFailureLinks, WorkflowReportJobIncludeStrategy workflowReportJobIncludeStrategy) { - return Templates.commentReport(report, artifactsAvailable, checkRun, messageIdActive, includeStackTraces, - includeFailureLinks, workflowReportJobIncludeStrategy).render(); + return Templates + .commentReport(report, artifactsAvailable, checkRun, messageIdActive, workflowRunId, buildScansCheckRunMarker, + includeStackTraces, includeFailureLinks, workflowReportJobIncludeStrategy) + .render(); } @CheckedTemplate @@ -39,7 +42,8 @@ public static native TemplateInstance checkRunReport(WorkflowReport report, bool boolean includeFailureLinks); public static native TemplateInstance commentReport(WorkflowReport report, boolean artifactsAvailable, - GHCheckRun checkRun, String messageIdActive, boolean includeStackTraces, boolean includeFailureLinks, + GHCheckRun checkRun, String messageIdActive, String workflowRunId, String buildScansCheckRunMarker, + boolean includeStackTraces, boolean includeFailureLinks, WorkflowReportJobIncludeStrategy workflowReportJobIncludeStrategy); } } diff --git a/build-reporter-github-actions/src/main/resources/templates/WorkflowReportFormatter/checkRunReportSummary.md b/build-reporter-github-actions/src/main/resources/templates/WorkflowReportFormatter/checkRunReportSummary.md index a32e60c..0c2196e 100644 --- a/build-reporter-github-actions/src/main/resources/templates/WorkflowReportFormatter/checkRunReportSummary.md +++ b/build-reporter-github-actions/src/main/resources/templates/WorkflowReportFormatter/checkRunReportSummary.md @@ -15,7 +15,7 @@ | :-: | -- | -- | :-: | :-: | :-: | :-: | {#for job in report.jobs} {#if workflowReportJobIncludeStrategy.include(report, job)} -| {job.conclusionEmoji} | {job.name} | {#if job.failingStep}`{job.failingStep}`{/if} | {#if job.reportedFailures}[Failures](#user-content-{job.failuresAnchor}){#else if job.failing}:warning: Check →{/if} | {#if job.url}[Logs]({job.url}){/if} | {#if job.rawLogsUrl}[Raw logs]({job.rawLogsUrl}){/if} | {#if job.gradleBuildScanUrl}[Build scan]({job.gradleBuildScanUrl}){/if} +| {job.conclusionEmoji} | {job.name} | {#if job.failingStep}`{job.failingStep}`{/if} | {#if job.reportedFailures}[Failures](#user-content-{job.failuresAnchor}){#else if job.failing}:warning: Check →{/if} | {#if job.url}[Logs]({job.url}){/if} | {#if job.rawLogsUrl}[Raw logs]({job.rawLogsUrl}){/if} | {#if job.gradleBuildScanUrl}[:mag:]({job.gradleBuildScanUrl}){#else}:construction:{/if} {/if} {/for} {/if} \ No newline at end of file diff --git a/build-reporter-github-actions/src/main/resources/templates/WorkflowReportFormatter/commentReport.md b/build-reporter-github-actions/src/main/resources/templates/WorkflowReportFormatter/commentReport.md index 6bb0379..bc93e63 100644 --- a/build-reporter-github-actions/src/main/resources/templates/WorkflowReportFormatter/commentReport.md +++ b/build-reporter-github-actions/src/main/resources/templates/WorkflowReportFormatter/commentReport.md @@ -18,7 +18,7 @@ | :-: | -- | -- | :-: | :-: | :-: | :-: | {#for job in report.jobs} {#if workflowReportJobIncludeStrategy.include(report, job)} -| {job.conclusionEmoji} | {job.name} | {#if job.failingStep}`{job.failingStep}`{/if} | {#if job.reportedFailures}[Failures](#user-content-{job.failuresAnchor}){#else if job.failing}:warning: Check →{/if} | {#if job.url}[Logs]({job.url}){/if} | {#if job.rawLogsUrl}[Raw logs]({job.rawLogsUrl}){/if} | {#if job.gradleBuildScanUrl}[Build scan]({job.gradleBuildScanUrl}){/if} +| {job.conclusionEmoji} | {job.name} | {#if job.failingStep}`{job.failingStep}`{/if} | {#if job.reportedFailures}[Failures](#user-content-{job.failuresAnchor}){#else if job.failing}:warning: Check →{/if} | {#if job.url}[Logs]({job.url}){/if} | {#if job.rawLogsUrl}[Raw logs]({job.rawLogsUrl}){/if} | {#if job.gradleBuildScanUrl}[:mag:]({job.gradleBuildScanUrl}){#else}:construction:{/if} {/if} {/for} @@ -26,6 +26,7 @@ Full information is available in the [Build summary check run]({checkRun.htmlUrl}). {/if} {/if} +{buildScansCheckRunMarker} {#if report.errorDownloadingBuildReports} :warning: Errors occurred while downloading the build reports. This report is incomplete. @@ -78,4 +79,5 @@ Full information is available in the [Build summary check run]({checkRun.htmlUrl {/for} {/if} -{messageIdActive} \ No newline at end of file +{messageIdActive} +{workflowRunId} \ No newline at end of file