From 4b741e2291663577465cb2f864a6bd623ce24b84 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Sun, 12 Apr 2026 02:57:55 +0100 Subject: [PATCH 1/2] CI/GnuComment: enhance PR commenting logic to update existing comments --- .github/workflows/GnuComment.yml | 39 +++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/.github/workflows/GnuComment.yml b/.github/workflows/GnuComment.yml index 5841aa36db7..8c9b51f1be9 100644 --- a/.github/workflows/GnuComment.yml +++ b/.github/workflows/GnuComment.yml @@ -49,14 +49,37 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - var fs = require('fs'); - var issue_number = Number(fs.readFileSync('./NR')); - var content = fs.readFileSync('./result.txt'); - if (content.toString().trim().length > 7) { // 7 because we have backquote + \n + const fs = require('fs'); + const issue_number = Number(fs.readFileSync('./NR')); + const content = fs.readFileSync('./result.txt').toString(); + + if (content.trim().length <= 7) { // 7 because we have backquote + \n + return; + } + + const marker = ''; + const body = `${marker}\nGNU testsuite comparison:\n\`\`\`\n${content}\n\`\`\``; + + const { data: comments } = await github.rest.issues.listComments({ + ...context.repo, + issue_number + }); + + const existing = comments.find(c => + c.user.login === 'github-actions[bot]' && + c.body.includes(marker) + ); + + if (existing) { + await github.rest.issues.updateComment({ + ...context.repo, + comment_id: existing.id, + body + }); + } else { await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: issue_number, - body: 'GNU testsuite comparison:\n```\n' + content + '```' + ...context.repo, + issue_number, + body }); } From 8492fcec1072c81ba85d5f1f7d8f45103e1d807c Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Sun, 12 Apr 2026 03:15:02 +0100 Subject: [PATCH 2/2] Make sure we still update the comment with if there was no change in test status --- .github/workflows/GnuComment.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/GnuComment.yml b/.github/workflows/GnuComment.yml index 8c9b51f1be9..3dc2a46d96a 100644 --- a/.github/workflows/GnuComment.yml +++ b/.github/workflows/GnuComment.yml @@ -53,10 +53,6 @@ jobs: const issue_number = Number(fs.readFileSync('./NR')); const content = fs.readFileSync('./result.txt').toString(); - if (content.trim().length <= 7) { // 7 because we have backquote + \n - return; - } - const marker = ''; const body = `${marker}\nGNU testsuite comparison:\n\`\`\`\n${content}\n\`\`\``; @@ -77,6 +73,9 @@ jobs: body }); } else { + if (content.trim().length <= 7) { // 7 because we have backquote + \n + return; + } await github.rest.issues.createComment({ ...context.repo, issue_number,