]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ci: Labeler improvements
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 9 Dec 2022 11:10:09 +0000 (12:10 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 9 Dec 2022 14:37:43 +0000 (15:37 +0100)
- Mention "/please-review" in the contributing guide
- Remove "needs-rebase" on push
- Don't add "please-review" if a green label is set
- Don't add please-review label to draft PRs
- Add please-review when a PR moves out of draft

.github/workflows/labeler.yml
docs/CONTRIBUTING.md

index b86d1ff7692cf638e4c5253d3f98ed7363eab2bd..c3b4040add3eafef667faaa20651da256126a088 100644 (file)
@@ -5,15 +5,17 @@
 name: "Pull Request Labeler"
 
 on:
-- pull_request_target
-- issue_comment
+  pull_request_target:
+    types: [opened, synchronize, reopened, ready_for_review]
+  issue_comment:
+    types: [created]
 
 permissions:
   contents: read
 
 jobs:
   triage:
-    if: github.event.repository.name != 'systemd-security'
+    if: github.repository == 'systemd/systemd'
     runs-on: ubuntu-latest
     permissions:
       pull-requests: write
@@ -26,25 +28,42 @@ jobs:
         sync-labels: "" # This is a workaround for issue 18671
 
     - uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0
-      if: github.event_name == 'pull_request_target'
+      if: github.event_name == 'pull_request_target' && !github.event.pull_request.draft
       with:
         script: |
-          await github.rest.issues.addLabels({
+          response = await github.rest.issues.listLabelsOnIssue({
             issue_number: context.issue.number,
             owner: context.repo.owner,
             repo: context.repo.repo,
-            labels: ["please-review"]
-          })
+          });
+
+          good_to_merge = [
+            "good-to-merge/waiting-for-ci 👍",
+            "good-to-merge/after-next-release",
+            "good-to-merge/with-minor-suggestions",
+            "good-to-merge/waiting-for-reporter-feedback 👍",
+          ];
+
+          if (response.data.every(l => !good_to_merge.includes(l.name))) {
+            await github.rest.issues.addLabels({
+              issue_number: context.issue.number,
+              owner: context.repo.owner,
+              repo: context.repo.repo,
+              labels: ["please-review"]
+            });
+          }
+
           for (const label of ["reviewed/needs-rework 🔨",
                                "ci-fails/needs-rework 🔥",
-                               "ci-failure-appears-unrelated"]) {
+                               "ci-failure-appears-unrelated",
+                               "needs-rebase"]) {
             try {
               await github.rest.issues.removeLabel({
                 issue_number: context.issue.number,
                 owner: context.repo.owner,
                 repo: context.repo.repo,
                 name: label,
-              })
+              });
             } catch (err) {
               if (err.status != 404) {
                 throw err;
@@ -56,7 +75,7 @@ jobs:
       if: github.event_name == 'issue_comment' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/please-review')
       with:
         script: |
-          github.rest.issues.addLabels({
+          await github.rest.issues.addLabels({
             issue_number: context.issue.number,
             owner: context.repo.owner,
             repo: context.repo.repo,
index 1db99ad41a7b1e17c9442440855511326612d197..d980f7764e78720bb0b0a1440ebe2790db97e9fd 100644 (file)
@@ -41,6 +41,9 @@ See [reporting of security vulnerabilities](SECURITY.md).
 * After you have pushed a new version, add a comment explaining the latest changes. If you are a member of the systemd project on GitHub, remove the `reviewed/needs-rework`/`ci-fails/needs-rework`/`needs-rebase` labels.
 * If you are copying existing code from another source (eg: a compat header), please make sure the license is compatible with `LGPL-2.1-or-later`. If the license is not `LGPL-2.1-or-later`, please add a note to [`LICENSES/README.md`](https://github.com/systemd/systemd/blob/main/LICENSES/README.md).
 * If the pull request stalls without review, post a ping in a comment after some time has passed. We are always short on reviewer time, and pull requests which haven't seen any recent activity can be easily forgotten.
+* Github will automatically add the please-review label when a pull request is opened or updated. If you need
+more information after a review, you can comment `/please-review` on the pull request to have Github add the
+please-review to the pull request.
 
 ## Reviewing Pull Requests