Skip to content
Open
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
3 changes: 2 additions & 1 deletion src/main/java/org/wildfly/bot/LifecycleProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ void onStart(@Observes StartupEvent event) {
List<String> problems = configFileChangeProcessor.validateFile(wildflyBotConfigFile, repository);

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

if (problems.isEmpty()) {
LOG.infof("The configuration file from the repository %s was parsed successfully.",
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/wildfly/bot/model/RuntimeConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class RuntimeConstants {
public static final String LABEL_NEEDS_REBASE = "rebase-this";

public static final String LABEL_FIX_ME = "fix-me";
public static final String LABEL_WIP = "work-in-progress";

public static final String BOT_MESSAGE_DELIMINER = "\n\n____";

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/wildfly/bot/util/GithubProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ public String skipPullRequest(GHPullRequest pullRequest) throws IOException {
return "pull request being a draft";
}

if (pullRequest.getLabels().stream().anyMatch(ghLabel -> ghLabel.getName().equals(RuntimeConstants.LABEL_WIP))) {
return "work in progress label found";
}

return null;
}

Expand Down
22 changes: 22 additions & 0 deletions src/test/java/org/wildfly/bot/PRSkipPullRequestTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.wildfly.bot.model.RuntimeConstants;
import org.wildfly.bot.utils.TestConstants;
import org.wildfly.bot.utils.WildflyGitHubBotTesting;
import org.wildfly.bot.utils.mocking.Mockable;
Expand Down Expand Up @@ -81,4 +82,25 @@ void testSkippingFormatCheckOnDraft() throws Throwable {
verifyNoMoreInteractions(mocks.pullRequest(pullRequestJson.id()));
});
}

@Test
void testSkippingFormatCheckOnWipLabel() throws Throwable {
pullRequestJson = TestModel.setPullRequestJsonBuilder(
pullRequestJsonBuilder -> pullRequestJsonBuilder
.title(TestConstants.INVALID_TITLE));

mockedContext = MockedGHPullRequest.builder(pullRequestJson.id()).labels(RuntimeConstants.LABEL_WIP);

TestModel.given(mocks -> WildflyGitHubBotTesting.mockRepo(mocks, wildflyConfigFile, pullRequestJson, mockedContext))
.pullRequestEvent(pullRequestJson)
.then(mocks -> {
verify(mocks.pullRequest(pullRequestJson.id()), times(2)).getBody();
verify(mocks.pullRequest(pullRequestJson.id())).listFiles();
verify(mocks.pullRequest(pullRequestJson.id()), times(2)).isDraft();
verify(mocks.pullRequest(pullRequestJson.id())).listComments();
verify(mocks.pullRequest(pullRequestJson.id()), times(2)).getLabels(); // important for WIP skip check
// commit status should not be set
verifyNoMoreInteractions(mocks.pullRequest(pullRequestJson.id()));
});
}
}
Loading