diff --git a/.github/workflows/pr-triage.yml b/.github/workflows/pr-triage.yml index 89ec8d9d..bf94fc0d 100644 --- a/.github/workflows/pr-triage.yml +++ b/.github/workflows/pr-triage.yml @@ -227,11 +227,11 @@ jobs: '**Risk notes:**', riskNotes.map((note) => `- ${note}`).join('\n'), '', + 'Hard merge gates still come from GitHub Actions, not AI review.', + '', '**Dosu handoff:** Dosu can be used as the AI reviewer for risk explanation, missing-test prompts, and maintainer Q&A. If it does not comment automatically from the PR template, ask:', '', - '`@dosubot review this PR for changed-area risk, missing tests, docs impact, desktop startup risk, and CLI core impact.`', - '', - 'Hard merge gates still come from GitHub Actions, not AI review.', + '@dosubot review this PR for changed-area risk, missing tests, docs impact, desktop startup risk, and CLI core impact.', ].join('\n') const comments = await github.paginate(github.rest.issues.listComments, { diff --git a/package.json b/package.json index 34ea1a7a..84e03205 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "start": "bun run ./bin/claude-haha", "check:pr": "bun run scripts/pr/check-pr.ts", "check:impact": "bun run scripts/pr/impact-report.ts", - "check:policy": "bun test scripts/pr/change-policy.test.ts", + "check:policy": "bun test scripts/pr/change-policy.test.ts scripts/pr/pr-triage-workflow.test.ts", "check:server": "bun run scripts/pr/run-server-tests.ts", "check:desktop": "cd desktop && bun run lint && bun run test -- --run && bun run build", "check:adapters": "cd adapters && bun test", diff --git a/scripts/pr/pr-triage-workflow.test.ts b/scripts/pr/pr-triage-workflow.test.ts new file mode 100644 index 00000000..a8932a36 --- /dev/null +++ b/scripts/pr/pr-triage-workflow.test.ts @@ -0,0 +1,28 @@ +import { describe, expect, test } from 'bun:test' +import { readFileSync } from 'node:fs' + +const DOSU_PROMPT = '@dosubot review this PR for changed-area risk, missing tests, docs impact, desktop startup risk, and CLI core impact.' + +function extractCommentBodyEntries(workflow: string) { + const match = workflow.match(/const body = \[([\s\S]*?)\n\s*\]\.join\('\\n'\)/) + if (!match) { + throw new Error('Could not find PR triage comment body array') + } + + return match[1] + .split('\n') + .map((line) => line.trim()) + .filter((line) => line.startsWith("'") || line.startsWith('`')) +} + +describe('PR triage workflow comment', () => { + test('ends with a plain-text Dosu mention so the bot is triggered', () => { + const workflow = readFileSync('.github/workflows/pr-triage.yml', 'utf8') + const entries = extractCommentBodyEntries(workflow) + const nonEmptyEntries = entries.filter((entry) => !/^['`]['`],?$/.test(entry)) + const lastEntry = nonEmptyEntries.at(-1) + + expect(lastEntry).toBe(`'${DOSU_PROMPT}',`) + expect(workflow).not.toContain(`\`${DOSU_PROMPT}\``) + }) +})