ci: require a closing magic word for the Linear link - #222
Conversation
dirvine
left a comment
There was a problem hiding this comment.
One blocking issue: this checker does not match Linear’s documented closing syntax. Linear supports close/closes/closed/closing, fix/fixes/fixed/fixing, resolve/resolves/resolved/resolving, complete/completes/completed/completing, implement/implements/implemented/implementing, and linear issue; MAGIC_WORDS accepts only five of those.
For example, Fixed V2-1161 links and closes the issue in Linear, but I reproduced that it exits 1 here. Because this is merge-blocking CI, it would reject valid Linear-linked PRs, while the new comments also incorrectly say these five are the closing words Linear recognises. Please expand MAGIC_WORDS and the tests to cover Linear’s official closing set.
Official reference: https://linear.app/docs/github
A bare `V2-123` in a PR description does not link the PR to the issue — Linear ignores it — so a PR could pass the `linear-link` check while never appearing on the issue and never driving it to Merged when it lands on `main`. ant-node WithAutonomi#216 is the concrete case: it carried `V2-1033` under the Linear heading, had no identifier in its branch name, and had to be attached to the issue by hand. The `linear-link` check now requires one of Linear's closing magic words followed by the issue key in the PR body. The accepted set is taken verbatim from https://linear.app/docs/github — close / fix / resolve / complete / implement in every tense (`-s`, `-d`, `-ing`) plus the phrase `linear issue`, case-insensitive, with either the key or a linear.app issue URL. Linear's linking-only families (`ref`, `part of`, `towards`, `relates to`) attach a PR without driving the Merged transition, so they are deliberately not accepted. An identifier in the branch name or the PR title remains an accepted alternative, since both also link the PR. The magic word and the key must sit on the same line, so a paragraph that merely ends in "...closes." cannot pair up with a bare key further down the body, and the template's own `## Linear issue` heading cannot pair up with a bare key on the line beneath it. `pr-template` applies the same rule to the `## Linear issue` section, and the template comment and CLAUDE.md now ask for the closing form and say why the bare and linking-only forms do not work. The self-test matrix grows from 17 to 52 cases: one per documented closing word, the URL form, case-insensitivity, the linking-only rejections, word-boundary cases, and the bare-reference rejections. Closes V2-1161 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WN8hjL7E8qcCxJBgT9vFt6
2611d7c to
0c47709
Compare
|
You're right, and I've fixed it — amended and force-pushed. I checked the claim against https://linear.app/docs/github rather than taking it on trust, and the docs confirm it. Your repro now passes: Alternatives are sorted longest-first when the pattern is built, so What I did not add, deliberately: the linking-only families the same docs page lists — On the incorrect comments: also fixed. Tests: the matrix went 30 → 52 cases. It generates one case per closing word from its own tuple, restated independently of The same amended commit is on all six train repos. |
dirvine
left a comment
There was a problem hiding this comment.
Follow-up review: the full documented Linear closing-word set is now covered, including the previously rejected forms. The expanded local test suite passes 52/52. Approved.
Linear issue
Closes V2-1161
Risk tier
Compatibility
Semver impact
Test evidence
python3 .github/scripts/test_check_pr.py— 52/52 cases pass, in this repo andin all six (the
self-testjob runs the same matrix). The matrix grew from 17 to 52cases, asserting: one case per closing magic word Linear documents, in the tense an
author would actually write (
Closed,Fixed,Resolving,Implemented, …); theCloses <linear.app issue URL>form; lower-cased input; thelinear issuephrase;the linking-only families (
ref,part of,towards,relates to) rejected, sincethey attach a PR without driving the Merged transition; word-boundary cases
(
prefix/fixturemust not match); a magic word with no key; a magic word separatedfrom its key by a blank line; and bare key or bare issue URL in the body — the last of
which used to pass and now fails, which is the point of the change.
The accepted set is taken verbatim from https://linear.app/docs/github and restated
independently in the test matrix, so the matrix is an assertion about the documented
behaviour rather than a restatement of the implementation.
This PR is its own end-to-end test: it carries the closing form in the body, and the
pull_requestevent runs the version ofcheck_pr.pyfrom this branch.New dependency
none
ADR
n/a
Mitigation / rollback
Revert the commit. The check is a CI gate with no runtime surface; reverting restores
the previous
linear-linkbehaviour immediately.