From 715d67717242e5f2b1c4cf991dba10f72a8f55b5 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Fri, 17 Nov 2023 14:06:48 +0100 Subject: [PATCH] Add an option to condition Develocity presence --- .../githubactions/BuildReporter.java | 3 +++ .../githubactions/BuildReporterConfig.java | 17 +++++++++++++++-- .../githubactions/WorkflowReportFormatter.java | 6 +++--- .../WorkflowReportFormatter/commentReport.md | 8 ++++---- 4 files changed, 25 insertions(+), 9 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 896566f..8b3d24a 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 @@ -73,6 +73,7 @@ public Optional generateReportComment(GHWorkflowRun workflowRun, WorkflowConstants.MESSAGE_ID_ACTIVE, workflowRunIdMarker, WorkflowConstants.BUILD_SCANS_CHECK_RUN_MARKER, + buildReporterConfig.isDevelocityEnabled(), true, true, workflowReportJobIncludeStrategy); @@ -83,6 +84,7 @@ public Optional generateReportComment(GHWorkflowRun workflowRun, WorkflowConstants.MESSAGE_ID_ACTIVE, workflowRunIdMarker, WorkflowConstants.BUILD_SCANS_CHECK_RUN_MARKER, + buildReporterConfig.isDevelocityEnabled(), false, true, workflowReportJobIncludeStrategy); @@ -94,6 +96,7 @@ public Optional generateReportComment(GHWorkflowRun workflowRun, WorkflowConstants.MESSAGE_ID_ACTIVE, workflowRunIdMarker, WorkflowConstants.BUILD_SCANS_CHECK_RUN_MARKER, + buildReporterConfig.isDevelocityEnabled(), false, false, workflowReportJobIncludeStrategy); diff --git a/build-reporter-github-actions/src/main/java/io/quarkus/bot/buildreporter/githubactions/BuildReporterConfig.java b/build-reporter-github-actions/src/main/java/io/quarkus/bot/buildreporter/githubactions/BuildReporterConfig.java index a8d051f..bd0861a 100644 --- a/build-reporter-github-actions/src/main/java/io/quarkus/bot/buildreporter/githubactions/BuildReporterConfig.java +++ b/build-reporter-github-actions/src/main/java/io/quarkus/bot/buildreporter/githubactions/BuildReporterConfig.java @@ -12,13 +12,15 @@ public class BuildReporterConfig { private final Comparator workflowJobComparator; private final Set monitoredWorkflows; private final boolean createCheckRun; + private final boolean develocityEnabled; private BuildReporterConfig(boolean dryRun, Comparator workflowJobComparator, - Set monitoredWorkflows, boolean createCheckRun) { + Set monitoredWorkflows, boolean createCheckRun, boolean develocityEnabled) { this.dryRun = dryRun; this.workflowJobComparator = workflowJobComparator; this.monitoredWorkflows = monitoredWorkflows; this.createCheckRun = createCheckRun; + this.develocityEnabled = develocityEnabled; } public boolean isDryRun() { @@ -37,6 +39,10 @@ public boolean isCreateCheckRun() { return createCheckRun; } + public boolean isDevelocityEnabled() { + return develocityEnabled; + } + public static Builder builder() { return new Builder(); } @@ -47,6 +53,7 @@ public static class Builder { private boolean createCheckRun = true; private Comparator workflowJobComparator = DefaultJobNameComparator.INSTANCE; private Set monitoredWorkflows = Collections.emptySet(); + private boolean develocityEnabled; public Builder dryRun(boolean dryRun) { this.dryRun = dryRun; @@ -68,8 +75,14 @@ public Builder createCheckRun(boolean createCheckRun) { return this; } + public Builder enableDevelocity(boolean develocityEnabled) { + this.develocityEnabled = develocityEnabled; + return this; + } + public BuildReporterConfig build() { - return new BuildReporterConfig(dryRun, workflowJobComparator, monitoredWorkflows, createCheckRun); + return new BuildReporterConfig(dryRun, workflowJobComparator, monitoredWorkflows, createCheckRun, + develocityEnabled); } } 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 82777fc..d72c41a 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 @@ -24,11 +24,11 @@ public String getCheckRunReport(WorkflowReport report, boolean includeStackTrace public String getReportComment(WorkflowReport report, boolean artifactsAvailable, GHCheckRun checkRun, String messageIdActive, String workflowRunId, String buildScansCheckRunMarker, - boolean includeStackTraces, boolean includeFailureLinks, + boolean develocityEnabled, boolean includeStackTraces, boolean includeFailureLinks, WorkflowReportJobIncludeStrategy workflowReportJobIncludeStrategy) { return Templates .commentReport(report, artifactsAvailable, checkRun, messageIdActive, workflowRunId, buildScansCheckRunMarker, - includeStackTraces, includeFailureLinks, workflowReportJobIncludeStrategy) + develocityEnabled, includeStackTraces, includeFailureLinks, workflowReportJobIncludeStrategy) .render(); } @@ -43,7 +43,7 @@ public static native TemplateInstance checkRunReport(WorkflowReport report, bool public static native TemplateInstance commentReport(WorkflowReport report, boolean artifactsAvailable, GHCheckRun checkRun, String messageIdActive, String workflowRunId, String buildScansCheckRunMarker, - boolean includeStackTraces, boolean includeFailureLinks, + boolean develocityEnabled, boolean includeStackTraces, boolean includeFailureLinks, WorkflowReportJobIncludeStrategy workflowReportJobIncludeStrategy); } } 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 bc93e63..a823566 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 @@ -14,11 +14,11 @@ {#if !artifactsAvailable && !report.cancelled}:warning: Artifacts of the workflow run were not available thus the report misses some details.{/if} -| Status | Name | Step | Failures | Logs | Raw logs | Build scan | -| :-: | -- | -- | :-: | :-: | :-: | :-: | +| Status | Name | Step | Failures | Logs | Raw logs |{#if develocityEnabled} Build scan |{/if} +| :-: | -- | -- | :-: | :-: | :-: |{#if develocityEnabled} :-: |{/if} {#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}[:mag:]({job.gradleBuildScanUrl}){#else}:construction:{/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 develocityEnabled} {#if job.gradleBuildScanUrl}[:mag:]({job.gradleBuildScanUrl}){#else}:construction:{/if} |{/if} {/if} {/for} @@ -26,7 +26,7 @@ Full information is available in the [Build summary check run]({checkRun.htmlUrl}). {/if} {/if} -{buildScansCheckRunMarker} +{#if develocityEnabled}{buildScansCheckRunMarker}{/if} {#if report.errorDownloadingBuildReports} :warning: Errors occurred while downloading the build reports. This report is incomplete.