Skip to content

ci: Add config file for CodeRabbit with custom rules#291

Merged
spetrosi merged 1 commit into
mainfrom
coderabbit-init
May 19, 2026
Merged

ci: Add config file for CodeRabbit with custom rules#291
spetrosi merged 1 commit into
mainfrom
coderabbit-init

Conversation

@spetrosi

@spetrosi spetrosi commented May 19, 2026

Copy link
Copy Markdown
Contributor

Sourcery that we currently use cannot read documentation files and best
practices, it's rather a refactoring tool.
So I want to introduce CodeRabbit that allows creating .coderabbit.yaml with
custom rules and conventions.

Signed-off-by: Sergei Petrosian spetrosi@redhat.com

Summary by Sourcery

Introduce a CodeRabbit configuration file to standardize automated review behavior and enforce repository-specific contribution conventions.

CI:

  • Configure CodeRabbit reviews, disabling nonessential features and auto-actions while enabling pre-merge checks for PR titles and descriptions.

Documentation:

  • Embed guidance for PR formatting and role-specific coding/documentation standards within the CodeRabbit configuration to align reviews with existing contribution guidelines.

Chores:

  • Add path-specific CodeRabbit review instructions for tasks, handlers, tests, templates, variable files, Python code, and README to ensure consistency with linux-system-roles practices.

Sourcery that we currently use cannot read documentation files and best
practices, it's rather a refactoring tool.
So I want to introduce CodeRabbit that allows creating .coderabbit.yaml with
custom rules and conventions.

Signed-off-by: Sergei Petrosian <spetrosi@redhat.com>
@spetrosi spetrosi self-assigned this May 19, 2026
@sourcery-ai

sourcery-ai Bot commented May 19, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Adds a CodeRabbit configuration file (.coderabbit.yaml) tailored for this repository, disabling nonessential AI review features, enforcing PR title/description conventions, and defining path-specific review instructions for Ansible tasks, handlers, tests, templates, variables, Python, and documentation in line with linux-system-roles best practices.

Flow diagram for CodeRabbit review using .coderabbit.yaml

flowchart TD
    A[PR opened/updated] --> B[CodeRabbit triggered]
    B --> C[Load .coderabbit.yaml]
    C --> D[Apply global review settings
- fun features disabled
- auto features disabled]
    C --> E[Run pre_merge_checks
- title format
- description template]
    C --> F[Evaluate changed files
by path]

    F --> G[tasks/**/*.yml
Check no_log, package, tests]
    F --> H[handlers/**/*.yml
Check no_log usage]
    F --> I[tests/tests_*.yml
Check role invocation
and test quality]
    F --> J[templates/**/*.j2
Check required headers]
    F --> K[defaults/**/*.yml
Check kdump_ vars
documented]
    F --> L[vars/**/*.yml
Check __kdump_ vars]
    F --> M[**/*.py
Check PEP8/Black]
    F --> N[README.md
Check new vars documented]

    D --> O[Review report with warnings]
    E --> O
    G --> O
    H --> O
    I --> O
    J --> O
    K --> O
    L --> O
    M --> O
    N --> O
    O --> P[Posted as CodeRabbit review
comments on PR]
Loading

File-Level Changes

Change Details Files
Introduce repository-wide CodeRabbit configuration with disabled cosmetic features and basic chat settings.
  • Add .coderabbit.yaml at the repo root to configure CodeRabbit behavior.
  • Disable art, poems, fortunes, sequence diagrams, effort estimation, suggested labels, and other nonessential or novelty review features.
  • Turn off auto behaviors such as auto-applying labels, auto-assigning reviewers, and request-changes workflow handling.
  • Disable CodeRabbit finishing-touches unit-test suggestions.
.coderabbit.yaml
Enforce standardized PR title and description formats through CodeRabbit pre-merge checks.
  • Configure a title pre_merge_check that warns when PR titles do not follow Conventional Commits formatting, with examples and reference to .commitlintrc.js type-enum.
  • Add a custom description-format check that warns when PR descriptions do not follow the documented Enhancement/Feature, Reason, Result, and optional Issue Tracker sections from the PR template.
.coderabbit.yaml
Define path-specific review guidelines for Ansible tasks, handlers, tests, templates, variable files, Python code, and README documentation.
  • Add detailed instructions for tasks//.yml on no_log usage, OSTree-compatible package installation patterns, avoiding third-party collections, idempotency, check-mode support, and mandatory test coverage for new tasks.
  • Specify handler guidance requiring parametrized no_log with kdump_secure_logging for sensitive data.
  • Define strict patterns for tests/tests_.yml to invoke roles only via the run_role_with_clear_facts wrapper, ensure idempotent and assert-based testing of success/failure scenarios, and cleanup expectations.
  • Require specific header structure in templates//.j2 including ansible_managed and a system_role:kdump fingerprint.
  • Set naming and location conventions for defaults/**/.yml and vars/**/*.yml (kdump_ for user-facing vars in defaults/main.yml, _kdump for internal vars in vars/).
  • Add instructions for all Python files to conform to PEP 8 and be formatted with Black, with tox -e black,flake8 as the local check.
  • Require README.md updates documenting any new user-facing variables and new functionality usage examples.
.coderabbit.yaml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai 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.

Hey - I've left some high level feedback:

  • The path instructions are very kdump-specific (e.g., kdump_secure_logging, __kdump_is_ostree, system_role:kdump), which may not generalize well to other linux-system-roles if this config is meant to be reused globally; consider parameterizing or templating these role-specific names.
  • The tasks section instructs reviewers to enforce test coverage, while finishing_touches.unit_tests.enabled is disabled; if the intent is to avoid automated test-related suggestions, consider aligning these settings or clarifying which mechanism should actually enforce test expectations.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The path instructions are very kdump-specific (e.g., `kdump_secure_logging`, `__kdump_is_ostree`, `system_role:kdump`), which may not generalize well to other linux-system-roles if this config is meant to be reused globally; consider parameterizing or templating these role-specific names.
- The tasks section instructs reviewers to enforce test coverage, while `finishing_touches.unit_tests.enabled` is disabled; if the intent is to avoid automated test-related suggestions, consider aligning these settings or clarifying which mechanism should actually enforce test expectations.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@spetrosi spetrosi merged commit 96ae8b8 into main May 19, 2026
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant