From 2a247672a650a8635c5bbe31f92eb655762346d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 26 Oct 2021 19:45:17 +0200 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=91=B7=20Add=20reminder=20for=20issue?= =?UTF-8?q?s=20w/o=20bundles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Will add a reminder if an issue is labeled 'triage' and now bundle is detected. Will go away if issue is no longer labeled 'triage' or edited to fix the problem. --- .github/workflows/issue_automation.yml | 97 ++++++++++++++++++++++++-- 1 file changed, 92 insertions(+), 5 deletions(-) diff --git a/.github/workflows/issue_automation.yml b/.github/workflows/issue_automation.yml index fb59a7d97..bccc1b258 100644 --- a/.github/workflows/issue_automation.yml +++ b/.github/workflows/issue_automation.yml @@ -1,19 +1,18 @@ name: "Issue Automation" on: issues: - types: [opened, edited, closed, reopened] + types: [opened, edited, closed, reopened, labeled, unlabeled] jobs: issue-automation: runs-on: ubuntu-latest steps: - - uses: actions/github-script@v2 + - uses: actions/github-script@v5 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - let labels = []; + let labels = context.payload.issue.labels.map(label => label.name); let setLabels = false; - context.payload.issue.labels.forEach(label => { labels.push(label.name) }); switch (context.payload.action) { @@ -55,7 +54,7 @@ jobs: } if (setLabels) { - github.issues.setLabels({ + github.rest.issues.setLabels({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, @@ -67,3 +66,91 @@ jobs: # if: github.event_name == 'issues' && (github.event.action == 'opened' || github.event.action == 'edited') # with: # repo-token: ${{ secrets.GITHUB_TOKEN }} + + - uses: actions/github-script@v5 + env: + REMINDER: > + Hi @${{ github.event.issue.user.login }}! + + + It looks like you didn't upload a [system info bundle](https://community.octoprint.org/t/29887) as requested by the template. + A bundle is required to further process your issue. It contains important logs and + system information to be able to put your issue into context and give pointers as to + what has happened. + + + Please upload **a bundle zip file** to the original issue post. Actually upload the file please and + do not paste some link to a cloud provider, we want to have everything in one place here. Also do + not unpack, repack or otherwise modify the bundle, share it **exactly** like you get it from OctoPrint. + + + Without the availability of a bundle, your issue will have to be closed. + + + Thank you for your collaboration. + THANKYOU: > + Thank you @${{ github.event.issue.user.login }} for adding a bundle! Now this can actually get looked at. + with: + script: | + const { REMINDER, THANKYOU } = process.env; + const bundleRegex = /\[(octoprint-systeminfo-\d{14}\.zip)\]\(([^)]+)\)/g; + const marker = ""; + + const issueLabels = await github.rest.issues.listLabelsOnIssue({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number + }); + let labels = issueLabels.data.map(label => label.name); + + const comments = await github.rest.issues.listComments({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + }) + const comment = comments.data.find(c => c.user.login === "github-actions[bot]" && c.body.includes(marker)); + + if (!labels.includes("triage")) { + console.log("No label, deleting comment if needed"); + if (comment) { + await github.rest.issues.deleteComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: comment.id, + }) + } + return; + } + + const found = !!context.payload.issue.body.match(bundleRegex); + + if (!found) { + console.log("No bundle found, posting/updating reminder"); + const text = REMINDER + "\n" + marker; + if (comment && comment.body !== text) { + await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: comment.id, + body: text + }); + } else { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body: text + }); + } + } else if (found && comment) { + console.log("Bundle found, saying thanks"); + const text = REMINDER.split("\n\n").map(line => `~~${line.trim()}~~`).join("\n\n") + "\n\n" + THANKYOU + "\n" + marker; + if (comment.body !== text) { + await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: comment.id, + body: text + }); + } + } From 450d5bb9aef92c25a1722f9b9a053b594c8b5b5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 27 Oct 2021 12:57:01 +0200 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=91=B7=E2=80=8D=E2=99=82=EF=B8=8F=20F?= =?UTF-8?q?ix=20PR=20automation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Labels weren't refreshed properly in a step, causing labeling to be reverted and thereby causing issues in a later step. --- .github/workflows/pr_automation.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pr_automation.yml b/.github/workflows/pr_automation.yml index c1f115ecf..2d3ae592b 100644 --- a/.github/workflows/pr_automation.yml +++ b/.github/workflows/pr_automation.yml @@ -12,13 +12,18 @@ jobs: with: repo-token: "${{ secrets.GITHUB_TOKEN }}" - - uses: actions/github-script@v2 + - uses: actions/github-script@v5 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - let labels = []; + # fetch a fresh set of labels, they might have changed earlier + const issueLabels = await github.rest.issues.listLabelsOnIssue({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number + }); + let labels = issueLabels.data.map(label => label.name); let setLabels = false; - context.payload.pull_request.labels.forEach(label => { labels.push(label.name) }); let target = context.payload.pull_request.base.ref; if (["maintenance", "devel", "staging/maintenance", "staging/devel", "master"].includes(target)) { @@ -27,7 +32,7 @@ jobs: } if (setLabels) { - github.issues.setLabels({ + github.rest.issues.setLabels({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, From d3e92db8a8279966d1092280c2a2b9565d950313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 27 Oct 2021 22:54:21 +0200 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=91=B7=E2=80=8D=E2=99=82=EF=B8=8F=20R?= =?UTF-8?q?ephrase=20the=20bundle=20reminder?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit And doing this as a PR to test the PR label fix from earlier today... --- .github/workflows/issue_automation.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/issue_automation.yml b/.github/workflows/issue_automation.yml index bccc1b258..facf1ade8 100644 --- a/.github/workflows/issue_automation.yml +++ b/.github/workflows/issue_automation.yml @@ -79,9 +79,9 @@ jobs: what has happened. - Please upload **a bundle zip file** to the original issue post. Actually upload the file please and + Please **edit your original post above** and upload **a bundle zip file**. Actually upload the file please and do not paste some link to a cloud provider, we want to have everything in one place here. Also do - not unpack, repack or otherwise modify the bundle, share it **exactly** like you get it from OctoPrint. + not unpack, repack or otherwise modify the bundle or its name, share it **exactly** like you get it from OctoPrint. Without the availability of a bundle, your issue will have to be closed. From 4a9e573107e45ca5cb51442ca6ee669b52eb765f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 27 Oct 2021 22:58:45 +0200 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=91=B7=E2=80=8D=E2=99=82=EF=B8=8F=20F?= =?UTF-8?q?ix=20comment=20syntax=20in=20workflow=20step?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit JS uses `//`, not `#` ... --- .github/workflows/pr_automation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr_automation.yml b/.github/workflows/pr_automation.yml index 2d3ae592b..cc411d121 100644 --- a/.github/workflows/pr_automation.yml +++ b/.github/workflows/pr_automation.yml @@ -16,7 +16,7 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - # fetch a fresh set of labels, they might have changed earlier + // fetch a fresh set of labels, they might have changed earlier const issueLabels = await github.rest.issues.listLabelsOnIssue({ owner: context.repo.owner, repo: context.repo.repo,