feat: add a few basic checks for PR descriptions#40181
Conversation
PR summary 706a62f36dImport changes for modified filesNo significant changes to the import graph Import changes for all files
|
|
This PR/issue depends on: |
Not hooked up yet
Not exhaustive, but hopefully this is already useful. This PR only implements the checks; a separate PR will run them in CI.
Run the PR description check only when the title starts with "feat" and the PR is not labelled `easy`. The title-format check still runs for all PRs; only the description check is gated. Also fix label parsing: labels were read via `args.variableArgsAs!`, but none are declared, so the `--labels` flag was parsed and discarded and `labels` was always empty (the `WIP`-skip never fired either). Read the flag and split it on newlines, matching the workflow's `jq -r '.[].name'` output. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
7be2826 to
021e7dc
Compare
bryangingechen
left a comment
There was a problem hiding this comment.
Some tweaks / fixes (with help from Claude code).
Co-authored-by: Bryan Gin-ge Chen <bryangingechen@gmail.com>
|
Thanks for the review; I have addressed all comments. #40234 is just the fix for the label parsing. |
Co-authored-by: Bryan Gin-ge Chen <bryangingechen@gmail.com>
| -- commit message at the first line starting with "---" (its `cut_body_after = "\n---"`), | ||
| -- so that is exactly what we treat as a fold here. | ||
| let before := description.lines.toList.takeWhile (fun l ↦ !l.startsWith "---") | ||
| -- If `after` is non-empty, there is a fold. |
There was a problem hiding this comment.
Can we lint against descriptions without a fold? (if after.isEmpty)
There's no reason to delete the fold from the PR template, and I also think this will filter out many slop PRs since they ignore the template and replace everything with slop (and might not notice CI failing).
| if before.isEmpty && !after.isEmpty then | ||
| errors := errors.push | ||
| "warning: your PR description is non-empty, but everything is after the '---' line\n\ | ||
| note: the final PR commit message only uses what is above that line" |
There was a problem hiding this comment.
after includes the fold itself, so a PR description that is just a fold will error here but there is nothing after the --- line, so the warning text will seem strange.
I suggest something like:
let beforeContainsText := before.any (·.any (·.isAlpha))
let afterContainsText := after.any (·.any (·.isAlpha))and then using these booleans here. Other than accounting for the fold, this will also take care of descriptions such as
.
---
I also suggest using these booleans for the "description is empty" check.
Not exhaustive, but hopefully this is already useful.
Please carefully double-check the CI variable changes: this is what the Github documentation search told me (which is AI-powered); at some point, I gave up trying to verify this by hand.