Skip to content

Commit

Permalink
Merge pull request #131 from gsmet/condition-build-scans
Browse files Browse the repository at this point in the history
Add an option to condition Develocity presence
  • Loading branch information
gsmet authored Nov 17, 2023
2 parents a9cd4ee + 715d677 commit 28d420e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public Optional<String> generateReportComment(GHWorkflowRun workflowRun,
WorkflowConstants.MESSAGE_ID_ACTIVE,
workflowRunIdMarker,
WorkflowConstants.BUILD_SCANS_CHECK_RUN_MARKER,
buildReporterConfig.isDevelocityEnabled(),
true,
true,
workflowReportJobIncludeStrategy);
Expand All @@ -83,6 +84,7 @@ public Optional<String> generateReportComment(GHWorkflowRun workflowRun,
WorkflowConstants.MESSAGE_ID_ACTIVE,
workflowRunIdMarker,
WorkflowConstants.BUILD_SCANS_CHECK_RUN_MARKER,
buildReporterConfig.isDevelocityEnabled(),
false,
true,
workflowReportJobIncludeStrategy);
Expand All @@ -94,6 +96,7 @@ public Optional<String> generateReportComment(GHWorkflowRun workflowRun,
WorkflowConstants.MESSAGE_ID_ACTIVE,
workflowRunIdMarker,
WorkflowConstants.BUILD_SCANS_CHECK_RUN_MARKER,
buildReporterConfig.isDevelocityEnabled(),
false,
false,
workflowReportJobIncludeStrategy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ public class BuildReporterConfig {
private final Comparator<GHWorkflowJob> workflowJobComparator;
private final Set<String> monitoredWorkflows;
private final boolean createCheckRun;
private final boolean develocityEnabled;

private BuildReporterConfig(boolean dryRun, Comparator<GHWorkflowJob> workflowJobComparator,
Set<String> monitoredWorkflows, boolean createCheckRun) {
Set<String> monitoredWorkflows, boolean createCheckRun, boolean develocityEnabled) {
this.dryRun = dryRun;
this.workflowJobComparator = workflowJobComparator;
this.monitoredWorkflows = monitoredWorkflows;
this.createCheckRun = createCheckRun;
this.develocityEnabled = develocityEnabled;
}

public boolean isDryRun() {
Expand All @@ -37,6 +39,10 @@ public boolean isCreateCheckRun() {
return createCheckRun;
}

public boolean isDevelocityEnabled() {
return develocityEnabled;
}

public static Builder builder() {
return new Builder();
}
Expand All @@ -47,6 +53,7 @@ public static class Builder {
private boolean createCheckRun = true;
private Comparator<GHWorkflowJob> workflowJobComparator = DefaultJobNameComparator.INSTANCE;
private Set<String> monitoredWorkflows = Collections.emptySet();
private boolean develocityEnabled;

public Builder dryRun(boolean dryRun) {
this.dryRun = dryRun;
Expand All @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@

{#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}

{#if checkRun}
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.
Expand Down

0 comments on commit 28d420e

Please sign in to comment.