Skip to content

Commit

Permalink
Merge pull request #237 from gsmet/prepare-langchain4j
Browse files Browse the repository at this point in the history
Make the config a bit more flexible
  • Loading branch information
gsmet authored Nov 8, 2024
2 parents 95d501b + 95697c9 commit d7fc66e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class BuildReporter {
WorkflowReportFormatter workflowReportFormatter;

@Inject
WorkflowReportJobIncludeStrategy workflowReportJobIncludeStrategy;
WorkflowReportJobIncludeStrategy globalWorkflowReportJobIncludeStrategy;

@Inject
StackTraceShortener stackTraceShortener;
Expand All @@ -57,6 +57,10 @@ public Optional<String> generateReportComment(String workflowName,
String statusCommentMarker = workflowName == null ? WorkflowConstants.MESSAGE_ID_ACTIVE
: getActiveStatusCommentMarker(workflowName);

WorkflowReportJobIncludeStrategy workflowReportJobIncludeStrategy = buildReporterConfig
.getWorkflowReportJobIncludeStrategy() != null ? buildReporterConfig.getWorkflowReportJobIncludeStrategy()
: globalWorkflowReportJobIncludeStrategy;

String reportComment = workflowReportFormatter.getReportComment(workflowReport,
artifactsAvailable,
checkRunOptional.orElse(null),
Expand Down Expand Up @@ -126,6 +130,10 @@ public Optional<GHCheckRun> createCheckRun(GHWorkflowRun workflowRun,
return Optional.empty();
}

WorkflowReportJobIncludeStrategy workflowReportJobIncludeStrategy = buildReporterConfig
.getWorkflowReportJobIncludeStrategy() != null ? buildReporterConfig.getWorkflowReportJobIncludeStrategy()
: globalWorkflowReportJobIncludeStrategy;

try {
String name = WorkflowConstants.BUILD_SUMMARY_CHECK_RUN_PREFIX + workflowRun.getHeadSha();
String summary = workflowReportFormatter.getCheckRunReportSummary(workflowReport, workflowContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,24 @@

import org.kohsuke.github.GHWorkflowJob;

import io.quarkus.bot.buildreporter.githubactions.report.WorkflowReportJobIncludeStrategy;

public class BuildReporterConfig {

private final boolean dryRun;
private final WorkflowReportJobIncludeStrategy workflowReportJobIncludeStrategy;
private final Comparator<GHWorkflowJob> workflowJobComparator;
private final Set<String> monitoredWorkflows;
private final boolean createCheckRun;
private final boolean develocityEnabled;
private final String develocityUrl;

private BuildReporterConfig(boolean dryRun, Comparator<GHWorkflowJob> workflowJobComparator,
private BuildReporterConfig(boolean dryRun, WorkflowReportJobIncludeStrategy workflowReportJobIncludeStrategy,
Comparator<GHWorkflowJob> workflowJobComparator,
Set<String> monitoredWorkflows, boolean createCheckRun, boolean develocityEnabled,
String develocityUrl) {
this.dryRun = dryRun;
this.workflowReportJobIncludeStrategy = workflowReportJobIncludeStrategy;
this.workflowJobComparator = workflowJobComparator;
this.monitoredWorkflows = monitoredWorkflows;
this.createCheckRun = createCheckRun;
Expand All @@ -30,6 +35,10 @@ public boolean isDryRun() {
return dryRun;
}

public WorkflowReportJobIncludeStrategy getWorkflowReportJobIncludeStrategy() {
return workflowReportJobIncludeStrategy;
}

public Comparator<GHWorkflowJob> getJobNameComparator() {
return workflowJobComparator;
}
Expand Down Expand Up @@ -58,7 +67,8 @@ public static class Builder {

private boolean dryRun = false;
private boolean createCheckRun = true;
private Comparator<GHWorkflowJob> workflowJobComparator = DefaultJobNameComparator.INSTANCE;
private WorkflowReportJobIncludeStrategy workflowReportJobIncludeStrategy;
private Comparator<GHWorkflowJob> workflowJobComparator;
private Set<String> monitoredWorkflows = Collections.emptySet();
private boolean develocityEnabled;
private String develocityUrl;
Expand All @@ -68,6 +78,11 @@ public Builder dryRun(boolean dryRun) {
return this;
}

public Builder workflowReportJobIncludeStrategy(WorkflowReportJobIncludeStrategy workflowReportJobIncludeStrategy) {
this.workflowReportJobIncludeStrategy = workflowReportJobIncludeStrategy;
return this;
}

public Builder workflowJobComparator(Comparator<GHWorkflowJob> workflowJobComparator) {
this.workflowJobComparator = workflowJobComparator;
return this;
Expand All @@ -94,8 +109,9 @@ public Builder develocityUrl(String develocityUrl) {
}

public BuildReporterConfig build() {
return new BuildReporterConfig(dryRun, workflowJobComparator, monitoredWorkflows, createCheckRun,
develocityEnabled, develocityUrl);
return new BuildReporterConfig(dryRun, workflowReportJobIncludeStrategy,
workflowJobComparator != null ? workflowJobComparator : DefaultJobNameComparator.INSTANCE,
monitoredWorkflows, createCheckRun, develocityEnabled, develocityUrl);
}
}

Expand Down

0 comments on commit d7fc66e

Please sign in to comment.