9
9
10
10
import jakarta .inject .Inject ;
11
11
12
- import org .hibernate .infra .bot .check . Check ;
13
- import org .hibernate .infra .bot .check . CheckRunContext ;
14
- import org .hibernate .infra .bot .check . CheckRunOutput ;
15
- import org .hibernate .infra .bot .check . CheckRunRule ;
12
+ import org .hibernate .infra .bot .prcheck . PullRequestCheck ;
13
+ import org .hibernate .infra .bot .prcheck . PullRequestCheckRunContext ;
14
+ import org .hibernate .infra .bot .prcheck . PullRequestCheckRunOutput ;
15
+ import org .hibernate .infra .bot .prcheck . PullRequestCheckRunRule ;
16
16
import org .hibernate .infra .bot .config .DeploymentConfig ;
17
17
import org .hibernate .infra .bot .config .RepositoryConfig ;
18
18
import org .hibernate .infra .bot .util .CommitMessages ;
@@ -82,14 +82,14 @@ private void checkPullRequestContributionRules(GHRepository repository, Reposito
82
82
return ;
83
83
}
84
84
85
- CheckRunContext context = new CheckRunContext ( deploymentConfig , repository , repositoryConfig , pullRequest );
86
- List <Check > checks = createChecks ( repositoryConfig );
87
- List <CheckRunOutput > outputs = new ArrayList <>();
88
- for ( Check check : checks ) {
89
- outputs .add ( Check .run ( context , check ) );
85
+ PullRequestCheckRunContext context = new PullRequestCheckRunContext ( deploymentConfig , repository , repositoryConfig , pullRequest );
86
+ List <PullRequestCheck > checks = createChecks ( repositoryConfig );
87
+ List <PullRequestCheckRunOutput > outputs = new ArrayList <>();
88
+ for ( PullRequestCheck check : checks ) {
89
+ outputs .add ( PullRequestCheck .run ( context , check ) );
90
90
}
91
91
92
- boolean passed = outputs .stream ().allMatch ( CheckRunOutput ::passed );
92
+ boolean passed = outputs .stream ().allMatch ( PullRequestCheckRunOutput ::passed );
93
93
GHIssueComment existingComment = findExistingComment ( pullRequest );
94
94
// Avoid creating noisy comments for no reason, in particular if checks passed
95
95
// or if the pull request was already closed.
@@ -133,8 +133,8 @@ private GHIssueComment findExistingComment(GHPullRequest pullRequest) throws IOE
133
133
return null ;
134
134
}
135
135
136
- private List <Check > createChecks (RepositoryConfig repositoryConfig ) {
137
- List <Check > checks = new ArrayList <>();
136
+ private List <PullRequestCheck > createChecks (RepositoryConfig repositoryConfig ) {
137
+ List <PullRequestCheck > checks = new ArrayList <>();
138
138
checks .add ( new TitleCheck () );
139
139
140
140
if ( repositoryConfig != null && repositoryConfig .jira != null ) {
@@ -153,14 +153,14 @@ private List<Check> createChecks(RepositoryConfig repositoryConfig) {
153
153
return checks ;
154
154
}
155
155
156
- static class TitleCheck extends Check {
156
+ static class TitleCheck extends PullRequestCheck {
157
157
158
158
TitleCheck () {
159
159
super ( "Contribution — Title" );
160
160
}
161
161
162
162
@ Override
163
- public void perform (CheckRunContext context , CheckRunOutput output ) {
163
+ public void perform (PullRequestCheckRunContext context , PullRequestCheckRunOutput output ) {
164
164
String title = context .pullRequest .getTitle ();
165
165
166
166
output .rule ( "The pull request title should contain at least 2 words to describe the change properly" )
@@ -170,7 +170,7 @@ public void perform(CheckRunContext context, CheckRunOutput output) {
170
170
}
171
171
}
172
172
173
- static class JiraIssuesCheck extends Check {
173
+ static class JiraIssuesCheck extends PullRequestCheck {
174
174
175
175
private final Pattern issueKeyPattern ;
176
176
@@ -190,7 +190,7 @@ static class JiraIssuesCheck extends Check {
190
190
}
191
191
192
192
@ Override
193
- public void perform (CheckRunContext context , CheckRunOutput output ) throws IOException {
193
+ public void perform (PullRequestCheckRunContext context , PullRequestCheckRunOutput output ) throws IOException {
194
194
if ( !shouldCheckPullRequest ( context ) ) {
195
195
// Means we have an ignore rule configured that matches our pull request.
196
196
// No need to check anything else.
@@ -214,7 +214,7 @@ public void perform(CheckRunContext context, CheckRunOutput output) throws IOExc
214
214
}
215
215
}
216
216
217
- CheckRunRule commitRule =
217
+ PullRequestCheckRunRule commitRule =
218
218
output .rule ( "All commit messages should start with a JIRA issue key matching pattern `"
219
219
+ issueKeyPattern + "`" );
220
220
if ( commitsWithMessageNotStartingWithIssueKey .isEmpty () ) {
@@ -226,7 +226,7 @@ public void perform(CheckRunContext context, CheckRunOutput output) throws IOExc
226
226
227
227
if ( issueLinksLimit == null || issueKeys .size () > issueLinksLimit ) {
228
228
// We only need to check mentions if automatic body editing is disabled
229
- CheckRunRule pullRequestRule = output .rule (
229
+ PullRequestCheckRunRule pullRequestRule = output .rule (
230
230
"The PR title or body should list the keys of all JIRA issues mentioned in the commits" );
231
231
List <String > issueKeysNotMentionedInPullRequest = issueKeys .stream ()
232
232
.filter ( issueKey -> ( title == null || !title .contains ( issueKey ) )
@@ -242,7 +242,7 @@ public void perform(CheckRunContext context, CheckRunOutput output) throws IOExc
242
242
}
243
243
}
244
244
245
- private boolean shouldCheckPullRequest (CheckRunContext context ) throws IOException {
245
+ private boolean shouldCheckPullRequest (PullRequestCheckRunContext context ) throws IOException {
246
246
GHUser author = context .pullRequest .getUser ();
247
247
String title = context .pullRequest .getTitle ();
248
248
for ( RepositoryConfig .IgnoreConfiguration ignore : ignoredPRConfigurations ) {
0 commit comments