Adapt Devstar/Gitea action integration#2308
Adapt Devstar/Gitea action integration#2308mengning wants to merge 3 commits intoThe-PR-Agent:mainfrom
Conversation
feat:adaptation with Devstar/Gitea action
Review Summary by QodoAdd Gitea Actions runner and ticket context integration
WalkthroughsDescription• Add Gitea Actions runner integration for automated PR workflows • Implement issue context fetching and ticket compliance checking for Gitea • Refactor repository settings handling with hardcoded .pr_agent.toml path • Add Docker build workflow and update documentation for Devstar/Gitea support Diagramflowchart LR
A["Gitea Actions Event"] -->|"EVENT_NAME, TOKEN"| B["gitea_action_runner.py"]
B -->|"Configure Provider"| C["GiteaProvider"]
C -->|"Fetch Issue Context"| D["get_issue_main_description"]
C -->|"Extract Tickets"| E["ticket_pr_compliance_check.py"]
B -->|"Execute Tools"| F["PRDescription/Reviewer/Suggestions"]
G["entrypoint.sh"] -->|"Route Event"| B
H["Docker Workflow"] -->|"Build & Push"| I["Docker Image"]
File Changes1. pr_agent/servers/gitea_actions_runner.py
|
Code Review by QodoNew Review StartedThis review has been superseded by a new analysisⓘ The new review experience is currently in Beta. Learn more |
Code Review by Qodo
1. entrypoint.sh calls missing runner
|
| if [ -n "$GITEA_EVENT_NAME" ] || [ "$GITEA_ACTIONS" == "true" ]; then | ||
| python /app/pr_agent/servers/gitea_action_runner.py |
There was a problem hiding this comment.
1. entrypoint.sh calls missing runner 📘 Rule violation ☼ Reliability
github_action/entrypoint.sh runs python /app/pr_agent/servers/gitea_action_runner.py, but this PR adds pr_agent/servers/gitea_actions_runner.py (different filename). This will fail at runtime when Gitea actions are detected, preventing the action from starting.
Agent Prompt
## Issue description
The action entrypoint runs `gitea_action_runner.py`, but the repo contains `gitea_actions_runner.py`. This causes the container to crash when Gitea actions are detected.
## Issue Context
The mismatch is in the startup path for Devstar/Gitea actions.
## Fix Focus Areas
- github_action/entrypoint.sh[4-5]
- pr_agent/servers/gitea_actions_runner.py[1-1]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| raise ValueError("Gitea access token not found in settings.") | ||
|
|
||
| self.repo_settings = get_settings().get("GITEA.REPO_SETTING", None) | ||
| self.repo_settings = ".pr_agent.toml" |
There was a problem hiding this comment.
2. Hardcoded .pr_agent.toml path 📘 Rule violation ⚙ Maintainability
The Gitea provider now hardcodes the repository settings path to .pr_agent.toml instead of reading it from configuration. This makes behavior non-configurable and breaks the intended configuration override mechanism.
Agent Prompt
## Issue description
Repository settings path is hard-coded to `.pr_agent.toml` in the Gitea provider, preventing configuration overrides.
## Issue Context
Previously this value was configurable; hard-coding reduces deployability and breaks expected configuration patterns.
## Fix Focus Areas
- pr_agent/git_providers/gitea_provider.py[38-38]
- pr_agent/git_providers/gitea_provider.py[617-624]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| except Exception as e: | ||
| self.logger.error(f"Failed to fetch Gitea issue body: {e}") | ||
| return "" |
There was a problem hiding this comment.
3. Broad except exception in provider 📘 Rule violation ☼ Reliability
New Gitea provider methods catch Exception broadly and then return empty values, which can mask unexpected failures and make debugging harder. This violates the requirement to use targeted exception handling and preserve error context.
Agent Prompt
## Issue description
The Gitea provider uses broad `except Exception` and returns empty values, masking unexpected failures.
## Issue Context
Fetching issue bodies and repo settings should catch expected API/HTTP errors (e.g., 404) separately, and preserve context when re-raising/wrapping.
## Fix Focus Areas
- pr_agent/git_providers/gitea_provider.py[546-553]
- pr_agent/git_providers/gitea_provider.py[630-635]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| try: | ||
| with open(EVENT_PATH, "r") as f: | ||
| event_payload = json.load(f) | ||
| except Exception as e: | ||
| get_logger().error(f"Failed to parse payload JSON: {e}") | ||
| return |
There was a problem hiding this comment.
4. Broad except exception in runner 📘 Rule violation ☼ Reliability
pr_agent/servers/gitea_actions_runner.py uses broad except Exception in multiple places, which can hide real bugs and removes error specificity. This violates the requirement to catch expected exception types and preserve context.
Agent Prompt
## Issue description
The new Gitea actions runner catches `Exception` broadly in multiple blocks.
## Issue Context
Replace broad catches with specific exceptions (e.g., `json.JSONDecodeError`, `FileNotFoundError`, provider API exceptions) and use exception chaining when appropriate.
## Fix Focus Areas
- pr_agent/servers/gitea_actions_runner.py[84-86]
- pr_agent/servers/gitea_actions_runner.py[132-137]
- pr_agent/servers/gitea_actions_runner.py[153-156]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| import re | ||
| user_description = git_provider.get_pr_description_full() | ||
|
|
||
| ticket_numbers = list(set(re.findall(r'#(\d+)', user_description))) |
There was a problem hiding this comment.
5. set() dedupes ticket_numbers 📘 Rule violation ☼ Reliability
Ticket numbers are deduplicated via set(...), which does not preserve ordering and can produce non-deterministic ticket processing order. This can lead to unstable outputs, especially when truncation/limits are applied later.
Agent Prompt
## Issue description
`ticket_numbers = list(set(...))` is non-deterministic and can reorder extracted tickets.
## Issue Context
Stable ordering matters for consistent reviews and reproducible outputs.
## Fix Focus Areas
- pr_agent/tools/ticket_pr_compliance_check.py[221-224]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| if DEVSTAR_URL: | ||
| get_logger().info(f"Resolved Gitea URL from DEVSTAR_URL: {FINAL_GITEA_URL}") | ||
| elif GITEA_URL: | ||
| get_logger().info(f"Resolved Gitea URL from GITEA_URL: {FINAL_GITEA_URL}") |
There was a problem hiding this comment.
6. Runner whitespace/newline issues 📘 Rule violation ⚙ Maintainability
pr_agent/servers/gitea_actions_runner.py includes trailing whitespace and is missing a final newline, which can cause pre-commit hooks to fail. This violates repository whitespace and newline requirements.
Agent Prompt
## Issue description
The new runner file has trailing whitespace and no final newline, which can fail pre-commit hooks.
## Issue Context
The diff shows trailing spaces and indicates a missing newline at EOF.
## Fix Focus Areas
- pr_agent/servers/gitea_actions_runner.py[124-124]
- pr_agent/servers/gitea_actions_runner.py[223-224]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| # 4. Extract the PR URL | ||
| pr_url = None | ||
| if EVENT_NAME in ["pull_request", "pull_request_target"]: | ||
| pr_url = event_payload.get("pull_request", {}).get("html_url") | ||
| elif EVENT_NAME == "issue_comment": | ||
| issue_data = event_payload.get("issue", {}) | ||
| if "pull_request" in issue_data: | ||
| pr_url = issue_data.get("pull_request", {}).get("html_url") or issue_data.get("html_url") | ||
|
|
||
| if not pr_url: | ||
| get_logger().warning("No valid PR URL found in the payload. Exiting.") | ||
| return |
There was a problem hiding this comment.
7. Pr url field mismatch 🐞 Bug ≡ Correctness
pr_agent/servers/gitea_actions_runner.py reads PR URL from pull_request.html_url, but the existing Gitea handler uses pull_request.url. If the Actions payload matches the webhook payload shape, pr_url will be empty and the runner exits without processing PR events.
Agent Prompt
### Issue description
The Gitea Actions runner extracts the PR URL from `pull_request.html_url` only. Existing Gitea code paths use `pull_request.url`, so the runner can fail to find a PR URL and exit.
### Issue Context
Gitea webhook handling uses `pull_request.url` as the canonical URL passed into `apply_repo_settings()` / `handle_request()`.
### Fix Focus Areas
- pr_agent/servers/gitea_actions_runner.py[139-150]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Adapt Devstar/Gitea action integration