diff --git a/.github/scripts/issue-quality.cjs b/.github/scripts/issue-quality.cjs index 9b38b6b06..12d2ecc6c 100644 --- a/.github/scripts/issue-quality.cjs +++ b/.github/scripts/issue-quality.cjs @@ -16,6 +16,18 @@ const REPRODUCTION_ALIASES = [ "Stack trace", ]; +const ISSUE_QUALITY_MARKER = ""; +const ISSUE_QUALITY_STATE_PREFIX = ""; + const state = ''; + + it("accepts the issue-quality workflow's canonical state comment", () => { + assert.equal( + isCanonicalIssueQualityComment({ + user: { login: "github-actions[bot]" }, + body: `${marker}\n${state}\n\n### Maintainer decision respected`, + }), + true, + ); + }); + + it("rejects another bot workflow's comment containing spoofed state", () => { + assert.equal( + isCanonicalIssueQualityComment({ + user: { login: "github-actions[bot]" }, + body: `\n\n${marker}\n${state}`, + }), + false, + ); + }); + + it("rejects a matching comment from a non-actions author", () => { + assert.equal( + isCanonicalIssueQualityComment({ + user: { login: "reporter" }, + body: `${marker}\n${state}`, + }), + false, + ); + }); +}); + // --------------------------------------------------------------------------- // Translated / soft-pass / labels // --------------------------------------------------------------------------- diff --git a/.github/workflows/enforce-issue-quality.yml b/.github/workflows/enforce-issue-quality.yml index ba828712f..431d4ebb6 100644 --- a/.github/workflows/enforce-issue-quality.yml +++ b/.github/workflows/enforce-issue-quality.yml @@ -786,6 +786,7 @@ jobs: validateIssue, shouldReopen, shouldEnforceClosure, + isCanonicalIssueQualityComment, labelForKind, detectAreaLabels, AREA_LABELS, @@ -890,9 +891,7 @@ jobs: const comments = await github.paginate(github.rest.issues.listComments, { owner, repo, issue_number, per_page: 100, }); - const botComment = comments.find( - (c) => c.user?.login === "github-actions[bot]" && c.body?.includes(BOT_MARKER), - ); + const botComment = comments.find(isCanonicalIssueQualityComment); let botState = null; if (botComment) {