d5889919a9
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Contributor onboarding leans on a small set of CI gates
("commitperclip") that read PR metadata and enforce the rules in
CONTRIBUTING.md
> - We recently landed two new contributor rules: every PR must either
link an existing issue or inline an issue-template-shaped description,
and the author must affirm they searched for duplicate PRs first
> - The existing `check-pr-linked-issue` gate only accepted
`Fixes/Closes/Resolves #N`, and there was no gate at all for the
dedup-search affirmation, so the new rules were unenforced
> - This pull request widens the linked-issue gate (accept `Refs #N`,
accept inline template-shaped descriptions) and adds a new dedup-search
gate wired into `run-quality-gates`
> - The benefit is that the rules we ask contributors to follow are now
mechanically enforced, lowering review noise without raising contributor
friction
## Linked Issues or Issue Description
Refs #4260 — the PR cited in the original rule discussion, whose body is
the canonical example of the inline-issue-description shape this gate
now accepts.
**Problem or motivation**
The repo recently adopted two contributor rules: (1) link the issue your
PR fixes or inline a description in the issue-template shape, and (2)
confirm you searched for duplicate PRs before opening one. Neither rule
was enforced — the existing linked-issue check only matched
`Fixes/Closes/Resolves #N`, and nothing looked for the dedup-search
affirmation. Reviewers had to remember and re-state the rules by hand on
every PR.
**Proposed solution**
Widen `check-pr-linked-issue.mjs` and add a new
`check-pr-dedup-search.mjs` so commitperclip enforces the rules already
documented in CONTRIBUTING.md and the PR template:
- Accept `Refs #N` as a valid link verb alongside `Fixes`, `Closes`,
`Resolves`.
- Accept a PR body with an inline issue-template-shaped description (≥3
fields matched against the bug, feature, or adapter templates) as a
valid alternative to a linked issue.
- New `check-pr-dedup-search.mjs` looks for a checked checkbox affirming
the author searched for similar/duplicate/prior PRs, wired into
`run-quality-gates.mjs` with the same skip/override semantics as the
other gates.
**Alternatives considered**
- A single regex over the whole PR body looking for issue-template field
names — rejected, too brittle and gave no useful error message when it
failed. The per-field counter lets us tell the author exactly how many
template fields we matched and which template they're closest to.
- Making the dedup-search check live inside `check-pr-linked-issue` —
rejected, the two rules are orthogonal and a separate gate gives a
cleaner error message and respects `[skip-quality-gates]` independently.
**Roadmap alignment**
This is contributor-workflow plumbing for rules that already landed on
`master`. It is not a roadmap feature and does not overlap with planned
core work.
## What Changed
- `check-pr-linked-issue.mjs`: accept `Refs #N`; add
`hasInlineIssueDescription` (per-template field counter, ≥3 fields) so a
fully inlined description satisfies the gate.
- `check-pr-dedup-search.mjs`: new gate, looks for a checked
dedup-search checkbox in the PR body, with clear failure guidance.
- `run-quality-gates.mjs`: wire the new gate in alongside the existing
checks.
- `CONTRIBUTING.md`: "Before You Start: Search First" callout pointing
at the PR-template checkbox the gate enforces.
- Tests: unit tests for `Refs #N`, the inline-description threshold
(bolded labels, plain labels, headings), and the dedup-search gate
across checked/unchecked/missing/skip-prefix paths.
## Verification
- `node --test .github/scripts/tests/check-pr-linked-issue.test.mjs` →
all pass
- `node --test .github/scripts/tests/check-pr-dedup-search.test.mjs` →
all pass
- Full repo test matrix: 116/116 pass locally
For the gate itself, this PR exercises both new code paths: the body
inlines a feature-template-shaped description with ≥3 matched fields,
and the dedup-search checkbox below is checked.
## Risks
Low risk. The change is contributor-CI plumbing — no runtime or
migration impact. The widened linked-issue gate is strictly more
permissive (it can only flip prior FAILs to PASS), and the new
dedup-search gate honors the existing `[skip-quality-gates]` prefix, so
an author can always bypass it the same way as the other gates if
needed.
## Model Used
Claude Opus 4.7 (`claude-opus-4-7`), extended-thinking enabled, tool use
for filesystem + shell.
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [ ] If this change affects the UI, I have included before/after
screenshots
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge
Co-authored-by: Paperclip <noreply@paperclip.ing>
224 lines
6.3 KiB
JavaScript
224 lines
6.3 KiB
JavaScript
import { test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { checkLinkedIssue, hasInlineIssueDescription } from '../check-pr-linked-issue.mjs';
|
|
|
|
// Existing tests with title parameter added (defaults to no prefix, so still required)
|
|
|
|
test('passes with bare #NNN reference', () => {
|
|
assert.equal(checkLinkedIssue('This fixes the bug in #123', 'fix: something').passed, true);
|
|
});
|
|
|
|
test('passes with "Fixes #NNN"', () => {
|
|
assert.equal(checkLinkedIssue('Fixes #456\n\nSome description', 'fix: something').passed, true);
|
|
});
|
|
|
|
test('passes with "Closes #NNN" (case-insensitive)', () => {
|
|
assert.equal(checkLinkedIssue('closes #789', 'fix: something').passed, true);
|
|
});
|
|
|
|
test('passes with "Resolves #NNN"', () => {
|
|
assert.equal(checkLinkedIssue('Resolves #101', 'fix: something').passed, true);
|
|
});
|
|
|
|
test('passes with "Refs #NNN"', () => {
|
|
assert.equal(checkLinkedIssue('Refs #202', 'fix: something').passed, true);
|
|
});
|
|
|
|
test('passes with "refs #NNN" (case-insensitive)', () => {
|
|
assert.equal(checkLinkedIssue('refs #303', 'fix: something').passed, true);
|
|
});
|
|
|
|
test('passes with full github.com URL', () => {
|
|
assert.equal(
|
|
checkLinkedIssue('See https://github.com/paperclipai/paperclip/issues/202', 'fix: bug').passed,
|
|
true
|
|
);
|
|
});
|
|
|
|
test('passes with a full github.com URL followed by punctuation', () => {
|
|
assert.equal(
|
|
checkLinkedIssue('See (https://github.com/paperclipai/paperclip/issues/202).', 'fix: bug').passed,
|
|
true
|
|
);
|
|
});
|
|
|
|
test('fails with empty body when no skip prefix', () => {
|
|
const result = checkLinkedIssue('', 'fix: bug');
|
|
assert.equal(result.passed, false);
|
|
assert.ok(result.failures.length > 0);
|
|
});
|
|
|
|
test('fails with no issue reference when no skip prefix', () => {
|
|
const result = checkLinkedIssue('Added a cool feature, no issue linked', 'feat: something');
|
|
assert.equal(result.passed, false);
|
|
assert.ok(result.failures[0].includes('Fixes #NNN'));
|
|
});
|
|
|
|
test('fails with cross-repo issue reference', () => {
|
|
const result = checkLinkedIssue('See https://github.com/other/repo/issues/123', 'fix: bug');
|
|
assert.equal(result.passed, false);
|
|
});
|
|
|
|
test('fails when the Paperclip issue URL is embedded inside another host', () => {
|
|
const result = checkLinkedIssue(
|
|
'See https://evil.example/https://github.com/paperclipai/paperclip/issues/123',
|
|
'fix: bug'
|
|
);
|
|
assert.equal(result.passed, false);
|
|
});
|
|
|
|
test('fails when the Paperclip issue URL continues into another host', () => {
|
|
const result = checkLinkedIssue(
|
|
'See https://github.com/paperclipai/paperclip/issues/123.evil.example',
|
|
'fix: bug'
|
|
);
|
|
assert.equal(result.passed, false);
|
|
});
|
|
|
|
test('fails when #NNN is part of a word (no space before)', () => {
|
|
const result = checkLinkedIssue('This is version#123 not an issue link', 'fix: bug');
|
|
assert.equal(result.passed, false);
|
|
});
|
|
|
|
// Prefix-aware skip behavior
|
|
|
|
test('skips check for docs: prefix', () => {
|
|
assert.equal(checkLinkedIssue('', 'docs: update README').passed, true);
|
|
});
|
|
|
|
test('skips check for chore: prefix', () => {
|
|
assert.equal(checkLinkedIssue('', 'chore: bump deps').passed, true);
|
|
});
|
|
|
|
test('skips check for build: prefix', () => {
|
|
assert.equal(checkLinkedIssue('', 'build: update Dockerfile').passed, true);
|
|
});
|
|
|
|
test('skips check for ci: prefix', () => {
|
|
assert.equal(checkLinkedIssue('', 'ci: add workflow').passed, true);
|
|
});
|
|
|
|
test('skips check for test: prefix', () => {
|
|
assert.equal(checkLinkedIssue('', 'test: add coverage').passed, true);
|
|
});
|
|
|
|
test('skips check with scoped prefix like docs(api):', () => {
|
|
assert.equal(checkLinkedIssue('', 'docs(api): document endpoint').passed, true);
|
|
});
|
|
|
|
test('requires issue for feat: prefix', () => {
|
|
assert.equal(checkLinkedIssue('Some description without issue', 'feat: new thing').passed, false);
|
|
});
|
|
|
|
test('requires issue for refactor: prefix', () => {
|
|
assert.equal(checkLinkedIssue('Some refactor', 'refactor: rewrite thing').passed, false);
|
|
});
|
|
|
|
test('requires issue when no prefix (encourages prefix usage)', () => {
|
|
assert.equal(checkLinkedIssue('No prefix here', 'Add some feature').passed, false);
|
|
});
|
|
|
|
// Inline issue description (path 2)
|
|
|
|
const BUG_INLINE_BODY = `
|
|
## What happened?
|
|
|
|
Login button does nothing when clicked.
|
|
|
|
## Expected behavior
|
|
|
|
Clicking the login button should authenticate the user.
|
|
|
|
## Steps to reproduce
|
|
|
|
1. Open the app
|
|
2. Click login
|
|
3. Nothing happens
|
|
`;
|
|
|
|
const FEATURE_INLINE_BODY = `
|
|
## Problem or motivation
|
|
|
|
We don't have a way to bulk-tag issues.
|
|
|
|
## Proposed solution
|
|
|
|
Add a bulk-tag action to the issues list.
|
|
|
|
## Alternatives considered
|
|
|
|
Tagging individually — too slow.
|
|
`;
|
|
|
|
const ADAPTER_INLINE_BODY = `
|
|
## Agent or provider
|
|
|
|
Gemini CLI
|
|
|
|
## Why this adapter is useful
|
|
|
|
Lots of users want Gemini as an alternative model option.
|
|
|
|
## How the agent is invoked
|
|
|
|
Via the \`gemini\` CLI binary with stdin/stdout JSON.
|
|
`;
|
|
|
|
test('passes with inline bug description (3 template fields, feat: prefix)', () => {
|
|
assert.equal(checkLinkedIssue(BUG_INLINE_BODY, 'feat: fix login button').passed, true);
|
|
});
|
|
|
|
test('passes with inline feature description (3 template fields)', () => {
|
|
assert.equal(checkLinkedIssue(FEATURE_INLINE_BODY, 'feat: bulk tag').passed, true);
|
|
});
|
|
|
|
test('passes with inline adapter description (3 template fields)', () => {
|
|
assert.equal(checkLinkedIssue(ADAPTER_INLINE_BODY, 'feat: gemini adapter').passed, true);
|
|
});
|
|
|
|
test('fails with only two bug template fields (below threshold)', () => {
|
|
const body = `
|
|
## What happened?
|
|
|
|
Something broke.
|
|
|
|
## Expected behavior
|
|
|
|
It should work.
|
|
`;
|
|
assert.equal(checkLinkedIssue(body, 'feat: fix').passed, false);
|
|
});
|
|
|
|
test('fails with a single stray template-like heading', () => {
|
|
const body = `
|
|
This is mostly a free-form description but one heading happens to match.
|
|
|
|
## Expected behavior
|
|
|
|
Everything works.
|
|
`;
|
|
assert.equal(checkLinkedIssue(body, 'feat: fix').passed, false);
|
|
});
|
|
|
|
test('hasInlineIssueDescription returns true for ≥3 bug fields', () => {
|
|
assert.equal(hasInlineIssueDescription(BUG_INLINE_BODY), true);
|
|
});
|
|
|
|
test('hasInlineIssueDescription returns false for empty body', () => {
|
|
assert.equal(hasInlineIssueDescription(''), false);
|
|
});
|
|
|
|
test('hasInlineIssueDescription accepts bolded labels with colons', () => {
|
|
const body = `
|
|
**Problem:**
|
|
We need this.
|
|
|
|
**Proposed solution:**
|
|
Build it.
|
|
|
|
**Alternatives considered:**
|
|
None.
|
|
`;
|
|
assert.equal(hasInlineIssueDescription(body), true);
|
|
});
|