Skip to content

test: cover default signoff regex for bot and regular names - #463

Merged
shenxianpeng merged 2 commits into
mainfrom
test/signoff-default-regex-coverage
Jul 9, 2026
Merged

test: cover default signoff regex for bot and regular names#463
shenxianpeng merged 2 commits into
mainfrom
test/signoff-default-regex-coverage

Conversation

@shenxianpeng

@shenxianpeng shenxianpeng commented Jul 9, 2026

Copy link
Copy Markdown
Member

The existing SignoffValidator tests pass an inline regex, so the default pattern in rules_catalog was never exercised. Build the rule via RuleBuilder and assert the shipped default:

  • accepts a bracketed bot name (Signed-off-by: dependabot[bot] <...>)
  • accepts a regular Name signoff
  • rejects a message with no signoff trailer

related to #462

Summary by CodeRabbit

  • Tests
    • Expanded automated coverage for signoff validation.
    • Added checks that signed-off commits are accepted for both bot-generated and standard author formats.
    • Added a case confirming commits without a signoff trailer are correctly rejected.

The existing SignoffValidator tests pass an inline regex, so the default
pattern in rules_catalog was never exercised. Build the rule via
RuleBuilder and assert the shipped default:

- accepts a bracketed bot name (Signed-off-by: dependabot[bot] <...>)
- accepts a regular Name <email> signoff
- rejects a message with no signoff trailer
@shenxianpeng
shenxianpeng requested a review from a team as a code owner July 9, 2026 06:45
@netlify

netlify Bot commented Jul 9, 2026

Copy link
Copy Markdown

Deploy Preview for commit-check ready!

Name Link
🔨 Latest commit 14401cd
🔍 Latest deploy log https://app.netlify.com/projects/commit-check/deploys/6a4f4396060e1d0007d2e61f
😎 Deploy Preview https://deploy-preview-463--commit-check.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@shenxianpeng shenxianpeng added the tests Add test related changes label Jul 9, 2026
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Test module tests/engine_test.py was updated to import RuleBuilder and add a _default_signoff_rule() static helper in TestSignoffValidator. Three new benchmarked tests were added covering acceptance of bot-style and standard signoffs, and rejection of commits missing the signoff trailer.

Changes

Signoff Validator Default Rule Tests

Layer / File(s) Summary
Default signoff rule helper and tests
tests/engine_test.py
Imports RuleBuilder, adds _default_signoff_rule() helper to build the catalog default require_signed_off_by rule, and adds tests validating acceptance of bot and standard signoffs, plus rejection when signoff trailer is missing.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested labels: minor

🚥 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: tests covering the default signoff regex for bot and regular signoffs.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/signoff-default-regex-coverage

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.

@sonarqubecloud

sonarqubecloud Bot commented Jul 9, 2026

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/engine_test.py (1)

651-662: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use an assertion-friendly fallback for next()

next(r for r in rules if r.check == "require_signed_off_by") can fail with a bare StopIteration, which makes this test harder to diagnose. Use a default plus an assert so the failure message is explicit.

🤖 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 `@tests/engine_test.py` around lines 651 - 662, The helper
_default_signoff_rule currently uses next() to find the require_signed_off_by
rule, which can raise a bare StopIteration and make the test failure unclear.
Update this logic to use an assertion-friendly fallback in the generator lookup,
then assert the result is not None before returning it, so failures in
RuleBuilder.build_all_rules() are explicit and easier to diagnose.
🤖 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.

Nitpick comments:
In `@tests/engine_test.py`:
- Around line 651-662: The helper _default_signoff_rule currently uses next() to
find the require_signed_off_by rule, which can raise a bare StopIteration and
make the test failure unclear. Update this logic to use an assertion-friendly
fallback in the generator lookup, then assert the result is not None before
returning it, so failures in RuleBuilder.build_all_rules() are explicit and
easier to diagnose.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 66633e73-9fea-4672-a942-241203c018d4

📥 Commits

Reviewing files that changed from the base of the PR and between 092a824 and 14401cd.

📒 Files selected for processing (1)
  • tests/engine_test.py

@shenxianpeng
shenxianpeng merged commit df32a83 into main Jul 9, 2026
14 of 15 checks passed
@shenxianpeng
shenxianpeng deleted the test/signoff-default-regex-coverage branch July 9, 2026 06:49
@codspeed-hq

codspeed-hq Bot commented Jul 9, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 36.22%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 357 untouched benchmarks
🆕 3 new benchmarks
⏩ 109 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
test_empty_message_passes 1,016.5 µs 746.2 µs +36.22%
🆕 test_default_signoff_accepts_bot_name N/A 255.8 µs N/A
🆕 test_default_signoff_accepts_regular_name N/A 255.4 µs N/A
🆕 test_default_signoff_rejects_missing_signoff N/A 924.3 µs N/A

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing test/signoff-default-regex-coverage (823c06c) with main (092a824)

Open in CodSpeed

Footnotes

  1. 109 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

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

Labels

tests Add test related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant