Skip to content

Commit b290665

Browse files
committed
Add CodeRabbit configuration and GitHub Actions workflow
- Introduced .coderabbit.yaml for CodeRabbit integration, defining review settings, path filters, and instructions for various file types. - Created .github/workflows/coderabbit.yml to automate CodeRabbit reviews on pull requests and request reviews after CI completion. - Configured permissions and concurrency for the GitHub Actions workflow.
1 parent 5a11a2f commit b290665

2 files changed

Lines changed: 213 additions & 0 deletions

File tree

.coderabbit.yaml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
2+
#
3+
# CodeRabbit configuration for nowo-tech/anonymize-bundle.
4+
# Requires the CodeRabbit GitHub App installed on nowo-tech/AnonymizeBundle.
5+
# Manual review: comment `@coderabbitai review` on a pull request.
6+
7+
language: en-US
8+
9+
reviews:
10+
profile: chill
11+
request_changes_workflow: false
12+
high_level_summary: true
13+
review_status: true
14+
commit_status: true
15+
poem: false
16+
collapse_walkthrough: true
17+
sequence_diagrams: true
18+
changed_files_summary: true
19+
20+
auto_review:
21+
enabled: true
22+
auto_incremental_review: true
23+
auto_pause_after_reviewed_commits: 10
24+
drafts: false
25+
base_branches:
26+
- main
27+
- master
28+
ignore_title_keywords:
29+
- WIP
30+
- "[skip review]"
31+
32+
path_filters:
33+
- "!**/vendor/**"
34+
- "!**/coverage/**"
35+
- "!**/*.lock"
36+
- "!phpstan-baseline.neon"
37+
- "!.cursor/**"
38+
- "src/**"
39+
- "tests/**"
40+
- "docs/**"
41+
- "demo/**"
42+
- ".github/**"
43+
- "*.md"
44+
- "*.yaml"
45+
- "*.yml"
46+
- "Makefile"
47+
48+
path_instructions:
49+
- path: "src/**/*.php"
50+
instructions: |
51+
Symfony bundle (`nowo-tech/anonymize-bundle`). Dev/test only — never enable in production.
52+
Follow PSR-12 and `.php-cs-fixer.dist.php`. Prefer PHP 8 attributes over annotations.
53+
Respect PHP and Symfony ranges in `composer.json`. Preserve backward compatibility unless the PR explicitly breaks it.
54+
Use strict comparison (`===`) where appropriate. Keep changes minimal and consistent with existing patterns.
55+
Align with `composer cs-check`, `composer phpstan`, and `composer test`.
56+
57+
- path: "tests/**/*.php"
58+
instructions: |
59+
PHPUnit tests for the bundle. Add or update tests for new behaviour.
60+
Match existing test structure (Unit vs Integration). Avoid trivial assertions.
61+
Ensure changes remain compatible with CI matrix (PHP 8.1–8.5, Symfony 6.4/7.x/8.x).
62+
63+
- path: "docs/**/*.md"
64+
instructions: |
65+
User-facing documentation in English under `docs/`. Do not invent features, versions, or commands.
66+
For notable releases, keep CHANGELOG and UPGRADING aligned. Preserve document structure and tone.
67+
68+
- path: "demo/**/*.php"
69+
instructions: |
70+
Demo applications (Symfony 7 and 8). Illustrate bundle usage — not production code.
71+
Custom anonymizer services used via `anonymizeService` must be `public: true` in `config/services.yaml`.
72+
73+
- path: ".github/workflows/**"
74+
instructions: |
75+
GitHub Actions workflows for this Symfony bundle. Match existing workflow style (checkout@v6, matrix exclusions).
76+
Do not echo secrets. Pin third-party actions to major versions already used in this repo.
77+
78+
tools:
79+
phpstan:
80+
enabled: true
81+
phpcs:
82+
enabled: false
83+
phpmd:
84+
enabled: false
85+
yamllint:
86+
enabled: true
87+
hadolint:
88+
enabled: true
89+
gitleaks:
90+
enabled: true
91+
github-checks:
92+
enabled: true
93+
timeout_ms: 900000
94+
actionlint:
95+
enabled: true
96+
zizmor:
97+
enabled: true
98+
99+
knowledge_base:
100+
learnings:
101+
scope: auto
102+
pull_requests:
103+
scope: auto

.github/workflows/coderabbit.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# CodeRabbit integration for pull requests.
2+
#
3+
# Two complementary paths:
4+
# 1. GitHub App (recommended): install https://github.com/apps/coderabbitai on nowo-tech/AnonymizeBundle.
5+
# Uses .coderabbit.yaml and posts reviews automatically.
6+
# 2. CLI job (optional): set repository secret CODERABBIT_API_KEY (Agentic API key from CodeRabbit dashboard).
7+
#
8+
# After CI completes, request-review posts @coderabbitai review so the app can incorporate GitHub Checks results
9+
# (useful when the CI matrix exceeds the github-checks wait window in .coderabbit.yaml).
10+
11+
name: CodeRabbit
12+
13+
on:
14+
pull_request:
15+
branches: [main, master]
16+
types: [opened, synchronize, reopened]
17+
18+
workflow_run:
19+
workflows: [CI]
20+
types: [completed]
21+
22+
permissions:
23+
contents: read
24+
pull-requests: write
25+
26+
concurrency:
27+
group: coderabbit-${{ github.event.pull_request.number || github.event.workflow_run.id }}
28+
cancel-in-progress: true
29+
30+
jobs:
31+
cli-review:
32+
name: CodeRabbit CLI
33+
if: github.event_name == 'pull_request'
34+
runs-on: ubuntu-latest
35+
36+
steps:
37+
- name: Checkout PR head
38+
uses: actions/checkout@v6
39+
with:
40+
ref: ${{ github.event.pull_request.head.sha }}
41+
fetch-depth: 0
42+
43+
- name: Install CodeRabbit CLI
44+
run: curl -fsSL https://cli.coderabbit.ai/install.sh | sh
45+
46+
- name: Run CodeRabbit CLI review
47+
env:
48+
CODERABBIT_API_KEY: ${{ secrets.CODERABBIT_API_KEY }}
49+
run: |
50+
if [ -z "$CODERABBIT_API_KEY" ]; then
51+
echo "::warning::CODERABBIT_API_KEY is not set. Skipping CLI review."
52+
echo "Install the CodeRabbit GitHub App or add an Agentic API key secret to enable CLI reviews."
53+
exit 0
54+
fi
55+
56+
coderabbit auth login --api-key "$CODERABBIT_API_KEY"
57+
coderabbit review --plain --base "${{ github.event.pull_request.base.ref }}"
58+
59+
request-review-after-ci:
60+
name: Request CodeRabbit review after CI
61+
if: >
62+
github.event_name == 'workflow_run' &&
63+
github.event.workflow_run.conclusion == 'success' &&
64+
github.event.workflow_run.event == 'pull_request'
65+
runs-on: ubuntu-latest
66+
67+
steps:
68+
- name: Request CodeRabbit review on PR
69+
uses: actions/github-script@v7
70+
with:
71+
script: |
72+
const run = context.payload.workflow_run;
73+
const pulls = run.pull_requests ?? [];
74+
75+
if (pulls.length === 0) {
76+
core.info('No pull request linked to this CI workflow run.');
77+
return;
78+
}
79+
80+
const prNumber = pulls[0].number;
81+
const { owner, repo } = context.repo;
82+
83+
const comments = await github.paginate(github.rest.issues.listComments, {
84+
owner,
85+
repo,
86+
issue_number: prNumber,
87+
per_page: 100,
88+
});
89+
90+
const alreadyRequested = comments.some((comment) =>
91+
comment.body?.includes('@coderabbitai review') &&
92+
comment.user?.login === 'github-actions[bot]'
93+
);
94+
95+
if (alreadyRequested) {
96+
core.info(`CodeRabbit review already requested on PR #${prNumber}.`);
97+
return;
98+
}
99+
100+
await github.rest.issues.createComment({
101+
owner,
102+
repo,
103+
issue_number: prNumber,
104+
body: '@coderabbitai review',
105+
});
106+
107+
core.info(`Requested CodeRabbit review on PR #${prNumber} after CI success.`);
108+
109+
# Maintainer: Héctor Franco Aceituno (@HecFranco)
110+
# Organization: nowo-tech (https://github.com/nowo-tech)

0 commit comments

Comments
 (0)