From 140b448181aeaa0dd6ee7a43d6f24225abdeb661 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 18 Jul 2026 10:59:46 +0000 Subject: [PATCH 1/3] feat(action): add comment-on-clean input to suppress success comments - Add new input 'comment-on-clean' (default true) to control whether PR comments are posted on clean scans - Update render script to detect and output 'clean' flag - Modify comment-posting step to skip creating new comments when clean and flag is false (but still update existing ones) - Add tests for clean scan detection Closes #1385 Co-authored-by: Skosh --- action.yml | 12 ++++++++++++ .../react-doctor/tests/github-action-comment.test.ts | 10 ++++++++++ scripts/render-github-action-comment.mjs | 10 ++++++++++ 3 files changed, 32 insertions(+) diff --git a/action.yml b/action.yml index 055a0939c9..0fb676a05b 100644 --- a/action.yml +++ b/action.yml @@ -20,6 +20,9 @@ inputs: comment: description: "Create or update a sticky pull request summary comment. Automatically skipped when the pull request changes no React-eligible files (`.tsx`/`.jsx` or framework entry files)." default: "true" + comment-on-clean: + description: "When comment is enabled, whether to post a comment when the scan finds no issues. Set to false to only comment when there are issues to fix, reducing PR noise. Existing comments are still updated." + default: "true" review-comments: description: "Post inline review comments on the changed lines that triggered diagnostics (pull requests only)." default: "true" @@ -386,6 +389,8 @@ runs: env: REACT_DOCTOR_COMMENT_FILE: ${{ steps.render.outputs.comment-file }} REACT_DOCTOR_SKIPPED: ${{ steps.render.outputs.skipped }} + REACT_DOCTOR_CLEAN: ${{ steps.render.outputs.clean }} + REACT_DOCTOR_COMMENT_ON_CLEAN: ${{ inputs.comment-on-clean }} with: script: | const fs = require("fs"); @@ -401,6 +406,12 @@ runs: // changes were reverted out of the PR. const skipped = process.env.REACT_DOCTOR_SKIPPED === "true"; + // A clean scan (no issues found) can optionally skip creating new + // comments via the `comment-on-clean` input, reducing PR noise. Existing + // comments are still updated so stale findings don't linger. + const clean = process.env.REACT_DOCTOR_CLEAN === "true"; + const commentOnClean = process.env.REACT_DOCTOR_COMMENT_ON_CLEAN !== "false"; + const marker = ""; try { const { data: comments } = await github.rest.issues.listComments({ @@ -410,6 +421,7 @@ runs: }); const previous = comments.find((comment) => comment.body?.startsWith(marker)); if (skipped && !previous) return; + if (clean && !commentOnClean && !previous) return; if (previous) { await github.rest.issues.updateComment({ ...context.repo, diff --git a/packages/react-doctor/tests/github-action-comment.test.ts b/packages/react-doctor/tests/github-action-comment.test.ts index b8b8f803d2..47c087244a 100644 --- a/packages/react-doctor/tests/github-action-comment.test.ts +++ b/packages/react-doctor/tests/github-action-comment.test.ts @@ -356,6 +356,7 @@ describe("render-github-action-comment", () => { expect(comment).not.toContain("No React Doctor issues found"); expect(comment).not.toContain("found no issues"); expect(outputs).toContain("skipped=true"); + expect(outputs).toContain("clean=false"); }); it("marks a diff scan whose changed files examined zero eligible files as skipped", () => { @@ -378,6 +379,7 @@ describe("render-github-action-comment", () => { expect(comment).toContain("React Doctor skipped this pull request"); expect(outputs).toContain("skipped=true"); + expect(outputs).toContain("clean=false"); }); it("does NOT skip a clean scan of real React changes (eligible files examined)", () => { @@ -401,6 +403,14 @@ describe("render-github-action-comment", () => { expect(comment).toContain("**React Doctor** found no issues. 🎉"); expect(comment).not.toContain("skipped this pull request"); expect(outputs).toContain("skipped=false"); + expect(outputs).toContain("clean=true"); + }); + + it("marks a scan with issues as not clean", () => { + const { outputs } = runRenderer(buildReport()); + + expect(outputs).toContain("skipped=false"); + expect(outputs).toContain("clean=false"); }); it("does NOT skip a full-scope scan with no projects (clean success, not a no-op)", () => { diff --git a/scripts/render-github-action-comment.mjs b/scripts/render-github-action-comment.mjs index d208c4cfd3..0149160912 100644 --- a/scripts/render-github-action-comment.mjs +++ b/scripts/render-github-action-comment.mjs @@ -401,6 +401,14 @@ const isSkippedScan = (report) => { return (report.projects ?? []).every((project) => project.scannedFileCount === 0); }; +const isCleanScan = (report) => { + if (!report.ok) return false; + if (isSkippedScan(report)) return false; + if ((report.summary?.totalDiagnosticCount ?? 0) > 0) return false; + if (hasIncompleteChecks(report)) return false; + return true; +}; + // Unified body for every successful scan (baseline, diff, full). The lead line // adapts to the mode; the error/warning lists are shared. const buildIssuesBody = (report) => { @@ -434,6 +442,7 @@ if (!report) { process.exit(0); } const skipped = isSkippedScan(report); +const clean = isCleanScan(report); const body = skipped ? buildSingleLineBody(COPY.skipped) : buildCommentBody(report); if (commentPath) { @@ -445,6 +454,7 @@ if (commentPath) { // The Action reads this to suppress the sticky PR comment (it still mirrors the // body into the job summary + commit status, which read "skipped"). appendOutput("skipped", skipped ? "true" : "false"); +appendOutput("clean", clean ? "true" : "false"); appendOutput( "score", From e41634b093069022f046b3293ced49a3d7f1bbd9 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 18 Jul 2026 11:00:03 +0000 Subject: [PATCH 2/3] chore: add changeset for comment-on-clean feature Co-authored-by: Skosh --- .changeset/quiet-success-comments.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/quiet-success-comments.md diff --git a/.changeset/quiet-success-comments.md b/.changeset/quiet-success-comments.md new file mode 100644 index 0000000000..1ee3824abc --- /dev/null +++ b/.changeset/quiet-success-comments.md @@ -0,0 +1,5 @@ +--- +"react-doctor": patch +--- + +Add `comment-on-clean` input to GitHub Action to suppress success comments. When set to `false`, the action will only post PR comments when issues are found, reducing noise. Existing comments are still updated to reflect the latest scan results. From a422dbc5217ddd80524aaa216cac00dc6d74581f Mon Sep 17 00:00:00 2001 From: Aiden Bai Date: Mon, 27 Jul 2026 03:45:05 +0000 Subject: [PATCH 3/3] chore(action): remove unrelated package changeset --- .changeset/quiet-success-comments.md | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 .changeset/quiet-success-comments.md diff --git a/.changeset/quiet-success-comments.md b/.changeset/quiet-success-comments.md deleted file mode 100644 index 1ee3824abc..0000000000 --- a/.changeset/quiet-success-comments.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"react-doctor": patch ---- - -Add `comment-on-clean` input to GitHub Action to suppress success comments. When set to `false`, the action will only post PR comments when issues are found, reducing noise. Existing comments are still updated to reflect the latest scan results.