├── .dockerignore ├── .github ├── dependabot.yml └── workflows │ └── build.yml ├── .gitignore ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── LICENSE.txt ├── README.adoc ├── deploy-to-openshift.sh ├── documentation └── screenshots │ └── workflow-run-report.png ├── mvnw ├── mvnw.cmd ├── pom.xml └── src ├── main ├── docker │ ├── Dockerfile.fast-jar │ ├── Dockerfile.jvm │ └── Dockerfile.native ├── java │ └── io │ │ └── quarkus │ │ └── bot │ │ ├── AffectKindToPullRequest.java │ │ ├── AffectMilestone.java │ │ ├── AnalyzeWorkflowRunResults.java │ │ ├── ApproveWorkflow.java │ │ ├── CancelWorkflowOnClosedPullRequest.java │ │ ├── CheckIssueEditorialRules.java │ │ ├── CheckPullRequestContributionRules.java │ │ ├── CheckPullRequestEditorialRules.java │ │ ├── CheckTriageBackportContext.java │ │ ├── MarkClosedPullRequestInvalid.java │ │ ├── NotifyQE.java │ │ ├── PingWhenNeedsTriageRemoved.java │ │ ├── PullRequestGuardedBranches.java │ │ ├── PushToProjects.java │ │ ├── QuarkusBot.java │ │ ├── RemoveCiLabelsWhenClosed.java │ │ ├── RemoveInvalidLabelOnReopenAction.java │ │ ├── RemoveNeedsTriageLabelFromClosedIssue.java │ │ ├── SetAreaLabelColor.java │ │ ├── SetTriageBackportLabelColor.java │ │ ├── TriageDiscussion.java │ │ ├── TriageIssue.java │ │ ├── TriagePullRequest.java │ │ ├── config │ │ ├── Feature.java │ │ ├── QuarkusGitHubBotConfig.java │ │ └── QuarkusGitHubBotConfigFile.java │ │ ├── el │ │ ├── Matcher.java │ │ └── SimpleELContext.java │ │ ├── graal │ │ └── SubstituteClassPathResolver.java │ │ ├── util │ │ ├── Branches.java │ │ ├── GHIssues.java │ │ ├── GHPullRequests.java │ │ ├── IssueExtractor.java │ │ ├── Labels.java │ │ ├── Mentions.java │ │ ├── Patterns.java │ │ ├── PullRequestFilesMatcher.java │ │ ├── Strings.java │ │ └── Triage.java │ │ └── workflow │ │ ├── QuarkusStackTraceShortener.java │ │ ├── QuarkusWorkflowConstants.java │ │ ├── QuarkusWorkflowJobLabeller.java │ │ └── report │ │ └── QuarkusWorkflowReportJobIncludeStrategy.java └── resources │ └── application.properties └── test ├── java └── io │ └── quarkus │ └── bot │ ├── it │ ├── CheckIssueEditorialRulesTest.java │ ├── CheckPullRequestContributionRulesTest.java │ ├── CheckTriageBackportContextTest.java │ ├── IssueOpenedTest.java │ ├── MarkClosedPullRequestInvalidTest.java │ ├── MockHelper.java │ ├── PullRequestOpenedTest.java │ ├── PushToProjectsTest.java │ ├── WorkflowApprovalTest.java │ └── util │ │ ├── BranchesTest.java │ │ ├── GHIssuesTest.java │ │ └── GHPullRequestsTest.java │ └── workflow │ └── StackTraceShortenerTest.java └── resources ├── issue-opened-zulip.json ├── issue-opened.json ├── pullrequest-closed.json ├── pullrequest-labeled-no-organization.json ├── pullrequest-opened-description-doc-missing-large-patch.json ├── pullrequest-opened-description-doc-missing-multiple-commits.json ├── pullrequest-opened-description-doc-missing-small-patch.json ├── pullrequest-opened-description-doc-not-missing.json ├── pullrequest-opened-description-missing-bom.json ├── pullrequest-opened-description-non-doc-large-patch.json ├── pullrequest-opened-description-non-doc-medium-patch.json ├── pullrequest-opened-description-non-doc-small-patch.json ├── pullrequest-opened-guarded-branch.json ├── pullrequest-opened-title-contains-issue-number.json ├── pullrequest-opened-title-contains-keyword.json ├── pullrequest-opened-title-contains-test.json ├── pullrequest-opened-title-does-not-contain-keyword.json ├── pullrequest-opened-title-ends-with-dot.json ├── pullrequest-opened-title-for-maintenance-branch-with-no-prefix.json ├── pullrequest-opened-title-starts-with-chore.json ├── pullrequest-opened-title-starts-with-docs.json ├── pullrequest-opened-title-starts-with-feat.json ├── pullrequest-opened-title-starts-with-fix.json ├── pullrequest-opened-title-starts-with-gRPC.json ├── pullrequest-opened-title-starts-with-lowercase.json ├── pullrequest-opened-title-starts-with-maintenance-branch-for-main.json ├── pullrequest-opened-title-starts-with-maintenance-branch-parenthesis.json ├── pullrequest-opened-title-starts-with-maintenance-branch.json ├── workflow-approval-needed.json ├── workflow-from-committer.json └── workflow-unknown-contributor-approval-needed.json /.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !target/*-runner 3 | !target/*-runner.jar 4 | !target/lib/* 5 | !target/quarkus-app/* -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: maven 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | - package-ecosystem: "github-actions" 8 | directory: "/" 9 | schedule: 10 | interval: daily 11 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | push: 5 | branches: 6 | - "main" 7 | paths-ignore: 8 | - '.gitignore' 9 | - 'CODEOWNERS' 10 | - 'LICENSE' 11 | - '*.md' 12 | - '*.adoc' 13 | - '*.txt' 14 | - '.all-contributorsrc' 15 | pull_request: 16 | paths-ignore: 17 | - '.gitignore' 18 | - 'CODEOWNERS' 19 | - 'LICENSE' 20 | - '*.md' 21 | - '*.adoc' 22 | - '*.txt' 23 | - '.all-contributorsrc' 24 | 25 | jobs: 26 | build: 27 | 28 | runs-on: ubuntu-latest 29 | 30 | steps: 31 | - uses: actions/checkout@v4 32 | 33 | - name: Set up JDK 17 34 | uses: actions/setup-java@v4 35 | with: 36 | distribution: temurin 37 | java-version: 17 38 | 39 | - name: Get Date 40 | id: get-date 41 | run: | 42 | echo "::set-output name=date::$(/bin/date -u "+%Y-%m")" 43 | shell: bash 44 | - name: Cache Maven Repository 45 | id: cache-maven 46 | uses: actions/cache@v4 47 | with: 48 | path: ~/.m2/repository 49 | # refresh cache every month to avoid unlimited growth 50 | key: maven-repo-pr-${{ runner.os }}-${{ steps.get-date.outputs.date }} 51 | 52 | - name: Build with Maven 53 | run: mvn -B clean install -Dno-format 54 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Eclipse 2 | .project 3 | .classpath 4 | .settings/ 5 | bin/ 6 | 7 | # IntelliJ 8 | .idea 9 | *.ipr 10 | *.iml 11 | *.iws 12 | 13 | # NetBeans 14 | nb-configuration.xml 15 | 16 | # Visual Studio Code 17 | .vscode 18 | .factorypath 19 | 20 | # OSX 21 | .DS_Store 22 | 23 | # Vim 24 | *.swp 25 | *.swo 26 | 27 | # patch 28 | *.orig 29 | *.rej 30 | 31 | # Maven 32 | target/ 33 | pom.xml.tag 34 | pom.xml.releaseBackup 35 | pom.xml.versionsBackup 36 | release.properties 37 | 38 | # Impsort 39 | .cache/ 40 | 41 | # Environment 42 | .env 43 | .quarkus 44 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quarkusio/quarkus-github-bot/347b4f73964b2da1b1bd71e2bbf04dc75677bed5/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip 18 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar 19 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /README.adoc: -------------------------------------------------------------------------------- 1 | = Quarkus GitHub Bot 2 | 3 | > A Quarkus-powered GitHub App to simplify issues and pull requests management in the Quarkus project. 4 | 5 | ++++ 6 |
88 | * Note that it's a bit tricky to get this id as it's not present in the GraphQL API. You have to generate an event and
89 | * have a look at what is in the payload.
90 | */
91 | @JsonDeserialize(as = TreeSet.class)
92 | public Set(.*?)
",
17 | Pattern.DOTALL);
18 | private static final String QUARKUS_TEST_EXTENSION = " at io.quarkus.test.junit.QuarkusTestExtension.runExtensionMethod(";
19 |
20 | @Override
21 | public String shorten(String stacktrace, int length) {
22 | if (StringUtils.isBlank(stacktrace)) {
23 | return null;
24 | }
25 |
26 | if (stacktrace.contains(HTML_INTERNAL_ERROR_MARKER)) {
27 | // this is an HTML error, let's get to the stacktrace
28 | Matcher matcher = STACK_TRACE_PATTERN.matcher(stacktrace);
29 | StringBuilder sb = new StringBuilder();
30 | if (matcher.find()) {
31 | matcher.appendReplacement(sb, "Actual: An Internal Server Error with stack trace:\n$1");
32 | stacktrace = sb.toString();
33 | }
34 | }
35 |
36 | int quarkusTestExtensionIndex = stacktrace.indexOf(QUARKUS_TEST_EXTENSION);
37 | if (quarkusTestExtensionIndex > 0) {
38 | stacktrace = stacktrace.substring(0, stacktrace.lastIndexOf('\n', quarkusTestExtensionIndex));
39 | }
40 |
41 | return StringUtils.abbreviate(stacktrace, length);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/io/quarkus/bot/workflow/QuarkusWorkflowConstants.java:
--------------------------------------------------------------------------------
1 | package io.quarkus.bot.workflow;
2 |
3 | public class QuarkusWorkflowConstants {
4 |
5 | public static final String QUARKUS_CI_WORKFLOW_NAME = "Quarkus CI";
6 | public static final String QUARKUS_DOCUMENTATION_CI_WORKFLOW_NAME = "Quarkus Documentation CI";
7 | public static final String JOB_NAME_DELIMITER = " - ";
8 | public static final String JOB_NAME_INITIAL_JDK_PREFIX = "Initial JDK ";
9 | public static final String JOB_NAME_JVM_TESTS_PREFIX = "JVM Tests";
10 | public static final String JOB_NAME_JDK_PREFIX = "JDK";
11 | public static final String JOB_NAME_JAVA_PREFIX = "Java";
12 | public static final String JOB_NAME_WINDOWS = "Windows";
13 | public static final String JOB_NAME_BUILD_REPORT = "Build report";
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/io/quarkus/bot/workflow/QuarkusWorkflowJobLabeller.java:
--------------------------------------------------------------------------------
1 | package io.quarkus.bot.workflow;
2 |
3 | import jakarta.inject.Singleton;
4 |
5 | import io.quarkus.bot.buildreporter.githubactions.WorkflowJobLabeller;
6 |
7 | @Singleton
8 | public class QuarkusWorkflowJobLabeller implements WorkflowJobLabeller {
9 |
10 | @Override
11 | public String label(String name) {
12 | if (name == null || name.isBlank()) {
13 | return name;
14 | }
15 |
16 | StringBuilder label = new StringBuilder();
17 | String[] tokens = name.split(QuarkusWorkflowConstants.JOB_NAME_DELIMITER);
18 |
19 | for (int i = 0; i < tokens.length; i++) {
20 | if (tokens[i].startsWith(QuarkusWorkflowConstants.JOB_NAME_JDK_PREFIX)
21 | || tokens[i].startsWith(QuarkusWorkflowConstants.JOB_NAME_JAVA_PREFIX)) {
22 | break;
23 | }
24 |
25 | if (!label.isEmpty()) {
26 | label.append(QuarkusWorkflowConstants.JOB_NAME_DELIMITER);
27 | }
28 | label.append(tokens[i]);
29 | }
30 |
31 | return label.toString();
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/io/quarkus/bot/workflow/report/QuarkusWorkflowReportJobIncludeStrategy.java:
--------------------------------------------------------------------------------
1 | package io.quarkus.bot.workflow.report;
2 |
3 | import java.util.Locale;
4 |
5 | import jakarta.inject.Singleton;
6 |
7 | import io.quarkus.bot.buildreporter.githubactions.WorkflowConstants;
8 | import io.quarkus.bot.buildreporter.githubactions.report.WorkflowReport;
9 | import io.quarkus.bot.buildreporter.githubactions.report.WorkflowReportJob;
10 | import io.quarkus.bot.buildreporter.githubactions.report.WorkflowReportJobIncludeStrategy;
11 | import io.quarkus.bot.workflow.QuarkusWorkflowConstants;
12 |
13 | @Singleton
14 | public class QuarkusWorkflowReportJobIncludeStrategy implements WorkflowReportJobIncludeStrategy {
15 |
16 | @Override
17 | public boolean include(WorkflowReport report, WorkflowReportJob job) {
18 | if (job.getName().startsWith(WorkflowConstants.BUILD_SUMMARY_CHECK_RUN_PREFIX)) {
19 | return false;
20 | }
21 | if (job.isFailing()) {
22 | return true;
23 | }
24 | if (QuarkusWorkflowConstants.JOB_NAME_BUILD_REPORT.equals(job.getName())) {
25 | return false;
26 | }
27 |
28 | // in this particular case, we exclude the Windows job as it does not run the containers job
29 | // (no Docker support on Windows) and thus does not provide a similar coverage as the Linux
30 | // jobs. Having it green does not mean that things were OK globally.
31 | if (isJvmTests(job)) {
32 | if (isWindows(job)) {
33 | return false;
34 | }
35 |
36 | return hasJobWithSameLabelFailing(report, job);
37 | }
38 |
39 | return hasJobWithSameLabelFailing(report, job);
40 | }
41 |
42 | private static boolean isJvmTests(WorkflowReportJob job) {
43 | return job.getName().toLowerCase(Locale.ROOT)
44 | .startsWith(QuarkusWorkflowConstants.JOB_NAME_JVM_TESTS_PREFIX.toLowerCase(Locale.ROOT));
45 | }
46 |
47 | private static boolean isWindows(WorkflowReportJob job) {
48 | return job.getName().contains(QuarkusWorkflowConstants.JOB_NAME_WINDOWS);
49 | }
50 |
51 | private static boolean hasJobWithSameLabelFailing(WorkflowReport report, WorkflowReportJob job) {
52 | return report.getJobs().stream()
53 | .filter(j -> j.getLabel().equals(job.getLabel()))
54 | .anyMatch(j -> j.isFailing());
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | quarkus.application.name=quarkus-bot
2 | quarkus.application.version=${buildNumber:999-SNAPSHOT}
3 |
4 | quarkus.live-reload.instrumentation=false
5 |
6 | quarkus.qute.suffixes=md
7 | quarkus.qute.content-types."md"=text/markdown
8 |
9 | quarkus.cache.caffeine."glob-cache".maximum-size=200
10 |
11 | quarkus.cache.caffeine."PushToProject.getStatusFieldValue".initial-capacity=10
12 | quarkus.cache.caffeine."PushToProject.getStatusFieldValue".maximum-size=100
13 | quarkus.cache.caffeine."PushToProject.getStatusFieldValue".expire-after-write=2H
14 |
15 | quarkus.cache.caffeine."contributor-cache".expire-after-write=P2D
16 | quarkus.cache.caffeine."stats-cache".expire-after-write=P2D
17 |
18 | quarkus.openshift.labels."app"=quarkus-bot
19 | quarkus.openshift.annotations."kubernetes.io/tls-acme"=true
20 | quarkus.openshift.env.vars.QUARKUS_GITHUB_APP_APP_ID=90234
21 | quarkus.openshift.env.vars.QUARKUS_GITHUB_APP_APP_NAME=quarkus-bot
22 | quarkus.openshift.env.vars.QUARKUS_OPTS=-Dquarkus.http.host=0.0.0.0 -Xmx150m
23 | #quarkus.openshift.env.vars.QUARKUS_BOT_DRY_RUN=true
24 | quarkus.openshift.env.secrets=quarkus-bot
25 | quarkus.openshift.add-version-to-label-selectors=false
26 | quarkus.openshift.replicas=2
27 |
28 | %dev.quarkus-github-bot.dry-run=true
29 |
30 | %test.quarkus.github-app.app-id=0
31 | %test.quarkus.github-app.private-key=-----BEGIN RSA PRIVATE KEY-----\
32 | MIIEogIBAAKCAQEA30YvyuZAd+kGDT0nm/XAa93CqsDvC/iYOc4KsKsfBQs1MWjH\
33 | royuVDfQj2fJvueFnOgZApM3viaCz188D/j3tUMNByIKOfMLiEm/R1tqe7Q6xRRn\
34 | uwpfT+wv+/x4cNvPxTscwo43LVR9Pno71UfZZywnYN03GS71ttNCiiBKXwCSnHez\
35 | /t79iAmMnym7ViNsKzA0aS5EwAw9A3GeTnxpRef0y0vDNE2aXBNCe+f1ZnFq1Fhe\
36 | PJIlKs/qlM136A2co+WRaPghacZJMuwQr1vajuMSBjMEroIPOfSG3x3Oitvnukjp\
37 | EwuhXjmZeaLc+60rYaMRwf+bje8KmaAVOMWkHQIDAQABAoIBAA+d8SnYARpiCjJS\
38 | 3Lpj7hmdYUhgRlgoAz3H06eX0IuhxQ63rX/gBzGM1eGx+MKJnybidR1g/r0mJHAs\
39 | 0R6s42aiUf71upFjFqNpxR9QnZoZeSLf0oGasB/+/Tw65JHATkAVamWRXPqmtjvw\
40 | gM7iP6qfxAFad8gjKLyo+jZ/G7SZTCMwnp+sRynirNpycxaAn/xK6Pe43+nyQVWT\
41 | E0J8bvCzrFD47CM5zZaBQlLWTMjY4Rr3U6BMTGwQWJzGkeGn+2JsHVUch0k7+NRa\
42 | e3FKjT+57dZqQTnGPVSpBFWEXVO9KLEuLBLyRx0348TZBHzIM9IigN4QS2AaWTJw\
43 | 1kp3VWECgYEA/3P/nsL+RL/yqYvENZ7XqEkXRNH6YHOe8h/lFoYHStCl9y0T8O+z\
44 | ooJq9hEq7QcYs2bHvBWj8B9he7+bZ5ZOMAM6oIgrgB5FzSvL7JzXhEdONxe/j2TI\
45 | GbQuC+NxdJtx4Y6yF9Lrb1UyKX+HzR4de+v6b5hER7x8x4gQn1sCYmsCgYEA38CN\
46 | bTtE3RKY98m33a1Cd6hNXHSyy5GOK5/XGDn0XoGfFe5YJnnh2lia2V4xqUH9d1Mu\
47 | bB0bEUhfbac5SX5SIW+NBVxzehqfMkrZj/rzN8Wd7TrYAHSldSMhkPTuwuuzfnHL\
48 | sJLe2gyoqq+sooeE7eCH2fpPIN0wg5U+jc60hZcCgYBHtmrGSPtUlYYr7p6wZt0n\
49 | 0w0DNudQ+GRgmG+ZeRrG9/f/gdodQ01si6w3U+53CAz5IBtmQ7T4Dfcx5EJePCXK\
50 | +L0Wn+OGXfk+ddMTo5wk+FeOw831FVfPT3O1xq3tDE5WAdchNQb/BC3G1JRtEs04\
51 | IrD1bwuMD+//m8T+12+97QKBgDko0XhEGdV3+MfkKiphJoe24Pxre3lxl6YhUSuJ\
52 | Mpop9t/9YVuC62WCGRzKaVlZ2ExxXXyU+uMxX999Rq81q/mKq7Xg5kcdIeoRIP8d\
53 | FqD6xNtjmuaS5enErcCAMbZtzA7TNzvGaVO+xB/GfQ2QHS8/mrTesvQsTUZwC+ji\
54 | E0/FAoGATJvuAfgy9uiKR7za7MigYVacE0u4aD1sF7v6D4AFqBOGquPQQhePSdz9\
55 | G/UUwySoo+AQ+rd2EPhyexjqXBhRGe+EDGFVFivaQzTT8/5bt/VddbTcw2IpmXYj\
56 | LW6V8BbcP5MRhd2JQSRh16nWwSQJ2BdpUZFwayEEQ6UcrMfqvA0=\
57 | -----END RSA PRIVATE KEY-----
58 |
--------------------------------------------------------------------------------
/src/test/java/io/quarkus/bot/it/CheckIssueEditorialRulesTest.java:
--------------------------------------------------------------------------------
1 | package io.quarkus.bot.it;
2 |
3 | import static io.quarkiverse.githubapp.testing.GitHubAppTesting.given;
4 | import static org.mockito.Mockito.verify;
5 | import static org.mockito.Mockito.verifyNoMoreInteractions;
6 |
7 | import java.io.IOException;
8 |
9 | import org.junit.jupiter.api.Test;
10 | import org.kohsuke.github.GHEvent;
11 |
12 | import io.quarkiverse.githubapp.testing.GitHubAppTest;
13 | import io.quarkus.bot.CheckIssueEditorialRules;
14 | import io.quarkus.test.junit.QuarkusTest;
15 |
16 | @QuarkusTest
17 | @GitHubAppTest
18 | public class CheckIssueEditorialRulesTest {
19 | @Test
20 | void validZulipLinkConfirmation() throws IOException {
21 | given().github(mocks -> mocks.configFile("quarkus-github-bot.yml").fromString("features: [ ALL ]\n"))
22 | .when().payloadFromClasspath("/issue-opened-zulip.json")
23 | .event(GHEvent.ISSUES)
24 | .then().github(mocks -> {
25 | verify(mocks.issue(942074921))
26 | .comment(CheckIssueEditorialRules.ZULIP_WARNING);
27 | verifyNoMoreInteractions(mocks.ghObjects());
28 | });
29 |
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/test/java/io/quarkus/bot/it/CheckTriageBackportContextTest.java:
--------------------------------------------------------------------------------
1 | package io.quarkus.bot.it;
2 |
3 | import static io.quarkiverse.githubapp.testing.GitHubAppTesting.given;
4 | import static org.mockito.Mockito.verify;
5 | import static org.mockito.Mockito.verifyNoMoreInteractions;
6 |
7 | import java.io.IOException;
8 |
9 | import org.junit.jupiter.api.Test;
10 | import org.kohsuke.github.GHEvent;
11 |
12 | import io.quarkiverse.githubapp.testing.GitHubAppTest;
13 | import io.quarkus.bot.CheckTriageBackportContext;
14 | import io.quarkus.bot.util.Strings;
15 | import io.quarkus.test.junit.QuarkusTest;
16 |
17 | @QuarkusTest
18 | @GitHubAppTest
19 | public class CheckTriageBackportContextTest {
20 |
21 | @Test
22 | void testLabelBackportWarningConfirmation() throws IOException {
23 | String warningMsg = String.format(CheckTriageBackportContext.LABEL_BACKPORT_WARNING, "triage/backport-whatever");
24 | String expectedComment = Strings.commentByBot("@test-github-user " + warningMsg);
25 |
26 | given().github(mocks -> mocks.configFile("quarkus-github-bot.yml").fromString("features: [ ALL ]\n"))
27 | .when().payloadFromString(getSampleIssueLabelTriageBackportPayload())
28 | .event(GHEvent.ISSUES)
29 | .then().github(mocks -> {
30 | verify(mocks.issue(1234567890))
31 | .comment(expectedComment.toString());
32 | verifyNoMoreInteractions(mocks.ghObjects());
33 | });
34 |
35 | }
36 |
37 | private static String getSampleIssueLabelTriageBackportPayload() {
38 | return """
39 | {
40 | "action": "labeled",
41 | "issue": {
42 | "id": 1234567890,
43 | "number": 123,
44 | "labels": [
45 | {
46 | "name": "triage/backport-whatever"
47 | }
48 | ]
49 | },
50 | "label": {
51 | "name": "triage/backport-whatever"
52 | },
53 | "repository": {
54 |
55 | },
56 | "sender": {
57 | "login": "test-github-user"
58 | },
59 | "installation" : {
60 | "id" : 28125889,
61 | "node_id" : "MDIzOkludGVncmF0aW9uSW5zdGFsbGF0aW9uMjgxMjU4ODk="
62 | }
63 | }""";
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/test/java/io/quarkus/bot/it/IssueOpenedTest.java:
--------------------------------------------------------------------------------
1 | package io.quarkus.bot.it;
2 |
3 | import static io.quarkiverse.githubapp.testing.GitHubAppTesting.given;
4 | import static org.mockito.Mockito.verify;
5 | import static org.mockito.Mockito.verifyNoMoreInteractions;
6 |
7 | import java.io.IOException;
8 |
9 | import org.junit.jupiter.api.Test;
10 | import org.kohsuke.github.GHEvent;
11 |
12 | import io.quarkiverse.githubapp.testing.GitHubAppTest;
13 | import io.quarkus.bot.util.Labels;
14 | import io.quarkus.test.junit.QuarkusTest;
15 |
16 | @QuarkusTest
17 | @GitHubAppTest
18 | public class IssueOpenedTest {
19 |
20 | @Test
21 | void triage() throws IOException {
22 | given().github(mocks -> mocks.configFile("quarkus-github-bot.yml")
23 | .fromString("features: [ ALL ]\n"
24 | + "triage:\n"
25 | + " rules:\n"
26 | + " - title: test\n"
27 | + " labels: [area/test1, area/test2]"))
28 | .when().payloadFromClasspath("/issue-opened.json")
29 | .event(GHEvent.ISSUES)
30 | .then().github(mocks -> {
31 | verify(mocks.issue(750705278))
32 | .addLabels("area/test1", "area/test2");
33 | verifyNoMoreInteractions(mocks.ghObjects());
34 | });
35 | }
36 |
37 | @Test
38 | void triageComment() throws IOException {
39 | given().github(mocks -> mocks.configFile("quarkus-github-bot.yml")
40 | .fromString("features: [ ALL ]\n"
41 | + "triage:\n"
42 | + " rules:\n"
43 | + " - title: test\n"
44 | + " comment: 'This is a security issue'"))
45 | .when().payloadFromClasspath("/issue-opened.json")
46 | .event(GHEvent.ISSUES)
47 | .then().github(mocks -> {
48 | verify(mocks.issue(750705278))
49 | .comment("This is a security issue");
50 | verify(mocks.issue(750705278))
51 | .addLabels(Labels.TRIAGE_NEEDS_TRIAGE);
52 | verifyNoMoreInteractions(mocks.ghObjects());
53 | });
54 | }
55 |
56 | @Test
57 | void triageBasicNotify() throws IOException {
58 | given().github(mocks -> mocks.configFile("quarkus-github-bot.yml")
59 | .fromString("features: [ ALL ]\n"
60 | + "triage:\n"
61 | + " rules:\n"
62 | + " - title: test\n"
63 | + " notify: [prodsec]\n"
64 | + " comment: 'This is a security issue'"))
65 | .when().payloadFromClasspath("/issue-opened.json")
66 | .event(GHEvent.ISSUES)
67 | .then().github(mocks -> {
68 | verify(mocks.issue(750705278))
69 | .comment("/cc @prodsec");
70 | verify(mocks.issue(750705278))
71 | .comment("This is a security issue");
72 | verifyNoMoreInteractions(mocks.ghObjects());
73 | });
74 | }
75 |
76 | @Test
77 | void triageIdNotify() throws IOException {
78 | given().github(mocks -> mocks.configFile("quarkus-github-bot.yml")
79 | .fromString("features: [ ALL ]\n"
80 | + "triage:\n"
81 | + " rules:\n"
82 | + " - id: 'security'\n"
83 | + " title: test\n"
84 | + " notify: [prodsec,max]\n"
85 | + " comment: 'This is a security issue'\n"
86 | + " - id: 'devtools'\n"
87 | + " title: test\n"
88 | + " notify: [max]\n"))
89 | .when().payloadFromClasspath("/issue-opened.json")
90 | .event(GHEvent.ISSUES)
91 | .then().github(mocks -> {
92 | verify(mocks.issue(750705278))
93 | .comment("This is a security issue");
94 | verify(mocks.issue(750705278)).comment("/cc @max (devtools,security), @prodsec (security)");
95 | verifyNoMoreInteractions(mocks.ghObjects());
96 | });
97 | }
98 |
99 | }
100 |
--------------------------------------------------------------------------------
/src/test/java/io/quarkus/bot/it/MarkClosedPullRequestInvalidTest.java:
--------------------------------------------------------------------------------
1 | package io.quarkus.bot.it;
2 |
3 | import static io.quarkiverse.githubapp.testing.GitHubAppTesting.given;
4 | import static org.mockito.Mockito.mock;
5 | import static org.mockito.Mockito.verify;
6 | import static org.mockito.Mockito.when;
7 | import static org.mockito.Mockito.withSettings;
8 |
9 | import java.io.IOException;
10 | import java.util.Collections;
11 | import java.util.Iterator;
12 | import java.util.List;
13 |
14 | import org.junit.jupiter.api.Test;
15 | import org.kohsuke.github.GHEvent;
16 | import org.kohsuke.github.GHRepository;
17 | import org.kohsuke.github.GHWorkflowRun;
18 | import org.kohsuke.github.GHWorkflowRunQueryBuilder;
19 | import org.kohsuke.github.PagedIterable;
20 | import org.kohsuke.github.PagedIterator;
21 | import org.mockito.Answers;
22 |
23 | import io.quarkiverse.githubapp.testing.GitHubAppTest;
24 | import io.quarkus.bot.util.Labels;
25 | import io.quarkus.test.junit.QuarkusTest;
26 |
27 | @QuarkusTest
28 | @GitHubAppTest
29 | public class MarkClosedPullRequestInvalidTest {
30 |
31 | @Test
32 | void handleLabels() throws IOException {
33 | given().github(mocks -> {
34 | mocks.configFile("quarkus-github-bot.yml").fromString("features: [ ALL ]\n");
35 | // this is necessary because this payload also triggers CancelWorkflowOnClosedPullRequest
36 | GHRepository repoMock = mocks.repository("Luke1432/GitHubTestAppRepo");
37 | GHWorkflowRunQueryBuilder workflowRunQueryBuilderMock = mock(GHWorkflowRunQueryBuilder.class,
38 | withSettings().defaultAnswer(Answers.RETURNS_SELF));
39 | when(repoMock.queryWorkflowRuns())
40 | .thenReturn(workflowRunQueryBuilderMock);
41 | PagedIterable