From 16ed039aaffcb36172210723cf0af47ab2497848 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Thu, 23 Nov 2023 21:34:57 +0100 Subject: [PATCH] Install an ugly CDI workaround --- .../io/quarkus/bot/release/ReleaseAction.java | 11 +++++++++++ .../bot/release/step/ApproveCoreRelease.java | 3 +++ .../bot/release/step/CoreReleasePrepare.java | 3 +++ .../bot/release/step/Prerequisites.java | 4 ++-- .../io/quarkus/bot/release/IssuesTest.java | 2 ++ .../quarkus/bot/release/StepInjectionTest.java | 18 ++++++++++++++++++ 6 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 src/test/java/io/quarkus/bot/release/StepInjectionTest.java diff --git a/src/main/java/io/quarkus/bot/release/ReleaseAction.java b/src/main/java/io/quarkus/bot/release/ReleaseAction.java index 37c8144..6b47384 100644 --- a/src/main/java/io/quarkus/bot/release/ReleaseAction.java +++ b/src/main/java/io/quarkus/bot/release/ReleaseAction.java @@ -23,6 +23,9 @@ import io.quarkus.arc.InstanceHandle; import io.quarkus.bot.release.error.StatusUpdateException; import io.quarkus.bot.release.error.StepExecutionException; +import io.quarkus.bot.release.step.ApproveCoreRelease; +import io.quarkus.bot.release.step.CoreReleasePrepare; +import io.quarkus.bot.release.step.Prerequisites; import io.quarkus.bot.release.step.Step; import io.quarkus.bot.release.step.StepHandler; import io.quarkus.bot.release.step.StepStatus; @@ -40,6 +43,14 @@ public class ReleaseAction { @Inject Processes processes; + // ugly workaround... + @Inject + Prerequisites prerequisites; + @Inject + ApproveCoreRelease approveCoreRelease; + @Inject + CoreReleasePrepare coreReleasePrepare; + @Action void startRelease(Context context, Commands commands, @Issue.Opened GHEventPayload.Issue issuePayload) throws Exception { GHIssue issue = issuePayload.getIssue(); diff --git a/src/main/java/io/quarkus/bot/release/step/ApproveCoreRelease.java b/src/main/java/io/quarkus/bot/release/step/ApproveCoreRelease.java index c9d5472..92f2385 100644 --- a/src/main/java/io/quarkus/bot/release/step/ApproveCoreRelease.java +++ b/src/main/java/io/quarkus/bot/release/step/ApproveCoreRelease.java @@ -2,6 +2,8 @@ import java.io.IOException; +import jakarta.inject.Singleton; + import org.kohsuke.github.GHIssue; import org.kohsuke.github.GHIssueComment; @@ -9,6 +11,7 @@ import io.quarkus.bot.release.ReleaseStatus; import io.quarkus.bot.release.util.Command; +@Singleton public class ApproveCoreRelease implements StepHandler { @Override diff --git a/src/main/java/io/quarkus/bot/release/step/CoreReleasePrepare.java b/src/main/java/io/quarkus/bot/release/step/CoreReleasePrepare.java index a94d461..a0a4182 100644 --- a/src/main/java/io/quarkus/bot/release/step/CoreReleasePrepare.java +++ b/src/main/java/io/quarkus/bot/release/step/CoreReleasePrepare.java @@ -2,10 +2,13 @@ import java.io.IOException; +import jakarta.inject.Singleton; + import org.kohsuke.github.GHIssue; import io.quarkus.bot.release.ReleaseInformation; +@Singleton public class CoreReleasePrepare implements StepHandler { @Override diff --git a/src/main/java/io/quarkus/bot/release/step/Prerequisites.java b/src/main/java/io/quarkus/bot/release/step/Prerequisites.java index 8847acc..532a567 100644 --- a/src/main/java/io/quarkus/bot/release/step/Prerequisites.java +++ b/src/main/java/io/quarkus/bot/release/step/Prerequisites.java @@ -6,8 +6,8 @@ import java.util.ArrayList; import java.util.List; -import jakarta.enterprise.context.Dependent; import jakarta.inject.Inject; +import jakarta.inject.Singleton; import org.kohsuke.github.GHIssue; @@ -15,7 +15,7 @@ import io.quarkus.bot.release.util.Issues; import io.quarkus.bot.release.util.Processes; -@Dependent +@Singleton public class Prerequisites implements StepHandler { @Inject diff --git a/src/test/java/io/quarkus/bot/release/IssuesTest.java b/src/test/java/io/quarkus/bot/release/IssuesTest.java index 8371c95..d97da83 100644 --- a/src/test/java/io/quarkus/bot/release/IssuesTest.java +++ b/src/test/java/io/quarkus/bot/release/IssuesTest.java @@ -7,6 +7,8 @@ import org.junit.jupiter.api.Test; +import io.quarkus.arc.Arc; +import io.quarkus.bot.release.step.Prerequisites; import io.quarkus.bot.release.step.Step; import io.quarkus.bot.release.step.StepStatus; import io.quarkus.bot.release.util.Issues; diff --git a/src/test/java/io/quarkus/bot/release/StepInjectionTest.java b/src/test/java/io/quarkus/bot/release/StepInjectionTest.java new file mode 100644 index 0000000..a6c1be3 --- /dev/null +++ b/src/test/java/io/quarkus/bot/release/StepInjectionTest.java @@ -0,0 +1,18 @@ +package io.quarkus.bot.release; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; + +import io.quarkus.arc.Arc; +import io.quarkus.bot.release.step.Prerequisites; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +public class StepInjectionTest { + + @Test + void testStepInjection() { + assertThat(Arc.container().instance(Prerequisites.class).get()).isNotNull(); + } +}