-
Notifications
You must be signed in to change notification settings - Fork 54
feat: enforce PR title convention and description requirements in CI #240
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
Closed
Xoulomon
wants to merge
2
commits into
MindBlockLabs:main
from
Xoulomon:feature/add-pr-validation-ci
+208
−0
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file was not in the issue description. Again, delete it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| # PR Validation CI/CD Guide | ||
|
|
||
| ## What Was Implemented | ||
|
|
||
| ### 1. CI Workflow Changes (`.github/workflows/ci.yml`) | ||
|
|
||
| Added a new `validate-pr` job that runs **only on pull requests** and validates: | ||
|
|
||
| - ✅ **PR Title**: Must follow Conventional Commits format with minimum 10 characters | ||
| - ✅ **PR Description**: Must contain at least 15 words | ||
| - ✅ **Branch Name**: Must follow `feature/*`, `fix/*`, or `docs/*` pattern | ||
|
|
||
| The `build` job now depends on `validate-pr`, so validation failures block the build. | ||
|
|
||
| ### 2. Documentation Updates (`CONTRIBUTING.md`) | ||
|
|
||
| Added comprehensive sections covering: | ||
| - Branch naming conventions with examples | ||
| - PR title format requirements | ||
| - PR description requirements with example | ||
|
|
||
| --- | ||
|
|
||
| ## Testing the Validation | ||
|
|
||
| ### ✅ Valid PR Example | ||
|
|
||
| **Branch:** `feature/add-user-profile` | ||
|
|
||
| **Title:** `feat: add user profile page with avatar upload` | ||
|
|
||
| **Description:** | ||
| ``` | ||
| This PR implements a new user profile page where users can view and edit their information. | ||
|
|
||
| Changes include: | ||
| - New ProfilePage component with form validation | ||
| - Avatar upload functionality using multipart/form-data | ||
| - Integration with existing user API endpoints | ||
|
|
||
| Tested manually with different user accounts. Closes #45 | ||
| ``` | ||
|
|
||
| **Result:** ✅ All validations pass | ||
|
|
||
| --- | ||
|
|
||
| ### ❌ Invalid PR Examples | ||
|
|
||
| #### Example 1: Bad Title | ||
| **Branch:** `feature/profile-page` | ||
| **Title:** `update` | ||
| **Description:** Valid description with more than 15 words explaining the changes made... | ||
|
|
||
| **Result:** ❌ Fails - Title doesn't follow convention | ||
|
|
||
| --- | ||
|
|
||
| #### Example 2: Short Description | ||
| **Branch:** `feature/profile-page` | ||
| **Title:** `feat: add user profile page` | ||
| **Description:** `Closes #45` | ||
|
|
||
| **Result:** ❌ Fails - Description too short (only 2 words) | ||
|
|
||
| --- | ||
|
|
||
| #### Example 3: Bad Branch Name | ||
| **Branch:** `my-feature` | ||
| **Title:** `feat: add user profile page` | ||
| **Description:** Valid description with more than 15 words... | ||
|
|
||
| **Result:** ❌ Fails - Branch name doesn't follow convention | ||
|
|
||
| --- | ||
|
|
||
| ## How to Test Locally | ||
|
|
||
| You can test the validation logic locally before pushing: | ||
|
|
||
| ### Test PR Title | ||
| ```bash | ||
| title="feat: add user authentication system" | ||
| if echo "$title" | grep -qE '^(feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert): .{10,}$'; then | ||
| echo "✅ Valid" | ||
| else | ||
| echo "❌ Invalid" | ||
| fi | ||
| ``` | ||
|
|
||
| ### Test PR Description Word Count | ||
| ```bash | ||
| description="This PR adds OAuth2 authentication support using Google as the provider." | ||
| word_count=$(echo "$description" | wc -w) | ||
| if [ "$word_count" -ge 15 ]; then | ||
| echo "✅ Valid ($word_count words)" | ||
| else | ||
| echo "❌ Too short ($word_count words)" | ||
| fi | ||
| ``` | ||
|
|
||
| ### Test Branch Name | ||
| ```bash | ||
| branch="feature/user-authentication" | ||
| if echo "$branch" | grep -qE '^(feature|fix|docs)/[a-z0-9-]+$'; then | ||
| echo "✅ Valid" | ||
| else | ||
| echo "❌ Invalid" | ||
| fi | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Validation Rules Summary | ||
|
|
||
| | Check | Rule | Example | | ||
| |-------|------|---------| | ||
| | **Branch Name** | `feature/*`, `fix/*`, or `docs/*` | `feature/add-login` | | ||
| | **PR Title** | `<type>: <description (10+ chars)>` | `feat: add OAuth login` | | ||
| | **PR Description** | Minimum 15 words | See valid example above | | ||
|
|
||
| --- | ||
|
|
||
| ## CI Behavior | ||
|
|
||
| - **On Push to main/develop**: Validation is skipped (only runs on PRs) | ||
| - **On Pull Request**: Validation runs first, then build/lint/type-check | ||
| - **If Validation Fails**: Build job is blocked, PR cannot be merged | ||
| - **If Validation Passes**: Normal CI pipeline continues | ||
|
|
||
| --- | ||
|
|
||
| ## For Contributors | ||
|
|
||
| Before opening a PR, ensure: | ||
|
|
||
| 1. ✅ Your branch follows the naming convention | ||
| 2. ✅ Your PR title is descriptive and follows the format | ||
| 3. ✅ Your PR description explains what, why, and how | ||
| 4. ✅ You've tested your changes locally | ||
|
|
||
| This helps maintainers review faster and keeps the project history clean! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.