Skip to content

feat: use commit-check-action to check PR title#90

Merged
shenxianpeng merged 11 commits into
mainfrom
feature/use-commit-check-action
Jul 8, 2026
Merged

feat: use commit-check-action to check PR title#90
shenxianpeng merged 11 commits into
mainfrom
feature/use-commit-check-action

Conversation

@shenxianpeng

@shenxianpeng shenxianpeng commented Jun 22, 2026

Copy link
Copy Markdown
Member

I've been maintaining commit-check for about 4 years now. It's mature enough to use the commit-check-action in their CI.

This PR eats my own dog food :)

What changed

Before: The check-pr-title job in pre-commit.yml installed a full Rust toolchain (rustup, cargo-binstall, committed) just to validate one PR title.

After: Uses commit-check-action with pr-title: true. The action discovers .github/commit-check.toml automatically — no extra setup needed.

Also added commit-check.toml to mirror the rules we had in committed.toml.

Diff

  • Rust toolchain setup gone (removed ~15 lines)
  • Two checkouts → one checkout (action auto-discovers config from .github/)
  • cspell spell check kept as a separate step
  • +27 -30 net

Not in this PR

  • The old .github/committed.toml is kept for now (can clean up later)
  • Other repos in the org that call this workflow may need their own commit-check.toml or use inherit_from — that's a follow-up

Summary by CodeRabbit

  • Chores
    • Updated pull request validation to use a new conventional-commit checker for PR titles.
    • Added clearer commit title rules, including allowed types and length/format requirements.
    • Improved spellcheck configuration fallback so checks still work when a project-specific config is unavailable.

Replace the committed-based PR title check with our own
commit-check-action to eat our own dogfood.

- Remove Rust toolchain installation (rustup, cargo-binstall, committed)
- Add commit-check.toml config mirroring the existing committed.toml rules
- Simplify to a single checkout (action auto-discovers config in .github/)
- Keep cspell spell check as a separate step
Comment thread .github/workflows/pre-commit.yml Outdated
@shenxianpeng

shenxianpeng commented Jun 22, 2026

Copy link
Copy Markdown
Member Author

This PR is not ready and still needs to think about how to make it work as expected.

I will come back when I have time.

@2bndy5

2bndy5 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Before: The check-pr-title job in pre-commit.yml installed a full Rust toolchain (rustup, cargo-binstall, committed)

We could have also just used pipx run committed ...; this was an oversight on my part.


My only main concern is adhering to conventional commits standards. This is because generating a changelog or release notes (via git-clff in cpp-linter-rs project) requires using a conventional commit title.

So, if

[commit]
# https://www.conventionalcommits.org
conventional_commits = true

means it enforces type(scope): title (where (scope) is optional), then I'm ok with this.

Resolve merge conflicts in pre-commit.yml:
- Accept PR's approach: single checkout + commit-check-action instead of dual checkout + rustup/committed
- Update actions/checkout to v7.0.0 (from main)
- Remove rustup setup and committed installation steps (per PR intent)
- Remove dual-repo cspell config fallback (per PR intent)
@shenxianpeng

Copy link
Copy Markdown
Member Author

So, if

[commit]
# https://www.conventionalcommits.org
conventional_commits = true

means it enforces type(scope): title (where (scope) is optional), then I'm ok with this.

Sure. commit-check follows the https://www.conventionalcommits.org, so the above cases are fully covered.

When a consuming repo doesn't have its own cspell.config.yml,
download the org-level config from the .github repo as a fallback.
Uses curl to fetch the file from the raw GitHub URL.
Instead of hardcoding 'main', use gh api to get the default branch
of the action repository, falling back to 'main' on failure.
The spell check change is out of scope for this PR (which focuses
on replacing committed with commit-check-action). Reverting back
to the original approach from the PR author.
- Checkout .github repo to root (no path) so commit-check-action
  discovers .github/commit-check.toml automatically
- Keep checkout of calling repo in project-repo/ for cspell
- Remove second .github checkout to org-repo/ (replaced by root checkout)
- Remove rustup/committed steps, add commit-check-action
- Spell check if-else fallback preserved unchanged from main
  (path changes from org-repo/ to root since .github is now at root)
Comment thread .github/workflows/pre-commit.yml
Comment thread .github/workflows/pre-commit.yml
Co-authored-by: Xianpeng Shen <xianpeng.shen@gmail.com>
@shenxianpeng shenxianpeng marked this pull request as ready for review July 8, 2026 22:31
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

This PR adds a .github/commit-check.toml configuration enabling conventional commit enforcement with subject formatting, length, and allowed-type rules. The pre-commit workflow's check-pr-title job is updated to use commit-check-action for PR title validation, replacing the previous committed tool installation, and adjusts the cspell fallback config path.

Changes

PR title validation migration

Layer / File(s) Summary
Commit-check configuration
.github/commit-check.toml
New config enables conventional commit checks with subject rules, length constraints, and an allowlist of commit types.
Workflow migration to commit-check-action
.github/workflows/pre-commit.yml
Adds a root checkout step for config discovery, replaces the rustup/cargo-binstall/committed toolchain with commit-check/commit-check-action@v2.9.0 scoped to pr-title checks, and updates the cspell fallback config path from org-repo/cspell.config.yml to cspell.config.yml.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • cpp-linter/.github#51: Both PRs modify the check-pr-title job's PR title handling logic in the same workflow file.
  • cpp-linter/.github#53: Both PRs change how the PR title is propagated into commit-title and spellcheck steps within check-pr-title.
  • cpp-linter/.github#83: Both PRs modify the cspell configuration fallback selection logic in the same workflow job.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: switching PR title validation to commit-check-action.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

SPELL_CONFIG -> CSPELL_CONFIG to match the variable
referenced in the npx cspell-cli command
- Remove path from .github checkout so .github/commit-check.toml
  lands at workspace root for auto-discovery by the action
- cspell fallback path adjusts accordingly: root instead of org-repo/
- Spell check if-else logic preserved unchanged from main
@shenxianpeng shenxianpeng requested a review from 2bndy5 July 8, 2026 22:43
@shenxianpeng shenxianpeng added the enhancement New feature or request label Jul 8, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/commit-check.toml:
- Around line 1-21: The commit subject length setting in the commit-check config
is now capped, which changes the previous unlimited behavior. Update the commit
validation config in the [commit] section by adjusting subject_max_length in
commit-check.toml so it preserves the intended unlimited length (use 0 or remove
the cap), and keep the conventional_commits-related settings consistent with the
existing validation rules.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0fd7c93c-25fc-4933-b2c3-939ed39a1d74

📥 Commits

Reviewing files that changed from the base of the PR and between 5943c47 and d225ee5.

📒 Files selected for processing (2)
  • .github/commit-check.toml
  • .github/workflows/pre-commit.yml

Comment thread .github/commit-check.toml
Comment on lines +1 to +21
[commit]
conventional_commits = true
subject_capitalized = false
subject_imperative = false
subject_max_length = 200
subject_min_length = 1
allow_commit_types = [
"fix",
"feat",
"build",
"chore",
"docs",
"style",
"refactor",
"remove",
"deprecate",
"security",
"add",
"perf",
"test",
]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Search for commit-check-action documentation or config schema references in the repo.
# Also check if the old committed.toml is still present (PR says it remains for now).

# Check for any documentation about commit-check config
rg -i "commit-check" --type yaml --type markdown -n -C3 || true

# Verify the old committed.toml still exists
fd "committed.toml" .github/

# Check if any other files reference commit-check.toml or its keys
rg -i "allow_commit_types\|conventional_commits\|subject_max_length\|subject_min_length\|subject_imperative" -n -C2 || true

Repository: cpp-linter/.github

Length of output: 432


🌐 Web query:

What is the config schema for commit-check-action v2.9.0 commit-check.toml? What are the valid config keys under the [commit] section?

💡 Result:

The commit-check-action v2.9.0 uses a TOML-based configuration file (typically named commit-check.toml or cchk.toml) to define validation rules [1][2]. The configuration is managed by the underlying commit-check engine [3][4]. Valid configuration keys under the [commit] section include: conventional_commits (bool): Enables or disables validation against the Conventional Commits specification [5][6]. message_pattern (str, optional): A custom regex pattern to validate commit messages, which overrides the conventional_commits rule [6]. subject_capitalized (bool): Enforces that the commit subject starts with a capital letter [5][6]. subject_imperative (bool): Enforces that the commit subject uses the imperative mood [5][6]. subject_max_length (int, optional): Sets the maximum allowed length for the commit subject [5][6]. subject_min_length (int, optional): Sets the minimum required length for the commit subject [5][6]. allow_commit_types (list[str]): A list of allowed commit types (e.g., feat, fix, chore) [5][6]. allow_merge_commits (bool): Whether merge commits are permitted [5][6]. allow_revert_commits (bool): Whether revert commits are permitted [5][6]. allow_empty_commits (bool): Whether empty commits are permitted [5][6]. allow_fixup_commits (bool): Whether fixup! commits are permitted [5][6]. allow_wip_commits (bool): Whether work-in-progress (e.g., WIP:) commits are permitted [5][6]. require_body (bool): Whether a body is required in the commit message [5][6]. require_signed_off_by (bool): Whether a "Signed-off-by" footer is required [5][6]. required_signoff_name (str, optional): A specific name required in the sign-off footer [6]. required_signoff_email (str, optional): A specific email required in the sign-off footer [6]. ignore_authors (list[str]): A list of author or co-author names to bypass commit checks (e.g., bots like dependabot[bot]) [5][7][6]. ai_attribution (str): Configures how AI-generated commit trailers are handled (e.g., ignore or forbid) [6]. Additionally, the configuration supports an inherit_from key at the root level to allow sharing and extending base configurations from other files, URLs, or GitHub repositories [1][2]. Users can also configure branch-specific rules under a separate [branch] section [5][6]. For IDE support, the schema is published on SchemaStore, allowing for automated validation and autocompletion in compatible editors [1].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== tracked commit-check files ==\n'
git ls-files '.github/*commit*' '.github/*cchk*' '.github/*toml' | sort

printf '\n== commit-check.toml ==\n'
if [ -f .github/commit-check.toml ]; then
  cat -n .github/commit-check.toml
fi

printf '\n== committed.toml ==\n'
if [ -f .github/committed.toml ]; then
  cat -n .github/committed.toml
fi

printf '\n== references ==\n'
rg -n "commit-check|committed\.toml|allow_commit_types|subject_max_length|subject_length|conventional_commits|subject_min_length|subject_imperative" .github -S || true

Repository: cpp-linter/.github

Length of output: 2006


Keep the subject length unlimited if that’s the intent
subject_max_length = 200 changes the previous unlimited subject_length = 0 behavior and will start rejecting longer subjects; use 0 or omit the cap if that restriction isn’t intended.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/commit-check.toml around lines 1 - 21, The commit subject length
setting in the commit-check config is now capped, which changes the previous
unlimited behavior. Update the commit validation config in the [commit] section
by adjusting subject_max_length in commit-check.toml so it preserves the
intended unlimited length (use 0 or remove the cap), and keep the
conventional_commits-related settings consistent with the existing validation
rules.

@shenxianpeng

Copy link
Copy Markdown
Member Author

✌️ hopefully it will work

@shenxianpeng shenxianpeng merged commit fac89f0 into main Jul 8, 2026
6 checks passed
@shenxianpeng shenxianpeng deleted the feature/use-commit-check-action branch July 8, 2026 22:53
@2bndy5

2bndy5 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Well, it works!

I noticed commit-check does not seem to check that the first word of the conventional commit title is an imperative verb. Committed did check for this, but there was some edge cases... Certain English words can be a noun or a verb (eg "lock", "default"). Committed often flagged titles that start with "default" as not starting with an imperative verb.

I think this is fine for our case. Not enforcing strict rules of English allows for more flexibility.

@shenxianpeng

Copy link
Copy Markdown
Member Author

Nice!

commit check also supports checking imperative verbs. it can enable from

subject_imperative = false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants