Enforce pull request conventions
Why Pull Request Conventions Matter¶
Consistent pull request (PR) conventions help teams identify what to expect from the pull request. Enforcing standards for PR titles, commit messages, and labels ensures that every change is clearly documented, easy to review, and traceable to business requirements or issues as well as to reduce cognitive load for developers and reviewers.
The following workflow steps demonstrate how to automate PR convention enforcement using GitHub Actions:
- name: PR Conventional Commit Validation
uses: ytanikin/pr-conventional-commits@1.4.0
with:
task_types: '["feat","fix","docs","test","ci","refactor","perf","chore","revert"]'
ticket_key_regex: 'AB#\d{1,6}'
custom_labels: |
{"feat": "feature", "fix": "fix", "docs": "documentation", "test": "test",
"ci": "CI/CD", "refactor": "refactor", "perf": "performance", "chore": "chore",
"revert": "revert", "wip": "WIP"}
add_scope_label: 'true'
- name: Assign PR to author
uses: toshimaru/auto-author-assign@v2.1.1
There may be variations in the implementation based on your choice of CI/CD platform, but the core principles remain the same.
What This Does¶
- PR Conventional Commit Validation:
- Enforces commit message formats (e.g.,
feat,fix,docs, etc.). - Requires a ticket key (e.g.,
AB#12345) for traceability. In the case of test automation, a test suite, test plan, or even a test case ID can be used to trace them back to testing efforts. - Applies custom labels for better categorization and reporting.
-
Adds scope labels to clarify the area of change.
-
Assign PR to Author:
- Automatically assigns the PR to its author, ensuring accountability and smoother review cycles.
Benefits¶
- Quality & Consistency: Every PR follows a predictable format, making reviews faster and easier.
- Traceability: Ticket keys link code changes to work items, supporting compliance and audit needs.
- Automation: Reduces manual effort and errors by automating checks and assignments.
- Collaboration: Clear labeling and author assignment help teams coordinate reviews and releases.