Skip to content

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

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

ci: Add config file for CodeRabbit with custom rules#189
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

Add project-wide CodeRabbit configuration to enforce contribution conventions and tailored review guidance.

CI:

  • Configure CodeRabbit reviews with disabled nonessential features and automated checks for PR titles and descriptions.

Chores:

  • Define path-specific review instructions for Ansible tasks, handlers, tests, templates, variables, Python code, and documentation in .coderabbit.yaml.

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 requested a review from richm as a code owner May 19, 2026 08:40
@spetrosi spetrosi self-assigned this May 19, 2026
@sourcery-ai

sourcery-ai Bot commented May 19, 2026

Copy link
Copy Markdown

Reviewer's Guide

.coderabbit.yaml is introduced to configure CodeRabbit code review automation with project-specific review rules, PR conventions, and path-based guidance for Ansible roles, tests, templates, variables, Python code, and documentation, while disabling non-essential AI assistant features.

Sequence diagram for CodeRabbit review using .coderabbit.yaml

sequenceDiagram
    actor Developer
    participant GitHub
    participant CodeRabbit
    participant Repo

    Developer->>GitHub: Open_pull_request
    GitHub->>Repo: Load_coderabbit_yaml
    GitHub->>CodeRabbit: Trigger_review_with_config
    CodeRabbit->>Repo: Analyze_changes
    CodeRabbit->>CodeRabbit: Apply_pre_merge_checks
    CodeRabbit->>CodeRabbit: Apply_path_instructions
    CodeRabbit-->>GitHub: Post_review_comments
    GitHub-->>Developer: Display_CodeRabbit_review
Loading

File-Level Changes

Change Details Files
Introduce project-wide CodeRabbit configuration with conservative, non-intrusive review behavior.
  • Add .coderabbit.yaml with schema reference and repository management notice
  • Disable aesthetic and fun chat/review features (art, poems, fortunes)
  • Disable automatic behaviors like auto labels, auto reviewer assignment, and automatic request-changes workflow
  • Disable extra review flourishes such as sequence diagrams, effort estimation, suggested labels, and high-level walkthrough summaries
  • Disable unit-test-related finishing-touches automation
.coderabbit.yaml
Enforce pull request title and description conventions via pre-merge checks.
  • Configure a title pre-merge check that warns when PR titles do not follow Conventional Commits format
  • Add a custom description-format check that warns when PR descriptions do not follow the project’s PR template structure with Enhancement/Feature, Reason, Result, and optional Issue Tracker sections
.coderabbit.yaml
Provide path-based review instructions tailored to this Ansible role repository.
  • Define detailed guidance for tasks/ files covering no_log usage, OSTree-compatible package installation, idempotency, check mode support, test coverage expectations, and avoiding third-party collections
  • Add handler-specific guidance enforcing parametrized no_log for sensitive handlers
  • Specify required invocation patterns and quality expectations for tests/tests_.yml playbooks
  • Enforce template headers and role fingerprinting for templates/**/.j2
  • Define naming and documentation rules for defaults/ (postgresql_-prefixed user-facing vars) and vars/ (_postgresql-prefixed internal vars) directories
  • Specify Python file expectations (PEP 8, Black formatting, tox -e black,flake8) and README.md documentation requirements for new user-facing variables
.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

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:

  • Several instructions (e.g., postgresql_secure_logging, __postgresql_is_ostree, system_role:postgresql, and postgresql_ variable prefixes) are very role-specific while the header describes this as a generic linux-system-roles config; consider either generalizing these names or clearly scoping this config to the postgresql role to avoid confusing reviewers on other roles.
  • The note in defaults/**/*.yml that “Ansible doesn't include variables from other files” is misleading, since Ansible does load multiple files under defaults/; it would be clearer to explain that this project’s convention is to keep all user-facing defaults in defaults/main.yml rather than implying Ansible cannot use other defaults files.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Several instructions (e.g., `postgresql_secure_logging`, `__postgresql_is_ostree`, `system_role:postgresql`, and `postgresql_` variable prefixes) are very role-specific while the header describes this as a generic linux-system-roles config; consider either generalizing these names or clearly scoping this config to the postgresql role to avoid confusing reviewers on other roles.
- The note in `defaults/**/*.yml` that “Ansible doesn't include variables from other files” is misleading, since Ansible does load multiple files under `defaults/`; it would be clearer to explain that this project’s convention is to keep all user-facing defaults in `defaults/main.yml` rather than implying Ansible cannot use other defaults files.

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 b36751a into main May 19, 2026
32 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