Skip to content

Improve PR description template #7706

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
May 6, 2025
19 changes: 8 additions & 11 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
## What changed?
<!-- Describe what has changed in this PR -->
_Describe what has changed in this PR._

## Why?
<!-- Tell your future self why have you made these changes -->
_Tell your future self why have you made these changes._

## How did you test it?
<!-- How have you verified this change? Tested locally? Added a unit test? Checked in staging env? -->
- [ ] built
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [ ] built
- [ ] yolo
- [ ] built

(not a serious suggestion)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"tested in production"
"my code doesn't need testing, it is flawless"
"checked by Chuck Norris"

There a bunch of good options.

- [ ] run locally and tested manually
- [ ] covered by existing tests
- [ ] added new unit test(s)
- [ ] added new functional test(s)

## Potential risks
<!-- Assuming the worst case, what can be broken when deploying this change to production? -->

## Documentation
<!-- Have you made sure this change doesn't falsify anything currently stated in `docs/`? If significant
new behavior is added, have you described that in `docs/`? -->

## Is hotfix candidate?
<!-- Is this PR a hotfix candidate or does it require a notification to be sent to the broader community? (Yes/No) -->
_Any change is risky. Identify all risks you are aware of. If none, remove this section._
59 changes: 59 additions & 0 deletions .github/workflows/check-pr-placeholders.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Validate PR description for placeholder lines or empty sections

on:
pull_request:
types: [opened, edited, synchronize, reopened]

permissions:
pull-requests: read

jobs:
validate-pr-description:
runs-on: ubuntu-latest

steps:
- name: Validate PR description for placeholder lines or empty sections
uses: actions/github-script@v7
with:
script: |
const pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number
});

const body = pr.data.body || '';
const lines = body.split(/\r?\n/);

let violations = [];

// Detect placeholder lines: entire line starts and ends with _
lines.forEach((line, idx) => {
if (/^_.*_$/.test(line.trim())) {
violations.push(`Line ${idx + 1}: Placeholder "${line.trim()}"`);
}
});

// Detect empty sections: look for headers like '## Why?' followed by no meaningful content
const requiredSections = ['## What changed?', '## Why?', '## How did you test it?'];
requiredSections.forEach((header) => {
const idx = lines.findIndex(line => line.trim().toLowerCase() === header.toLowerCase());
if (idx !== -1) {
let contentIdx = idx + 1;
while (contentIdx < lines.length && lines[contentIdx].trim() === '') {
contentIdx++;
}
const nextLine = lines[contentIdx]?.trim();
if (!nextLine || /^## /.test(nextLine)) {
violations.push(`Section "${header}" appears to be empty.`);
}
}
});

if (violations.length > 0) {
console.log("❌ PR description issues found:");
violations.forEach(v => console.log(`- ${v}`));
core.setFailed(`PR description must not contain placeholders or empty sections.`);
} else {
console.log("✅ PR description passed all checks.");
}
Loading