Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ✨ Separated Qodana and Spoon mining #729

Merged
merged 1 commit into from
Jun 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,54 @@ private Project getKnownProject() {
}

void mine(@Observes StartupEvent event) {
vertx.setTimer(TimeUnit.MINUTES.toMillis(5), v -> vertx.executeBlocking(it -> mineRandomRepo()));
vertx.setTimer(TimeUnit.MINUTES.toMillis(5), v -> vertx.executeBlocking(it -> mineRandomRepoQodana()));
vertx.setTimer(TimeUnit.MINUTES.toMillis(5), v -> vertx.executeBlocking(it -> mineRandomRepoSpoon()));
}

private void mineRandomRepo() {
private void mineRandomRepoQodana() {
try {
var project = queue.isEmpty() ? getRandomProject() : queue.poll();
var checkoutResult = checkoutProject(project);
if (checkoutResult instanceof ProjectResult.Error) {
logger.atWarning().log("Failed to checkout project %s", project);
mineRandomRepo();
mineRandomRepoQodana();
return;
}
if (checkoutResult instanceof ProjectResult.Success success) {
logger.atInfo().log("Successfully checked out project %s", success.project());
var qodanaResult = analyzeProject(success);

if (qodanaResult instanceof QodanaResult.Failure failure) {
logger.atWarning().log("Failed to analyze project %s", failure.message());
tryDeleteProject(success);
return;
}
if (qodanaResult instanceof QodanaResult.Success successResult) {
logger.atInfo().log("Successfully analyzed project %s", success.project());
saveQodanaResults(successResult);
addOrUpdateCommitHash(success);
}
}
} catch (Exception e) {
logger.atWarning().withCause(e).log("Failed to mine random repo");
} finally {
logger.atInfo().log("Queue size: %s", queue.size());
logger.atInfo().log("Mining next repo in 1 minute");
vertx.setTimer(TimeUnit.MINUTES.toMillis(1), v -> vertx.executeBlocking(it -> mineRandomRepoQodana()));
}
}

private void mineRandomRepoSpoon() {
try {
var project = queue.isEmpty() ? getRandomProject() : queue.poll();
var checkoutResult = checkoutProject(project);
if (checkoutResult instanceof ProjectResult.Error) {
logger.atWarning().log("Failed to checkout project %s", project);
mineRandomRepoSpoon();
return;
}
if (checkoutResult instanceof ProjectResult.Success success) {
logger.atInfo().log("Successfully checked out project %s", success.project());
var spoonPatternAnalyzerResult =
spoonPatternAnalyzer.analyze(new AnalyzerRequest.WithProject(success.project()));

Expand All @@ -106,28 +139,16 @@ private void mineRandomRepo() {
}
if (spoonPatternAnalyzerResult instanceof SpoonPatternAnalyzerResult.Failure failure) {
logger.atWarning().log("Failed to analyze project with spoon %s", failure.message());
registry.counter("mining.spoon.error").increment();
tryDeleteProject(success);
}
if (qodanaResult instanceof QodanaResult.Failure failure) {
logger.atWarning().log("Failed to analyze project %s", failure.message());
registry.counter("mining.qodana.error").increment();
tryDeleteProject(success);
return;
}
if (qodanaResult instanceof QodanaResult.Success successResult) {
logger.atInfo().log("Successfully analyzed project %s", success.project());
saveQodanaResults(successResult);
addOrUpdateCommitHash(success);
}
}
} catch (Exception e) {
logger.atWarning().withCause(e).log("Failed to mine random repo");
registry.counter("mining.error").increment();
} finally {
logger.atInfo().log("Queue size: %s", queue.size());
logger.atInfo().log("Mining next repo in 1 minute");
vertx.setTimer(TimeUnit.MINUTES.toMillis(1), v -> vertx.executeBlocking(it -> mineRandomRepo()));
vertx.setTimer(TimeUnit.MINUTES.toMillis(1), v -> vertx.executeBlocking(it -> mineRandomRepoSpoon()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import io.smallrye.graphql.client.dynamic.api.DynamicGraphQLClientBuilder;
import jakarta.inject.Inject;
import java.util.regex.Pattern;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

Expand Down