diff --git a/src/main/java/git/tracehub/codereview/action/Entry.java b/src/main/java/git/tracehub/codereview/action/Entry.java index d8d91ad..5833175 100644 --- a/src/main/java/git/tracehub/codereview/action/Entry.java +++ b/src/main/java/git/tracehub/codereview/action/Entry.java @@ -23,7 +23,11 @@ */ package git.tracehub.codereview.action; +import com.jcabi.github.Coordinates; +import com.jcabi.github.Repo; +import com.jcabi.github.RtGithub; import com.jcabi.log.Logger; +import git.tracehub.codereview.action.github.JsonPull; import java.io.IOException; import java.io.StringReader; import java.nio.file.Files; @@ -42,10 +46,29 @@ public final class Entry { /** * Application entry point. + * * @param args Application arguments * @throws IOException if I/O fails. + * @todo #2:25min Implement GhIdentity. + * For now we do create RtGithub right here, in the main method. + * Let's implement some sort of "smart" identity that based on + * INPUT_GITHUBTOKEN variable presence inside the environment will + * create corresponding object, either RtGithub (real github instance) + * or MkGithub (mocked github server in memory xml). + * @todo #2:30min Develop a prompt to the language model. + * After information is collected (pull request itself, its files, + * and reviews) we can feed it into the model asking what is the quality + * of the following code review. + * @todo #2:30min Fetch all the info about pull request we are working with. + * We should fetch all useful information about pull request that we are dealing with: + * title, files (changes), and its author. Let's present this data in JSON/XML format. + * @todo #2:30min Formulate action stoppers. + * We should formulate some action stoppers that would not "go further" + * into processing if: pull request is too small (we need a specific number), + * or some other alerts that would be reasonable. */ public static void main(final String... args) throws IOException { + final String name = System.getenv().get("GITHUB_REPOSITORY"); final JsonObject event = Json.createReader( new StringReader( new String( @@ -58,5 +81,10 @@ public static void main(final String... args) throws IOException { ) ).readObject(); Logger.info(Entry.class, "event received %s", event.toString()); + final Repo repo = new RtGithub( + System.getenv().get("INPUT_GITHUBTOKEN") + ).repos().get(new Coordinates.Simple(name)); + final JsonObject pull = new JsonPull(repo, event).value(); + Logger.info(Entry.class, "pull request found: %s", pull); } } diff --git a/src/test/java/git/tracehub/codereview/action/EntryTest.java b/src/test/java/git/tracehub/codereview/action/EntryTest.java deleted file mode 100644 index 99acf97..0000000 --- a/src/test/java/git/tracehub/codereview/action/EntryTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2024 Tracehub.git - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package git.tracehub.codereview.action; - -import org.junit.jupiter.api.Test; - -/** - * Test case for {@link Entry}. - * - * @since 0.0.0 - */ -final class EntryTest { - - /** - * Test. - * @todo #1:25min Remove EntryTest#foo test. - * This test was required only to pass the first build, since we need at - * least one test to run the `install` maven phase. - * Don't forget to remove this puzzle. - */ - @Test - @SuppressWarnings( - { - "JTCOP.RulePresentTense", - "JTCOP.RuleAssertionMessage", - "PMD.UncommentedEmptyMethodBody" - } - ) - void foo() { - } -}