Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
## What Changed?

<!-- Provide a clear summary of your changes. What did you add, remove, or modify? -->

## Why?

<!-- Explain why these changes were needed. What problem does this solve? Link any related issues. -->

Closes #(issue number)

## Type of Change

<!-- Check the box that applies by putting an 'x' inside the brackets: [x]. Delete the other unselected options. -->

- [ ] 🐛 Bug fix (fixes an issue without breaking existing functionality)
- [ ] ✨ New feature (adds new functionality without breaking existing features)
- [ ] 💥 Breaking change (existing functionality will be affected)
- [ ] 📝 Documentation update
- [ ] 🔧 Maintenance (refactoring, dependencies, configuration)

## How Did You Test This?

<!-- Describe what you did to verify your changes work correctly. This helps reviewers understand how to test your PR. -->

**What I tested:**

- [ ]
- [ ]

**How to test it:**

<!-- Optional: Add steps for reviewers to reproduce your testing -->

1.
2.

## Review Checklist

<!-- Quick self-check before submitting. You don't need to check every box, but consider each item. -->

- [ ] My code follows the project's style and conventions
- [ ] I've reviewed my own code for obvious issues
- [ ] I've added comments where the code might be confusing
- [ ] I've updated relevant documentation (if needed)
- [ ] I've tested my changes and they work as expected

## Screenshots / Additional Context

<!-- Optional: Add screenshots, logs, or any other helpful information for reviewers -->
75 changes: 75 additions & 0 deletions .github/workflows/pr-template-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: PR Template Check

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

jobs:
check-pr-description:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Check if PR description is filled out
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const prBody = context.payload.pull_request.body || '';

// Read the template file
const templatePath = '.github/pull_request_template.md';
let template = '';
try {
template = fs.readFileSync(templatePath, 'utf8');
} catch (error) {
console.log('⚠️ Could not read template file, skipping template comparison');
return;
}

// Normalize whitespace for comparison
const normalizeText = (text) => text.replace(/\s+/g, ' ').trim();
const normalizedPrBody = normalizeText(prBody);
const normalizedTemplate = normalizeText(template);

// Check if PR body is identical to template
if (normalizedPrBody === normalizedTemplate) {
core.setFailed('❌ PR description is identical to the template. Please fill out the template with information about your changes.');
return;
}

// Check if PR body is empty or only contains whitespace
if (prBody.trim().length === 0) {
core.setFailed('❌ PR description is empty. Please fill out the template with information about your changes.');
return;
}

// Keywords that indicate the template hasn't been filled out
const templateKeywords = [
'Provide a clear summary of your changes',
'What did you add, remove, or modify?',
'Explain why these changes were needed',
'Fixes #(issue number)',
];

// Check if template keywords are still present (indicating it wasn't filled out)
const foundKeywords = templateKeywords.filter(keyword =>
prBody.includes(keyword)
);

if (foundKeywords.length >= 2) {
core.setFailed(
`❌ PR template appears to be unfilled. Please replace the template text with your actual changes.\n\n` +
`Found unchanged template text:\n${foundKeywords.map(k => ` - "${k}"`).join('\n')}`
);
return;
}

// Check if "Fixes #(issue number)" is still present unchanged
if (prBody.includes('Fixes #(issue number)')) {
core.setFailed('❌ Please update "Fixes #(issue number)" with an actual issue number or remove it if not applicable.');
return;
}

console.log('✅ PR description appears to be properly filled out!');