Skip to content

Commit a458a4f

Browse files
meysholdtona-agent
andcommitted
added automation
Co-authored-by: Ona <no-reply@ona.com>
1 parent 8d9c729 commit a458a4f

2 files changed

Lines changed: 81 additions & 0 deletions

File tree

.ona/deploy-to-SE-demo.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
ona ai automation update 019c95af-e354-7d00-a5ed-5856f50e5957 fix-sonar-issue.yaml

.ona/fix-sonar-issue.yaml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
action:
2+
limits:
3+
maxParallel: 1
4+
maxTotal: 10
5+
steps:
6+
- agent:
7+
prompt: |
8+
You have access to SonarQube tools via MCP. Use them to query the project
9+
"ona-samples_sonarcube-integration" for open issues with BLOCKER or HIGH severity.
10+
11+
Pick the single highest-severity issue (BLOCKER > HIGH). If there are ties,
12+
pick the one in production code (src/main) over test code (src/test).
13+
14+
For the selected issue:
15+
1. Read the SonarQube rule details to understand what the rule requires.
16+
2. Read the affected source file and surrounding context.
17+
3. Note the rule key, severity, file path, line number, and the rule's message.
18+
19+
Do NOT make any code changes yet.
20+
- agent:
21+
prompt: |
22+
Using the issue identified in the previous step:
23+
24+
1. Create a new git branch named "sonar-fix/<rule-key>" (e.g. sonar-fix/java-S2699).
25+
2. Apply the minimal fix that resolves the SonarQube issue while preserving
26+
existing behavior. Follow the project's code style and conventions.
27+
3. Commit the fix with message: "Fix SonarQube <rule-key>: <short description>"
28+
Add co-author: "Co-authored-by: Ona <no-reply@ona.com>"
29+
30+
Do NOT run tests yet.
31+
- agent:
32+
prompt: |
33+
Verify the fix from the previous step:
34+
35+
1. Run `./mvnw compile test` to compile and run all tests.
36+
2. If compilation or tests fail:
37+
a. Read the error output carefully.
38+
b. Identify whether the failure is caused by the fix or a pre-existing issue.
39+
c. If caused by the fix, adjust the code and amend the commit.
40+
d. Rerun `./mvnw compile test`.
41+
e. Repeat until all tests pass.
42+
3. Once tests pass, confirm the fix is complete.
43+
- pullRequest:
44+
branch: sonar-fix/<issue>
45+
title: 'Sonar-Fix: <title>'
46+
description: |
47+
## SonarQube Issue
48+
49+
| Field | Value |
50+
|-------|-------|
51+
| **Rule** | `<rule-key>` — [View rule](https://rules.sonarsource.com/java/RSPEC-<rule-number>) |
52+
| **Severity** | <severity> |
53+
| **Type** | <clean-code-attribute-category> |
54+
| **Message** | <sonar-message> |
55+
56+
## Affected Code
57+
58+
| Field | Value |
59+
|-------|-------|
60+
| **File** | `<file-path>` |
61+
| **Line** | <line-number> |
62+
63+
## What changed
64+
65+
<one-or-two-sentence explanation of the fix and why it resolves the issue>
66+
67+
## Verification
68+
69+
- [x] `./mvnw compile test` passes
70+
- [x] Fix is minimal and preserves existing behavior
71+
description: >-
72+
Picks the highest-severity open SonarQube issue, applies a fix,
73+
verifies tests pass, and opens a pull request.
74+
name: fix-sonar-issue
75+
triggers:
76+
- context:
77+
projects: {}
78+
manual: {}

0 commit comments

Comments
 (0)