Skip to content

Commit 6439cb9

Browse files
committed
Skip format and rules check on work-in-progress label.
1 parent 050cedf commit 6439cb9

4 files changed

Lines changed: 29 additions & 1 deletion

File tree

src/main/java/org/wildfly/bot/LifecycleProcessor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ void onStart(@Observes StartupEvent event) {
8282
List<String> problems = configFileChangeProcessor.validateFile(wildflyBotConfigFile, repository);
8383

8484
githubProcessor.createLabelsIfMissing(repository,
85-
Set.of(RuntimeConstants.LABEL_NEEDS_REBASE, RuntimeConstants.LABEL_FIX_ME));
85+
Set.of(RuntimeConstants.LABEL_NEEDS_REBASE, RuntimeConstants.LABEL_FIX_ME,
86+
RuntimeConstants.LABEL_WIP));
8687

8788
if (problems.isEmpty()) {
8889
LOG.infof("The configuration file from the repository %s was parsed successfully.",

src/main/java/org/wildfly/bot/model/RuntimeConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class RuntimeConstants {
1313
public static final String LABEL_NEEDS_REBASE = "rebase-this";
1414

1515
public static final String LABEL_FIX_ME = "fix-me";
16+
public static final String LABEL_WIP = "work-in-progress";
1617

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

src/main/java/org/wildfly/bot/util/GithubProcessor.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,10 @@ public String skipPullRequest(GHPullRequest pullRequest) throws IOException {
279279
return "pull request being a draft";
280280
}
281281

282+
if (pullRequest.getLabels().stream().anyMatch(ghLabel -> ghLabel.getName().equals(RuntimeConstants.LABEL_WIP))) {
283+
return "work in progress label found";
284+
}
285+
282286
return null;
283287
}
284288

src/test/java/org/wildfly/bot/PRSkipPullRequestTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import io.quarkus.test.junit.QuarkusTest;
55
import org.junit.jupiter.api.BeforeAll;
66
import org.junit.jupiter.api.Test;
7+
import org.wildfly.bot.model.RuntimeConstants;
78
import org.wildfly.bot.utils.TestConstants;
89
import org.wildfly.bot.utils.WildflyGitHubBotTesting;
910
import org.wildfly.bot.utils.mocking.Mockable;
@@ -81,4 +82,25 @@ void testSkippingFormatCheckOnDraft() throws Throwable {
8182
verifyNoMoreInteractions(mocks.pullRequest(pullRequestJson.id()));
8283
});
8384
}
85+
86+
@Test
87+
void testSkippingFormatCheckOnWipLabel() throws Throwable {
88+
pullRequestJson = TestModel.setPullRequestJsonBuilder(
89+
pullRequestJsonBuilder -> pullRequestJsonBuilder
90+
.title(TestConstants.INVALID_TITLE));
91+
92+
mockedContext = MockedGHPullRequest.builder(pullRequestJson.id()).labels(RuntimeConstants.LABEL_WIP);
93+
94+
TestModel.given(mocks -> WildflyGitHubBotTesting.mockRepo(mocks, wildflyConfigFile, pullRequestJson, mockedContext))
95+
.pullRequestEvent(pullRequestJson)
96+
.then(mocks -> {
97+
verify(mocks.pullRequest(pullRequestJson.id()), times(2)).getBody();
98+
verify(mocks.pullRequest(pullRequestJson.id())).listFiles();
99+
verify(mocks.pullRequest(pullRequestJson.id()), times(2)).isDraft();
100+
verify(mocks.pullRequest(pullRequestJson.id())).listComments();
101+
verify(mocks.pullRequest(pullRequestJson.id()), times(2)).getLabels(); // important for WIP skip check
102+
// commit status should not be set
103+
verifyNoMoreInteractions(mocks.pullRequest(pullRequestJson.id()));
104+
});
105+
}
84106
}

0 commit comments

Comments
 (0)