summaryrefslogtreecommitdiffstats
path: root/.github
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2024-05-07 15:53:35 +0200
committerLuca Boccassi <luca.boccassi@gmail.com>2024-05-07 17:49:54 +0200
commit5dd3657f86545e0b357b8a48081317acf29fbc6c (patch)
treee3844ee4e34163c50548465505c32b70796f8f5a /.github
parentMerge pull request #32683 from dtardon/fix-error-vars (diff)
downloadsystemd-5dd3657f86545e0b357b8a48081317acf29fbc6c.tar.xz
systemd-5dd3657f86545e0b357b8a48081317acf29fbc6c.zip
ci: Optimize pull request labeler
We keep running into rate limits, so let's optimize the number of requests we do in the pull request labeler to hopefully fix that.
Diffstat (limited to '.github')
-rw-r--r--.github/workflows/labeler.yml69
1 files changed, 36 insertions, 33 deletions
diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml
index 64d0facc74..a0f89dd32b 100644
--- a/.github/workflows/labeler.yml
+++ b/.github/workflows/labeler.yml
@@ -52,38 +52,34 @@ jobs:
repo: context.repo.repo,
});
- good_to_merge = [
+ original = new Set(response.data.map(l => l.name));
+ labels = new Set(original);
+
+ good_to_merge = new Set([
"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"]
- });
+ if (Array.from(labels).filter(l => good_to_merge.has(l)).length == 0) {
+ labels.add("please-review");
}
for (const label of ["reviewed/needs-rework 🔨",
"ci-fails/needs-rework 🔥",
"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;
- }
- }
+ labels.delete(label);
+ }
+
+ if (labels.size != original.size || Array.from(labels).some(l => !original.has(l))) {
+ await github.rest.issues.setLabels({
+ issue_number: context.issue.number,
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ labels: Array.from(labels),
+ });
}
- name: Add please-review label on command in issue comment
@@ -103,6 +99,15 @@ jobs:
if: startsWith(github.event_name, 'pull_request') && github.event.action == 'closed'
with:
script: |
+ response = await github.rest.issues.listLabelsOnIssue({
+ issue_number: context.issue.number,
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ });
+
+ original = new Set(response.data.map(l => l.name));
+ labels = new Set(original);
+
for (const label of ["please-review",
"reviewed/needs-rework 🔨",
"ci-fails/needs-rework 🔥",
@@ -116,16 +121,14 @@ jobs:
"dont-merge 💣",
"squash-on-merge",
"quick-review 🏃‍♂️"]) {
- 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;
- }
- }
+ labels.delete(label);
+ }
+
+ if (labels.size != original.size || Array.from(labels).some(l => !original.has(l))) {
+ await github.rest.issues.setLabels({
+ issue_number: context.issue.number,
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ labels: Array.from(labels),
+ });
}