Skip to content

Commit

Permalink
Rename io.xstefank.wildfly -> org.wildfly
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir284 committed Mar 25, 2024
1 parent dd4fc98 commit 746e983
Show file tree
Hide file tree
Showing 59 changed files with 504 additions and 558 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>io.xstefank</groupId>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-github-app</artifactId>
<version>1.0.0-SNAPSHOT</version>
<properties>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package io.xstefank.wildfly.bot;
package org.wildfly.bot;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.quarkiverse.githubapp.event.PullRequest;
import io.quarkiverse.githubapp.runtime.UtilsProducer;
import io.quarkiverse.githubapp.runtime.github.GitHubConfigFileProviderImpl;
import io.xstefank.wildfly.bot.model.RuntimeConstants;
import io.xstefank.wildfly.bot.model.WildFlyConfigFile;
import io.xstefank.wildfly.bot.util.GithubProcessor;
import io.xstefank.wildfly.bot.util.PullRequestLogger;
import org.wildfly.bot.model.RuntimeConstants;
import org.wildfly.bot.model.WildFlyConfigFile;
import org.wildfly.bot.util.GithubProcessor;
import org.wildfly.bot.util.PullRequestLogger;
import jakarta.enterprise.context.RequestScoped;
import jakarta.inject.Inject;
import org.jboss.logging.Logger;
Expand All @@ -29,8 +29,6 @@
import java.util.Set;
import java.util.stream.Collectors;

import static io.xstefank.wildfly.bot.model.RuntimeConstants.FAILED_CONFIGFILE_COMMENT;

@RequestScoped
public class ConfigFileChangeProcessor {

Expand Down Expand Up @@ -77,7 +75,7 @@ void onFileChanged(
"One or multiple rules are invalid, please see the comment stating the problems");
LOG.warnf("Configuration File check unsuccessful. %s", String.join(",", problems));
}
githubProcessor.formatComment(pullRequest, FAILED_CONFIGFILE_COMMENT, problems);
githubProcessor.formatComment(pullRequest, RuntimeConstants.FAILED_CONFIGFILE_COMMENT, problems);
} else {
String message = "Configuration File check unsuccessful. Unable to correctly map loaded file to YAML.";
githubProcessor.commitStatusError(pullRequest, CHECK_NAME, message);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package io.xstefank.wildfly.bot;
package org.wildfly.bot;

import io.quarkiverse.githubapp.ConfigFile;
import io.quarkiverse.githubapp.GitHubClientProvider;
import io.quarkiverse.githubapp.GitHubConfigFileProvider;
import io.quarkiverse.githubapp.event.Installation;
import io.quarkus.logging.Log;
import io.quarkus.runtime.StartupEvent;
import io.xstefank.wildfly.bot.config.WildFlyBotConfig;
import io.xstefank.wildfly.bot.model.RuntimeConstants;
import io.xstefank.wildfly.bot.model.WildFlyConfigFile;
import io.xstefank.wildfly.bot.util.GithubProcessor;
import org.wildfly.bot.config.WildFlyBotConfig;
import org.wildfly.bot.model.RuntimeConstants;
import org.wildfly.bot.model.WildFlyConfigFile;
import org.wildfly.bot.util.GithubProcessor;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.event.Observes;
import jakarta.enterprise.inject.Any;
Expand All @@ -26,9 +26,6 @@
import java.util.Set;
import java.util.stream.Collectors;

import static io.xstefank.wildfly.bot.model.RuntimeConstants.LABEL_FIX_ME;
import static io.xstefank.wildfly.bot.model.RuntimeConstants.LABEL_NEEDS_REBASE;

@ApplicationScoped
public class LifecycleProcessor {

Expand Down Expand Up @@ -79,7 +76,8 @@ void onStart(@Observes StartupEvent event) {
List<String> emailAddresses = wildflyBotConfigFile.wildfly.emails;
List<String> problems = configFileChangeProcessor.validateFile(wildflyBotConfigFile, repository);

githubProcessor.createLabelsIfMissing(repository, Set.of(LABEL_NEEDS_REBASE, LABEL_FIX_ME));
githubProcessor.createLabelsIfMissing(repository,
Set.of(RuntimeConstants.LABEL_NEEDS_REBASE, RuntimeConstants.LABEL_FIX_ME));

if (problems.isEmpty()) {
LOG.infof("The configuration file from the repository %s was parsed successfully.",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package io.xstefank.wildfly.bot;
package org.wildfly.bot;

import io.quarkiverse.githubapp.ConfigFile;
import io.quarkiverse.githubapp.event.PullRequest;
import io.xstefank.wildfly.bot.config.WildFlyBotConfig;
import io.xstefank.wildfly.bot.format.Check;
import io.xstefank.wildfly.bot.format.CommitMessagesCheck;
import io.xstefank.wildfly.bot.format.DescriptionCheck;
import io.xstefank.wildfly.bot.format.TitleCheck;
import io.xstefank.wildfly.bot.model.RegexDefinition;
import io.xstefank.wildfly.bot.model.RuntimeConstants;
import io.xstefank.wildfly.bot.model.WildFlyConfigFile;
import io.xstefank.wildfly.bot.util.GithubProcessor;
import io.xstefank.wildfly.bot.util.PullRequestLogger;
import org.wildfly.bot.config.WildFlyBotConfig;
import org.wildfly.bot.format.Check;
import org.wildfly.bot.format.CommitMessagesCheck;
import org.wildfly.bot.format.DescriptionCheck;
import org.wildfly.bot.format.TitleCheck;
import org.wildfly.bot.model.RegexDefinition;
import org.wildfly.bot.model.RuntimeConstants;
import org.wildfly.bot.model.WildFlyConfigFile;
import org.wildfly.bot.util.GithubProcessor;
import org.wildfly.bot.util.PullRequestLogger;
import jakarta.enterprise.context.RequestScoped;
import jakarta.inject.Inject;
import org.jboss.logging.Logger;
Expand All @@ -20,6 +20,7 @@
import org.kohsuke.github.GHPullRequest;
import org.kohsuke.github.GHPullRequestCommitDetail;
import org.kohsuke.github.PagedIterable;
import org.wildfly.bot.util.Strings;

import java.io.IOException;
import java.util.ArrayList;
Expand All @@ -32,11 +33,6 @@
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import static io.xstefank.wildfly.bot.model.RuntimeConstants.BOT_REPO_REF_FOOTER;
import static io.xstefank.wildfly.bot.model.RuntimeConstants.DEPENDABOT;
import static io.xstefank.wildfly.bot.model.RuntimeConstants.FAILED_FORMAT_COMMENT;
import static io.xstefank.wildfly.bot.util.Strings.blockQuoted;

@RequestScoped
public class PullRequestFormatProcessor {

Expand Down Expand Up @@ -66,7 +62,7 @@ void pullRequestFormatCheck(
githubProcessor.commitStatusSuccess(pullRequest, CHECK_NAME, "Valid [Skipped]");
}
}
githubProcessor.deleteFormatComment(pullRequest, FAILED_FORMAT_COMMENT);
githubProcessor.deleteFormatComment(pullRequest, RuntimeConstants.FAILED_FORMAT_COMMENT);
LOG.infof("Skipping format due to %s", message);
return;
}
Expand All @@ -93,9 +89,10 @@ void pullRequestFormatCheck(
} else {
githubProcessor.commitStatusError(pullRequest, CHECK_NAME, "Failed checks: " + String.join(", ", errors.keySet()));
}
githubProcessor.formatComment(pullRequest, FAILED_FORMAT_COMMENT, errors.values());
githubProcessor.formatComment(pullRequest, RuntimeConstants.FAILED_FORMAT_COMMENT, errors.values());

String updatedBody = pullRequest.getBody() + BOT_REPO_REF_FOOTER.formatted(wildFlyBotConfig.githubName());
String updatedBody = pullRequest.getBody()
+ RuntimeConstants.BOT_REPO_REF_FOOTER.formatted(wildFlyBotConfig.githubName());
pullRequest.setBody(updatedBody);
}

Expand All @@ -105,7 +102,7 @@ void postDependabotInfo(@PullRequest.Opened GHEventPayload.PullRequest pullReque
LOG.setPullRequest(pullRequest);
githubProcessor.LOG.setPullRequest(pullRequest);

if (pullRequest.getUser().getLogin().equals(DEPENDABOT)) {
if (pullRequest.getUser().getLogin().equals(RuntimeConstants.DEPENDABOT)) {
LOG.infof("Dependabot detected.");
String comment = ("WildFly Bot recognized this PR as dependabot dependency update. Please create a %s issue" +
" and add new comment containing this JIRA link please.")
Expand Down Expand Up @@ -156,11 +153,11 @@ private void generateAppendedMessage(GHPullRequest pullRequest, Pattern projectP

sb.append(RuntimeConstants.BOT_MESSAGE_HEADER)
.append("\n\n")
.append(blockQuoted(RuntimeConstants.BOT_JIRA_LINKS_HEADER));
.append(Strings.blockQuoted(RuntimeConstants.BOT_JIRA_LINKS_HEADER));

for (String jira : jiraIssues) {

sb.append(blockQuoted(String.format(RuntimeConstants.BOT_JIRA_LINK_COMMENT_TEMPLATE, jira)));
sb.append(Strings.blockQuoted(String.format(RuntimeConstants.BOT_JIRA_LINK_COMMENT_TEMPLATE, jira)));
}

sb.append(RuntimeConstants.BOT_MESSAGE_FOOTER);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
package io.xstefank.wildfly.bot;
package org.wildfly.bot;

import io.quarkiverse.githubapp.event.PullRequest;
import io.xstefank.wildfly.bot.util.GithubProcessor;
import io.xstefank.wildfly.bot.util.PullRequestLogger;
import org.wildfly.bot.util.GithubProcessor;
import org.wildfly.bot.util.PullRequestLogger;
import jakarta.inject.Inject;
import org.jboss.logging.Logger;
import org.kohsuke.github.GHEventPayload;
import org.kohsuke.github.GHPullRequest;
import org.wildfly.bot.model.RuntimeConstants;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import static io.xstefank.wildfly.bot.model.RuntimeConstants.LABEL_FIX_ME;
import static io.xstefank.wildfly.bot.model.RuntimeConstants.LABEL_NEEDS_REBASE;

public class PullRequestLabelProcessor {

private static final Logger LOG_DELEGATE = Logger.getLogger(PullRequestFormatProcessor.class);
Expand All @@ -37,13 +35,13 @@ void pullRequestLabelCheck(@PullRequest.Synchronize @PullRequest.Reopened GHEven
}

List<String> labelsToAdd = new ArrayList<>();
List<String> labelsToRemove = new ArrayList<>(List.of(LABEL_FIX_ME));
List<String> labelsToRemove = new ArrayList<>(List.of(RuntimeConstants.LABEL_FIX_ME));

// By default, if we do not know the state, consider it mergable.
if (!Optional.ofNullable(pullRequest.getMergeable()).orElse(true)) {
labelsToAdd.add(LABEL_NEEDS_REBASE);
labelsToAdd.add(RuntimeConstants.LABEL_NEEDS_REBASE);
} else {
labelsToRemove.add(LABEL_NEEDS_REBASE);
labelsToRemove.add(RuntimeConstants.LABEL_NEEDS_REBASE);
}

githubProcessor.updateLabels(pullRequest, labelsToAdd, labelsToRemove);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package io.xstefank.wildfly.bot;
package org.wildfly.bot;

import io.quarkiverse.githubapp.event.PullRequestReview;
import io.xstefank.wildfly.bot.config.WildFlyBotConfig;
import io.xstefank.wildfly.bot.model.RuntimeConstants;
import io.xstefank.wildfly.bot.util.GithubProcessor;
import io.xstefank.wildfly.bot.util.PullRequestLogger;
import org.wildfly.bot.config.WildFlyBotConfig;
import org.wildfly.bot.model.RuntimeConstants;
import org.wildfly.bot.util.GithubProcessor;
import org.wildfly.bot.util.PullRequestLogger;
import jakarta.enterprise.context.RequestScoped;
import jakarta.inject.Inject;
import org.jboss.logging.Logger;
Expand All @@ -14,7 +14,6 @@

import java.io.IOException;

import static io.xstefank.wildfly.bot.model.RuntimeConstants.LABEL_FIX_ME;
import static org.kohsuke.github.GHPullRequestReviewState.CHANGES_REQUESTED;

@RequestScoped
Expand Down Expand Up @@ -45,13 +44,14 @@ void pullRequestReviewCheck(
}

if (pullRequestReview.getState() == CHANGES_REQUESTED) {
if (pullRequest.getLabels().stream().noneMatch(ghLabel -> ghLabel.getName().equals(LABEL_FIX_ME))) {
LOG.infof("Changes requested, applying following labels: %s.", LABEL_FIX_ME);
if (pullRequest.getLabels().stream()
.noneMatch(ghLabel -> ghLabel.getName().equals(RuntimeConstants.LABEL_FIX_ME))) {
LOG.infof("Changes requested, applying following labels: %s.", RuntimeConstants.LABEL_FIX_ME);
if (wildFlyBotConfig.isDryRun()) {
LOG.infof(RuntimeConstants.DRY_RUN_PREPEND.formatted("The following labels have been applied: %s"),
LABEL_FIX_ME);
RuntimeConstants.LABEL_FIX_ME);
} else {
pullRequest.addLabels(LABEL_FIX_ME);
pullRequest.addLabels(RuntimeConstants.LABEL_FIX_ME);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package io.xstefank.wildfly.bot;
package org.wildfly.bot;

import io.quarkiverse.githubapp.ConfigFile;
import io.quarkiverse.githubapp.event.PullRequest;
import io.xstefank.wildfly.bot.model.RuntimeConstants;
import io.xstefank.wildfly.bot.model.WildFlyConfigFile;
import io.xstefank.wildfly.bot.util.GithubProcessor;
import io.xstefank.wildfly.bot.util.Matcher;
import io.xstefank.wildfly.bot.util.PullRequestLogger;
import org.wildfly.bot.model.RuntimeConstants;
import org.wildfly.bot.model.WildFlyConfigFile;
import org.wildfly.bot.util.GithubProcessor;
import org.wildfly.bot.util.Matcher;
import org.wildfly.bot.util.PullRequestLogger;
import jakarta.enterprise.context.RequestScoped;
import jakarta.inject.Inject;
import org.jboss.logging.Logger;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package io.xstefank.wildfly.bot;
package org.wildfly.bot;

import io.quarkiverse.githubapp.event.Push;
import io.xstefank.wildfly.bot.util.PullRequestMergableProcessor;
import org.wildfly.bot.util.PullRequestMergableProcessor;
import jakarta.enterprise.context.RequestScoped;
import jakarta.inject.Inject;
import org.kohsuke.github.GHEventPayload;

import static io.xstefank.wildfly.bot.model.RuntimeConstants.MAIN_BRANCH_REF;
import org.wildfly.bot.model.RuntimeConstants;

@RequestScoped
public class RepositoryPushProcessor {
Expand All @@ -15,7 +14,7 @@ public class RepositoryPushProcessor {
PullRequestMergableProcessor pullRequestMergableProcessor;

void branchUpdated(@Push GHEventPayload.Push pushPayload) {
if (pushPayload.getRef().equals(MAIN_BRANCH_REF)) {
if (pushPayload.getRef().equals(RuntimeConstants.MAIN_BRANCH_REF)) {
pullRequestMergableProcessor.addPushPayload(pushPayload);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.xstefank.wildfly.bot.config;
package org.wildfly.bot.config;

import io.smallrye.config.ConfigMapping;
import io.smallrye.config.WithDefault;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.xstefank.wildfly.bot.format;
package org.wildfly.bot.format;

import org.kohsuke.github.GHPullRequest;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package io.xstefank.wildfly.bot.format;
package org.wildfly.bot.format;

import io.xstefank.wildfly.bot.model.RegexDefinition;
import io.xstefank.wildfly.bot.util.Patterns;
import org.wildfly.bot.model.RegexDefinition;
import org.wildfly.bot.util.Patterns;
import org.kohsuke.github.GHPullRequest;
import org.kohsuke.github.GHPullRequestCommitDetail;
import org.kohsuke.github.PagedIterable;
import java.util.regex.Pattern;
import java.io.IOException;

import static io.xstefank.wildfly.bot.model.RuntimeConstants.DEPENDABOT;
import static org.wildfly.bot.model.RuntimeConstants.DEPENDABOT;

public class CommitMessagesCheck implements Check {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.xstefank.wildfly.bot.format;
package org.wildfly.bot.format;

import io.xstefank.wildfly.bot.model.Description;
import io.xstefank.wildfly.bot.model.RegexDefinition;
import org.wildfly.bot.model.Description;
import org.wildfly.bot.model.RegexDefinition;
import org.kohsuke.github.GHPullRequest;

import java.util.regex.Matcher;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.xstefank.wildfly.bot.format;
package org.wildfly.bot.format;

import io.xstefank.wildfly.bot.model.RegexDefinition;
import io.xstefank.wildfly.bot.util.Patterns;
import org.wildfly.bot.model.RegexDefinition;
import org.wildfly.bot.util.Patterns;
import org.kohsuke.github.GHPullRequest;

import java.util.regex.Pattern;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.xstefank.wildfly.bot.model;
package org.wildfly.bot.model;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.xstefank.wildfly.bot.model;
package org.wildfly.bot.model;

import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.xstefank.wildfly.bot.model;
package org.wildfly.bot.model;

import java.util.regex.Pattern;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.xstefank.wildfly.bot.model;
package org.wildfly.bot.model;

public class RuntimeConstants {

Expand Down
Loading

0 comments on commit 746e983

Please sign in to comment.