feat: add pr-title input to validate pull request title#217
Conversation
Add a new pr-title input that validates the PR title against the Conventional Commits specification using commit-check's --message check. This is especially useful for teams using Squash and Merge, where the PR title becomes the final commit message. Key changes: - action.yml: add pr-title input (default: false) - main.py: add get_pr_title(), PR_TITLE_ENABLED flag, integrate PR title validation into run_commit_check() - main_test.py: add tests for get_pr_title(), PR title in run_commit_check(), and initial_emitted parameter Closes #93
|
Warning Review limit reached
More reviews will be available in 54 minutes and 29 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Commit-Check ✔️ |
The pr-comments feature has been stable for 8+ months with proper fork PR handling, pull_request_target support, and comprehensive error handling. The 'experimental' label is no longer accurate.
…change The pull_request event does not include the 'edited' type by default, so changing the PR title never re-triggers the workflow. Adding 'edited' ensures the pr-title check runs immediately when the title is updated, giving the contributor instant feedback.
Explain that pull_request does not trigger on title edits by default, and show how to add the 'edited' type to enable immediate validation.
- Print '--- PR title check ---' in the log so users can distinguish PR title validation from individual commit message checks - Always set output_prefix for result.txt so the failure output clearly identifies which check failed
Remove the markdown-style '# PR Title Validation' heading from result.txt. When the PR title check fails after other failures, use '--- PR Title ---' to match the existing commit check separator style (e.g. '--- Commit 2/6:').
Remove the 'commit-check --message' command lines that were being printed to the action log for every check invocation. The results are already visible in the job summary and PR comments — the command echo was debug cruft that created noise, especially when checking many individual commits in a PR.
Convert log_env_vars() to use ::debug:: workflow commands so the environment variable values only appear in the action log when ACTIONS_STEP_DEBUG is enabled. This follows GitHub Actions best practices for diagnostic output.
The PR title check always runs first, so the 'if emitted_failure_output' branch inside it was unreachable. Remove it to reduce nesting and improve readability.
Summary
Add a new
pr-titleinput that validates the pull request title against Conventional Commits using commit-check's--messagecheck.Motivation
Many teams use Squash & Merge, where individual commit messages are discarded and the PR title becomes the final commit message in the main branch. Previously, the action only validated individual git commits — which means:
This PR fixes that gap. See issue #93 for more context.
Usage
When
pr-title: trueis set on apull_requestorpull_request_targetevent, the action readsgithub.event.pull_request.titlefrom the event payload and validates it viacommit-check --message.Implementation details
All changes are in the action layer only — the upstream commit-check CLI already has the validation logic (
--message), the action just provides the right input (PR title from event payload).Changed files
action.ymlpr-titleinput (default:false) andPR_TITLEenv varmain.pyget_pr_title(),PR_TITLE_ENABLEDflag, integrated PR title check intorun_commit_check()before other checksmain_test.pyget_pr_title(), PR title flow inrun_commit_check(), andinitial_emittedparameterBehavior matrix
messagepr-titlepr-titleskipped (not in PR context)Closes
Closes #93