Skip to content

feat: add pr-title input to validate pull request title#217

Merged
shenxianpeng merged 14 commits into
mainfrom
feature/pr-title-validation
Jun 16, 2026
Merged

feat: add pr-title input to validate pull request title#217
shenxianpeng merged 14 commits into
mainfrom
feature/pr-title-validation

Conversation

@shenxianpeng

Copy link
Copy Markdown
Member

Summary

Add a new pr-title input that validates the pull request title against Conventional Commits using commit-check's --message check.

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:

  • Squash & Merge teams saw noisy failures on intermediate commits (wip, fixup, etc.) that never land in main
  • The actual commit message that ends up in main (the PR title) was never validated

This PR fixes that gap. See issue #93 for more context.

Usage

- uses: commit-check/commit-check-action@v2
  with:
    pr-title: true     # validate PR title against Conventional Commits
    message: true      # (optional) also validate individual git commits

When pr-title: true is set on a pull_request or pull_request_target event, the action reads github.event.pull_request.title from the event payload and validates it via commit-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

File Changes
action.yml Added pr-title input (default: false) and PR_TITLE env var
main.py Added get_pr_title(), PR_TITLE_ENABLED flag, integrated PR title check into run_commit_check() before other checks
main_test.py 8 new tests covering get_pr_title(), PR title flow in run_commit_check(), and initial_emitted parameter

Behavior matrix

message pr-title PR event? What happens
true false yes Validate each git commit (existing)
true true yes Validate PR title + each git commit
false true yes Validate PR title only + branch/author
true/false true no pr-title skipped (not in PR context)

Closes

Closes #93

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
@shenxianpeng shenxianpeng requested a review from a team as a code owner June 16, 2026 17:17
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@pre-commit-ci[bot], we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ad42a4ea-1729-4874-b8fc-0589b31e57b1

📥 Commits

Reviewing files that changed from the base of the PR and between eec6c29 and ce36a38.

📒 Files selected for processing (5)
  • .github/workflows/commit-check.yml
  • README.md
  • action.yml
  • main.py
  • main_test.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/pr-title-validation

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

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.
@shenxianpeng shenxianpeng changed the title feat: add pr-title input to validate pull request title feature: add pr-title input to validate pull request title Jun 16, 2026
shenxianpeng and others added 8 commits June 16, 2026 20:32
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.
@shenxianpeng shenxianpeng changed the title feature: add pr-title input to validate pull request title feat: add pr-title input to validate pull request title Jun 16, 2026
@shenxianpeng shenxianpeng added the enhancement New feature or request label Jun 16, 2026
@shenxianpeng shenxianpeng enabled auto-merge (squash) June 16, 2026 18:08
@shenxianpeng shenxianpeng disabled auto-merge June 16, 2026 18:08
@shenxianpeng shenxianpeng merged commit 60e903b into main Jun 16, 2026
8 of 9 checks passed
@shenxianpeng shenxianpeng deleted the feature/pr-title-validation branch June 16, 2026 18:08
@shenxianpeng shenxianpeng added the minor A minor version bump label Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request minor A minor version bump

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FR] Require committer name and email to match GitHub user

1 participant