diff --git a/github-bot/build.gradle b/github-bot/build.gradle index 002ac797b..4ae2f991a 100644 --- a/github-bot/build.gradle +++ b/github-bot/build.gradle @@ -5,31 +5,38 @@ plugins { } dependencies { - implementation 'io.quarkus:quarkus-info' - implementation 'io.quarkiverse.jgit:quarkus-jgit:3.0.6' implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}") + + implementation 'io.quarkus:quarkus-info' + implementation 'io.quarkiverse.jgit:quarkus-jgit:3.0.6' implementation 'io.quarkiverse.githubapi:quarkus-github-api:1.318.0' implementation 'io.quarkus:quarkus-arc' implementation "io.quarkus:quarkus-scheduler" implementation 'io.quarkus:quarkus-smallrye-health' - implementation project(path: ':spoon-analyzer') - testImplementation 'io.quarkus:quarkus-junit5' - implementation project(":code-transformation") - annotationProcessor("io.quarkus:quarkus-panache-common") + implementation("io.quarkus:quarkus-smallrye-graphql") - testImplementation("io.quarkus:quarkus-smallrye-graphql-client") implementation 'io.quarkiverse.quinoa:quarkus-quinoa:2.3.2' implementation("io.quarkus:quarkus-oidc") implementation("io.quarkus:quarkus-keycloak-authorization") implementation("io.quarkus:quarkus-micrometer-registry-prometheus") - testImplementation group: 'org.assertj', name: 'assertj-core', version: '3.25.1' - implementation project(":commons") implementation "io.quarkiverse.loggingmanager:quarkus-logging-manager:3.0.3" - testImplementation 'org.mockito:mockito-core:5.8.0' implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.16.1' - annotationProcessor("io.quarkus:quarkus-panache-common") implementation("io.quarkus:quarkus-hibernate-orm-panache") implementation("io.quarkus:quarkus-jdbc-mariadb") + implementation("io.quarkus:quarkus-opentelemetry") + + implementation project(":commons") + implementation project(path: ':spoon-analyzer') + implementation project(":code-transformation") + + testImplementation 'org.mockito:mockito-core:5.8.0' + testImplementation group: 'org.assertj', name: 'assertj-core', version: '3.25.1' + testImplementation 'io.quarkus:quarkus-junit5' + testImplementation("io.quarkus:quarkus-smallrye-graphql-client") + + annotationProcessor("io.quarkus:quarkus-panache-common") + annotationProcessor("io.quarkus:quarkus-panache-common") + } diff --git a/github-bot/src/main/java/io/github/martinwitt/laughing_train/services/AnalyzerResultPersistenceService.java b/github-bot/src/main/java/io/github/martinwitt/laughing_train/services/AnalyzerResultPersistenceService.java index 371ab1d0e..b65baa06b 100644 --- a/github-bot/src/main/java/io/github/martinwitt/laughing_train/services/AnalyzerResultPersistenceService.java +++ b/github-bot/src/main/java/io/github/martinwitt/laughing_train/services/AnalyzerResultPersistenceService.java @@ -2,14 +2,11 @@ import com.google.common.flogger.FluentLogger; import io.github.martinwitt.laughing_train.commons.GitProject; -import io.github.martinwitt.laughing_train.data.QodanaResult; import io.github.martinwitt.laughing_train.data.result.CodeAnalyzerResult; import io.github.martinwitt.laughing_train.persistence.BadSmell; import io.github.martinwitt.laughing_train.persistence.repository.BadSmellRepository; -import io.smallrye.mutiny.Multi; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; -import java.util.stream.Collectors; @ApplicationScoped public class AnalyzerResultPersistenceService { @@ -17,28 +14,6 @@ public class AnalyzerResultPersistenceService { @Inject BadSmellRepository badSmellRepository; - void persistResults(QodanaResult result) { - if (result instanceof QodanaResult.Success success) { - GitProject gitProject = success.gitProject(); - Multi.createFrom() - .iterable(success.result()) - .map( - badSmell -> - new BadSmell( - badSmell, gitProject.name(), gitProject.url(), gitProject.commitHash())) - .filter(v -> badSmellRepository.findByIdentifier(v.getIdentifier()).isEmpty()) - .map(badSmellRepository::save) - .collect() - .with(Collectors.counting()) - .subscribe() - .with( - badSmell -> - logger.atInfo().log( - "Persisted %d qodana bad smells for project %s", - badSmell, gitProject.name())); - } - } - void persistResults(CodeAnalyzerResult.Success success) { logger.atInfo().log( "Persisting %s results for project %s", diff --git a/github-bot/src/main/resources/application.properties b/github-bot/src/main/resources/application.properties index 5ddf09d4a..544031aa8 100644 --- a/github-bot/src/main/resources/application.properties +++ b/github-bot/src/main/resources/application.properties @@ -10,10 +10,8 @@ quarkus.oidc.tls.verification=none %prod.quarkus.http.auth.permission.authenticated.policy=authenticated %dev.quarkus.smallrye-graphql.log-payload=queryAndVariables quarkus.smallrye-graphql.error-extension-fields=[exception,classification,code,description,validationErrorType,queryPath] -quarkus.ssl.native=true quarkus.http.proxy.proxy-address-forwarding=true quarkus.http.proxy.allow-forwarded=true -quarkus.http.proxy.allow-x-forwarded=true quarkus.http.proxy.enable-forwarded-host=true quarkus.http.proxy.enable-forwarded-prefix=true %dev.quarkus.scheduler.enabled=false @@ -24,5 +22,5 @@ quarkus.http.cors.origins=* quarkus.vertx.max-worker-execute-time=30m %test.quarkus.scheduler.enabled=false quarkus.datasource.db-kind = mariadb -quarkus.hibernate-orm.database.generation = drop-and-create +quarkus.hibernate-orm.database.generation = update %dev.quarkus.quinoa=false \ No newline at end of file diff --git a/github-bot/src/test/java/io/github/martinwitt/laughing_train/mining/AnalyzerResultsPersistenceTest.java b/github-bot/src/test/java/io/github/martinwitt/laughing_train/mining/AnalyzerResultsPersistenceTest.java index 461d450ef..1b6da8a15 100644 --- a/github-bot/src/test/java/io/github/martinwitt/laughing_train/mining/AnalyzerResultsPersistenceTest.java +++ b/github-bot/src/test/java/io/github/martinwitt/laughing_train/mining/AnalyzerResultsPersistenceTest.java @@ -6,6 +6,7 @@ import io.github.martinwitt.laughing_train.data.result.CodeAnalyzerResult; import io.github.martinwitt.laughing_train.mining.api.AnalyzerRunRepository; import io.github.martinwitt.laughing_train.mining.requests.StoreResults; +import io.quarkus.test.TestTransaction; import io.quarkus.test.junit.QuarkusTest; import jakarta.inject.Inject; import org.instancio.Instancio; @@ -18,6 +19,7 @@ class AnalyzerResultsPersistenceTest { @Inject AnalyzerRunRepository analyzerRunRepository; @Test + @TestTransaction void persistResults() { StoreResults storeResults = new StoreResults( diff --git a/github-bot/src/test/java/io/github/martinwitt/laughing_train/persistence/impl/SqlProjectRepositoryTest.java b/github-bot/src/test/java/io/github/martinwitt/laughing_train/persistence/impl/SqlProjectRepositoryTest.java index 130e76c58..ec93462f9 100644 --- a/github-bot/src/test/java/io/github/martinwitt/laughing_train/persistence/impl/SqlProjectRepositoryTest.java +++ b/github-bot/src/test/java/io/github/martinwitt/laughing_train/persistence/impl/SqlProjectRepositoryTest.java @@ -1,23 +1,23 @@ package io.github.martinwitt.laughing_train.persistence.impl; -import static org.assertj.core.api.Assertions.assertThat; - import io.github.martinwitt.laughing_train.domain.entity.RemoteProject; -import io.github.martinwitt.laughing_train.mining.api.AnalyzerRunRepository; +import io.quarkus.test.TestTransaction; import io.quarkus.test.junit.QuarkusTest; import jakarta.inject.Inject; -import java.util.List; import org.instancio.Instancio; import org.junit.jupiter.api.Test; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + @QuarkusTest class SqlProjectRepositoryTest { @Inject SqlProjectRepository sqlProjectRepository; - @Inject AnalyzerRunRepository sqlAnalyzerRunRepository; - @Test + @TestTransaction void insertProject() { RemoteProject remoteProject = Instancio.create(RemoteProject.class); sqlProjectRepository.save(remoteProject);