Skip to content

Commit 29a7843

Browse files
Merge pull request #29 from codota/DEV3-4782/generalize-action-inputs
DEV3-4782: Generalize GitHub Action to support custom prompts and comment prefixes
2 parents 1f086a7 + 593c518 commit 29a7843

5 files changed

Lines changed: 194 additions & 130 deletions

File tree

Bitbucket/bitbucket-pipelines.yml

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# TABNINE_HOST - Tabnine host URL (default: https://console.tabnine.com)
1212
# TABNINE_MODEL_ID - Model ID for the Tabnine CLI agent. If empty, falls back to DEFAULT_MODEL_ID below or the system default from the admin console.
1313
# TABNINE_CLEANUP - Set to "true" to delete settings.json after each run (default: "false"). Recommended for self-hosted runners.
14+
# TABNINE_COMMENT_PREFIX - Prefix used to identify bot comments for cleanup (default: '#### Tabnine PR Bot').
1415

1516
image: node:20
1617

@@ -30,6 +31,7 @@ pipelines:
3031
- export BB_PR_ID="${BITBUCKET_PR_ID}"
3132
- export BB_COMMIT="${BITBUCKET_COMMIT}"
3233
- export BB_PR_DEST_BRANCH="${BITBUCKET_PR_DESTINATION_BRANCH}"
34+
- export COMMENT_PREFIX="${TABNINE_COMMENT_PREFIX:-#### Tabnine PR Bot}"
3335

3436
# Input validation
3537
- |
@@ -90,8 +92,8 @@ pipelines:
9092
9193
# Clean up previous bot summary comments
9294
- |
93-
echo "Cleaning up previous Tabnine PR Bot comments..."
94-
COMMENTS=$(curl -s --header "Authorization: Bearer $BB_API_TOKEN" "$BB_API_BASE/repositories/$BB_WORKSPACE/$BB_REPO_SLUG/pullrequests/$BB_PR_ID/comments?pagelen=100" | jq -r '.values[] | select(.content.raw | startswith("#### Tabnine PR Bot")) | .id')
95+
echo "Cleaning up previous bot comments (prefix: $COMMENT_PREFIX)..."
96+
COMMENTS=$(curl -s --header "Authorization: Bearer $BB_API_TOKEN" "$BB_API_BASE/repositories/$BB_WORKSPACE/$BB_REPO_SLUG/pullrequests/$BB_PR_ID/comments?pagelen=100" | jq -r ".values[] | select(.content.raw | startswith(\"$COMMENT_PREFIX\")) | .id")
9597
9698
for COMMENT_ID in $COMMENTS; do
9799
echo "Deleting bot comment: $COMMENT_ID"
@@ -139,28 +141,22 @@ pipelines:
139141
Based on Phase A, classify this PR into a risk tier:
140142
141143
**Tier 1 - Low Risk** (docs, config, tests, typo fixes, dependency bumps with no code changes):
142-
- Skip Phase C2 (cross-repo analysis) and Phase C3 (infra review) entirely.
143-
- Post only the summary comment (Phase E) with a brief confirmation.
144+
- Skip Phase B2 (cross-repo analysis) and Phase B3 (infra review) entirely.
145+
- Post only the summary comment (Phase D) with a brief confirmation.
144146
- Maximum inline comments: 1 (only for genuine bugs).
145147
146148
**Tier 2 - Standard** (feature work, refactors, most bug fixes):
147-
- Run full Phase C audit.
148-
- Run Phase C2 only if the diff touches public APIs, shared libraries, or interface definitions.
149+
- Run full Phase B audit.
150+
- Run Phase B2 only if the diff touches public APIs, shared libraries, or interface definitions.
149151
- Maximum inline comments: 5.
150152
151153
**Tier 3 - High Risk** (security changes, auth/authz, data migrations, public API changes, infrastructure/deployment changes, shared library changes):
152-
- Run all phases including full Phase C2 and Phase C3.
154+
- Run all phases including full Phase B2 and Phase B3.
153155
- Maximum inline comments: 8.
154156
155157
Determine the tier before proceeding. State the tier in your summary.
156158
157-
### Phase B: Clean Up Previous Inline Comments
158-
Before posting new inline comments, delete all previous Tabnine PR Bot inline review comments:
159-
1. List all PR comments: curl -s --header 'Authorization: Bearer \$BB_API_TOKEN' '$BB_API_BASE/repositories/$BB_WORKSPACE/$BB_REPO_SLUG/pullrequests/$BB_PR_ID/comments?pagelen=100'
160-
2. For each comment whose content.raw starts with '#### Tabnine PR Bot' and has an 'inline' property (indicating it's an inline comment), delete it using: curl -s --header 'Authorization: Bearer \$BB_API_TOKEN' --request DELETE '$BB_API_BASE/repositories/$BB_WORKSPACE/$BB_REPO_SLUG/pullrequests/$BB_PR_ID/comments/COMMENT_ID'
161-
Note: Summary comments are cleaned up automatically before this review runs, so you only need to handle inline comments here.
162-
163-
### Phase C: Engineering Audit
159+
### Phase B: Engineering Audit
164160
Evaluate the code against these pillars IN PRIORITY ORDER. Spend the most effort on the highest-priority categories.
165161
166162
**P0 - Correctness & Logic** (most critical):
@@ -224,7 +220,7 @@ pipelines:
224220
- Are names self-explanatory? Are complex algorithms or non-obvious business rules documented?
225221
- Does the code follow existing project conventions?
226222
227-
### Phase C2: Cross-Repository Impact Analysis (Skip for Tier 1)
223+
### Phase B2: Cross-Repository Impact Analysis (Skip for Tier 1)
228224
Use the Tabnine MCP context engine tools to analyze cross-repository impact of this PR:
229225
1. **List repositories**: Call 'remote_repositories_list' to discover the organization's repository ecosystem.
230226
2. **Find related services**: Call 'remote_search_assets' with queries derived from the changed files to find SERVICE_SUMMARY and OPENAPI_SPEC assets related to the code being modified.
@@ -242,22 +238,22 @@ pipelines:
242238
- Services or repositories as nodes
243239
- Call or dependency relationships as directed edges
244240
- Use this diagram to reason about blast radius, layering violations, or unintended coupling.
245-
8. **Compile findings** for inclusion in the Phase E summary comment:
241+
8. **Compile findings** for inclusion in the Phase D summary comment:
246242
- Architecture violations or new inter-service dependencies introduced by this PR
247243
- Other repositories or services that consume the changed code (with file and line references where possible)
248244
- High-level architecture insight derived from SERVICE_SUMMARY / OPENAPI_SPEC assets
249245
- ASCII architecture diagram (only if it adds clarity; omit if trivial)
250246
- If no cross-repo impact is found, state 'No cross-repository impact detected'
251247
252-
### Phase C3: Infrastructure & Configuration Review (Tier 3 only, skip if no infra files in diff)
248+
### Phase B3: Infrastructure & Configuration Review (Tier 3 only, skip if no infra files in diff)
253249
If the PR modifies infrastructure or configuration files, apply these checks:
254250
**Dockerfiles**: Are base images pinned (not 'latest')? Running as non-root? Secrets not in build args?
255251
**CI/CD Pipelines**: Are dependencies version-pinned? Could this break the pipeline for other branches? Secrets via secure stores?
256252
**Kubernetes/Helm**: Resource requests/limits defined? Liveness/readiness probes configured? Rolling update safe?
257253
**Terraform/IaC**: Any resource destruction? Blast radius limited? New resources tagged consistently?
258254
**Config/Env Vars**: New vars have safe defaults? Sensitive values from secret managers? App fails fast if required config missing?
259255
260-
### Phase C4: Coaching Guidelines Compliance
256+
### Phase B4: Coaching Guidelines Compliance
261257
Use the Tabnine MCP 'get_guidelines' tool to retrieve the organization's coaching guidelines and validate the changed code against them:
262258
1. **Identify languages**: Determine which programming languages are present in the diff (e.g., python, javascript, typescript, java, php, go, cpp, csharp, kotlin).
263259
2. **Fetch guidelines**: Call 'get_guidelines' with the 'language' parameter for each language detected in the diff to retrieve applicable coaching guidelines. If changed files span multiple languages, call it once per language.
@@ -266,7 +262,7 @@ pipelines:
266262
- Post an inline comment referencing the guideline ID and description. Coaching guideline violations are exempt from the tier comment budget -- every violation must be reported.
267263
- Use the guideline's severity to map to the inline comment severity: Critical -> [Critical], Error -> [Warning], Warning -> [Suggestion], Info -> [Suggestion].
268264
- Include the guideline's recommended fix or best practice in the 'Suggested fix' section of the comment.
269-
5. **Include in summary**: Add a 'Coaching Guidelines' section to the Phase E summary if any violations were found. List violated guideline IDs grouped by severity. If no violations were found, state 'All changed code complies with coaching guidelines.'
265+
5. **Include in summary**: Add a 'Coaching Guidelines' section to the Phase D summary if any violations were found. List violated guideline IDs grouped by severity. If no violations were found, state 'All changed code complies with coaching guidelines.'
270266
271267
## 4. Comment Value Threshold (CRITICAL FILTER)
272268
@@ -281,7 +277,7 @@ pipelines:
281277
- Introduces a deployment risk (non-backward-compatible migration, missing feature flag for risky change)
282278
- Changes CI/CD configuration in a way that could break the build for other contributors
283279
- Violates critical project patterns (e.g., error handling, path handling)
284-
- Violates any organization coaching guideline, regardless of severity (from Phase C4)
280+
- Violates any organization coaching guideline, regardless of severity (from Phase B4)
285281
- Makes the code significantly harder to maintain or debug
286282
287283
**DO NOT comment on:**
@@ -304,9 +300,9 @@ pipelines:
304300
305301
**Golden Rule**: If removing your comment would NOT increase the risk of bugs, security issues, or maintenance problems, DO NOT POST IT.
306302
307-
### Phase D: Inline Comments
303+
### Phase C: Inline Comments
308304
309-
For each potential issue from Phase C:
305+
For each potential issue from Phase B:
310306
1. Apply the Comment Value Threshold filter above
311307
2. Enforce the tier comment budget (Tier 1: max 1, Tier 2: max 5, Tier 3: max 8). If you have more findings than the budget, keep only the highest-severity ones.
312308
3. Verify the file exists in the diff and the line number is within changed lines
@@ -323,24 +319,28 @@ pipelines:
323319
- **[Warning]** -- Logic issues, edge cases, performance concerns. Strongly recommended to fix.
324320
- **[Suggestion]** -- Improvements to maintainability or clarity. Author's discretion.
325321
322+
**FILE-LEVEL vs LINE-LEVEL comments**: If a comment applies to the entire file rather than specific lines (e.g., a deleted file, a file that should not exist, or a concern about the file as a whole), post a FILE-LEVEL comment using 'inline.path' without 'from'/'to' instead of a comment spanning all lines. Never post a comment that covers all or most lines of a file -- this creates an excessively large comment. Use file-level comments for file-wide feedback.
323+
326324
Submit inline comments using the Bitbucket PR Comments API:
327-
**IMPORTANT**: All comments MUST start with '#### Tabnine PR Bot' on the first line, followed by a blank line, then your formatted comment content.
325+
**IMPORTANT**: All comments MUST start with '$COMMENT_PREFIX' on the first line, followed by a blank line, then your formatted comment content.
326+
For FILE-LEVEL comments (when the comment applies to the entire file, not specific lines):
327+
curl -s --header 'Authorization: Bearer \$BB_API_TOKEN' --request POST --header 'Content-Type: application/json' --data '{"content": {"raw": "$COMMENT_PREFIX\n\nYOUR_COMMENT"}, "inline": {"path": "FILE_PATH"}}' '$BB_API_BASE/repositories/$BB_WORKSPACE/$BB_REPO_SLUG/pullrequests/$BB_PR_ID/comments'
328328
For inline comments on specific lines:
329-
curl -s --header 'Authorization: Bearer \$BB_API_TOKEN' --request POST --header 'Content-Type: application/json' --data '{"content": {"raw": "#### Tabnine PR Bot\n\nYOUR_COMMENT"}, "inline": {"path": "FILE_PATH", "to": LINE_NUMBER}}' '$BB_API_BASE/repositories/$BB_WORKSPACE/$BB_REPO_SLUG/pullrequests/$BB_PR_ID/comments'
329+
curl -s --header 'Authorization: Bearer \$BB_API_TOKEN' --request POST --header 'Content-Type: application/json' --data '{"content": {"raw": "$COMMENT_PREFIX\n\nYOUR_COMMENT"}, "inline": {"path": "FILE_PATH", "to": LINE_NUMBER}}' '$BB_API_BASE/repositories/$BB_WORKSPACE/$BB_REPO_SLUG/pullrequests/$BB_PR_ID/comments'
330330
331-
### Phase E: Final Summary
331+
### Phase D: Final Summary
332332
After submitting inline comments (or if zero comments were posted), post the holistic summary.
333333
The summary is the MOST IMPORTANT output -- most developers read only this.
334334
Create the summary comment using the Bitbucket PR Comments API:
335-
curl -s --header 'Authorization: Bearer \$BB_API_TOKEN' --request POST --header 'Content-Type: application/json' --data '{"content": {"raw": "#### Tabnine PR Bot\n\nYOUR_SUMMARY"}}' '$BB_API_BASE/repositories/$BB_WORKSPACE/$BB_REPO_SLUG/pullrequests/$BB_PR_ID/comments'
335+
curl -s --header 'Authorization: Bearer \$BB_API_TOKEN' --request POST --header 'Content-Type: application/json' --data '{"content": {"raw": "$COMMENT_PREFIX\n\nYOUR_SUMMARY"}}' '$BB_API_BASE/repositories/$BB_WORKSPACE/$BB_REPO_SLUG/pullrequests/$BB_PR_ID/comments'
336336
337337
Structure your summary as follows:
338338
- **Line 1 - Risk Tier**: State the tier: [Low Risk], [Standard], or [HIGH RISK]
339339
- **What This PR Does** (1-2 sentences): Demonstrate you understood the author's intent. This builds trust.
340340
- **Assessment** (1-3 sentences): Overall verdict. Is this good to merge? Any blockers?
341341
- **Key Findings** (only if findings exist): Group by severity -- [Critical] first, then [Warning], then [Suggestion]. List max 3-5 findings; if more, prioritize by severity.
342-
- **Cross-Repository Impact** (Tier 2-3 only): Findings from Phase C2, or 'No cross-repository impact detected.'
343-
- **Coaching Guidelines**: Findings from Phase C4 -- list violated guideline IDs grouped by severity, or 'All changed code complies with coaching guidelines.'
342+
- **Cross-Repository Impact** (Tier 2-3 only): Findings from Phase B2, or 'No cross-repository impact detected.'
343+
- **Coaching Guidelines**: Findings from Phase B4 -- list violated guideline IDs grouped by severity, or 'All changed code complies with coaching guidelines.'
344344
- **Deployment & Operations** (only if relevant): Migration safety, feature flag requirements, observability gaps, infrastructure concerns. Omit entirely if no operational concerns.
345345
- **What Looks Good** (1-3 bullet points): Specific things the author did well (good test coverage, clean error handling, thoughtful API design). Always find something positive.
346346

0 commit comments

Comments
 (0)