Skip to content

Commit

Permalink
Prepare Quarkus LangChain4j arrival
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmet committed Nov 8, 2024
1 parent ef1e924 commit cca4614
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<formatter-plugin.version>2.24.1</formatter-plugin.version>

<quarkus-github-action.version>2.4.0</quarkus-github-action.version>
<build-reporter.version>3.9.5</build-reporter.version>
<build-reporter.version>3.9.6</build-reporter.version>
</properties>
<dependencyManagement>
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import io.quarkiverse.githubaction.Commands;
import io.quarkiverse.githubaction.Context;
import io.quarkiverse.githubaction.Inputs;
import io.quarkus.bot.action.buildreporter.workflow.QuarkusWorkflowConstants;
import io.quarkus.bot.buildreporter.githubactions.BuildReporterActionHandler;
import io.quarkus.bot.buildreporter.githubactions.BuildReporterConfig;

Expand Down Expand Up @@ -50,10 +49,24 @@ void postJobSummary(Inputs inputs, Commands commands, Context context, GitHub gi
return;
}

Comparator<GHWorkflowJob> workflowJobComparator;

switch (context.getGitHubRepository()) {
case "quarkusio/quarkus":
workflowJobComparator = QuarkusWorkflowJobComparator.INSTANCE;
break;
case "quarkiverse/quarkus-langchain4j":
workflowJobComparator = QuarkusLangChain4jWorkflowJobComparator.INSTANCE;
break;
default:
// it will use the default ones
workflowJobComparator = null;
}

BuildReporterConfig buildReporterConfig = new BuildReporterConfig.Builder()
// only create check run and annotation if this is a fork
.createCheckRun(workflowRun.getRepository().isFork())
.workflowJobComparator(QuarkusWorkflowJobComparator.INSTANCE)
.workflowJobComparator(workflowJobComparator)
.build();

Optional<String> report = buildReporterActionHandler.generateReport(context.getGitHubWorkflow(), workflowRun,
Expand All @@ -72,16 +85,101 @@ private final static class QuarkusWorkflowJobComparator implements Comparator<GH

@Override
public int compare(GHWorkflowJob o1, GHWorkflowJob o2) {
if (o1.getName().startsWith(QuarkusWorkflowConstants.JOB_NAME_INITIAL_JDK_PREFIX)
&& !o2.getName().startsWith(QuarkusWorkflowConstants.JOB_NAME_INITIAL_JDK_PREFIX)) {
return -1;
int order1 = getOrder(o1.getName());
int order2 = getOrder(o2.getName());

if (order1 == order2) {
return o1.getName().compareToIgnoreCase(o2.getName());
}
if (!o1.getName().startsWith(QuarkusWorkflowConstants.JOB_NAME_INITIAL_JDK_PREFIX)
&& o2.getName().startsWith(QuarkusWorkflowConstants.JOB_NAME_INITIAL_JDK_PREFIX)) {

return order1 - order2;
}

private static int getOrder(String jobName) {
if (jobName.startsWith("Initial JDK")) {
return 1;
}
if (jobName.startsWith("Calculate Test Jobs")) {
return 2;
}
if (jobName.startsWith("JVM Tests - ")) {
if (jobName.contains("Windows")) {
return 12;
}
return 11;
}
if (jobName.startsWith("Maven Tests - ")) {
if (jobName.contains("Windows")) {
return 22;
}
return 21;
}
if (jobName.startsWith("Gradle Tests - ")) {
if (jobName.contains("Windows")) {
return 32;
}
return 31;
}
if (jobName.startsWith("Devtools Tests - ")) {
if (jobName.contains("Windows")) {
return 42;
}
return 41;
}
if (jobName.startsWith("Kubernetes Tests - ")) {
if (jobName.contains("Windows")) {
return 52;
}
return 51;
}
if (jobName.startsWith("Quickstarts Compilation")) {
return 61;
}
if (jobName.startsWith("MicroProfile TCKs Tests")) {
return 71;
}
if (jobName.startsWith("Native Tests - ")) {
if (jobName.contains("Windows")) {
return 82;
}
return 81;
}

return 200;
}
}

private final static class QuarkusLangChain4jWorkflowJobComparator implements Comparator<GHWorkflowJob> {

private static final QuarkusLangChain4jWorkflowJobComparator INSTANCE = new QuarkusLangChain4jWorkflowJobComparator();

@Override
public int compare(GHWorkflowJob o1, GHWorkflowJob o2) {
int order1 = getOrder(o1.getName());
int order2 = getOrder(o2.getName());

if (order1 == order2) {
return o1.getName().compareToIgnoreCase(o2.getName());
}

return order1 - order2;
}

private static int getOrder(String jobName) {
if (jobName.startsWith("Quick Build")) {
return 1;
}
if (jobName.startsWith("JVM tests - ")) {
return 2;
}
if (jobName.startsWith("Native tests - ")) {
return 12;
}
if (jobName.startsWith("In process embedding model tests - ")) {
return 22;
}

return o1.getName().compareTo(o2.getName());
return 200;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class QuarkusWorkflowConstants {
public static final String JOB_NAME_INITIAL_JDK_PREFIX = "Initial JDK ";
public static final String JOB_NAME_JVM_TESTS_PREFIX = "JVM Tests";
public static final String JOB_NAME_JDK_PREFIX = "JDK";
public static final String JOB_NAME_JAVA_PREFIX = "Java";
public static final String JOB_NAME_WINDOWS = "Windows";
public static final String JOB_NAME_BUILD_REPORT = "Build report";
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public String label(String name) {
String[] tokens = name.split(QuarkusWorkflowConstants.JOB_NAME_DELIMITER);

for (int i = 0; i < tokens.length; i++) {
if (tokens[i].startsWith(QuarkusWorkflowConstants.JOB_NAME_JDK_PREFIX)) {
if (tokens[i].startsWith(QuarkusWorkflowConstants.JOB_NAME_JDK_PREFIX)
|| tokens[i].startsWith(QuarkusWorkflowConstants.JOB_NAME_JAVA_PREFIX)) {
break;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.quarkus.bot.action.buildreporter.workflow.report;

import java.util.Locale;

import jakarta.inject.Singleton;

import io.quarkus.bot.action.buildreporter.workflow.QuarkusWorkflowConstants;
Expand Down Expand Up @@ -38,7 +40,8 @@ public boolean include(WorkflowReport report, WorkflowReportJob job) {
}

private static boolean isJvmTests(WorkflowReportJob job) {
return job.getName().startsWith(QuarkusWorkflowConstants.JOB_NAME_JVM_TESTS_PREFIX);
return job.getName().toLowerCase(Locale.ROOT)
.startsWith(QuarkusWorkflowConstants.JOB_NAME_JVM_TESTS_PREFIX.toLowerCase(Locale.ROOT));
}

private static boolean isWindows(WorkflowReportJob job) {
Expand Down

0 comments on commit cca4614

Please sign in to comment.