mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-04 12:50:38 +08:00
feat: Update configuration and handling of GitHub Action settings
This commit is contained in:
6
.github/workflows/pr-agent-review.yaml
vendored
6
.github/workflows/pr-agent-review.yaml
vendored
@ -27,7 +27,9 @@ jobs:
|
|||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
PINECONE.API_KEY: ${{ secrets.PINECONE_API_KEY }}
|
PINECONE.API_KEY: ${{ secrets.PINECONE_API_KEY }}
|
||||||
PINECONE.ENVIRONMENT: ${{ secrets.PINECONE_ENVIRONMENT }}
|
PINECONE.ENVIRONMENT: ${{ secrets.PINECONE_ENVIRONMENT }}
|
||||||
GITHUB_ACTION.AUTO_REVIEW: true
|
GITHUB_ACTION_CONFIG.AUTO_DESCRIBE: true
|
||||||
GITHUB_ACTION.AUTO_IMPROVE: true
|
GITHUB_ACTION_CONFIG.AUTO_REVIEW: true
|
||||||
|
GITHUB_ACTION_CONFIG.AUTO_IMPROVE: true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
30
Usage.md
30
Usage.md
@ -146,24 +146,17 @@ The [github_app](pr_agent/settings/configuration.toml#L76) section defines GitHu
|
|||||||
In this section, you can define configurations to control the conditions for which tools will **run automatically**.
|
In this section, you can define configurations to control the conditions for which tools will **run automatically**.
|
||||||
|
|
||||||
##### GitHub app automatic tools for PR actions
|
##### GitHub app automatic tools for PR actions
|
||||||
The GitHub app can respond to the following actions on a PR:
|
The configuration parameter `pr_commands` defines the list of tools that will be **run automatically** when a new PR is opened.
|
||||||
1. `opened` - Opening a new PR
|
|
||||||
2. `reopened` - Reopening a closed PR
|
|
||||||
3. `ready_for_review` - Moving a PR from Draft to Open
|
|
||||||
4. `review_requested` - Specifically requesting review (in the PR reviewers list) from the `github-actions[bot]` user
|
|
||||||
|
|
||||||
The configuration parameter `handle_pr_actions` defines the list of actions for which the GitHub app will trigger the PR-Agent.
|
|
||||||
The configuration parameter `pr_commands` defines the list of tools that will be **run automatically** when one of the above actions happens (e.g., a new PR is opened):
|
|
||||||
```
|
```
|
||||||
[github_app]
|
[github_app]
|
||||||
handle_pr_actions = ['opened', 'reopened', 'ready_for_review', 'review_requested']
|
|
||||||
pr_commands = [
|
pr_commands = [
|
||||||
"/describe --pr_description.add_original_user_description=true --pr_description.keep_original_user_title=true",
|
"/describe --pr_description.add_original_user_description=true --pr_description.keep_original_user_title=true",
|
||||||
"/review",
|
"/review --pr_reviewer.num_code_suggestions=0",
|
||||||
|
"/improve",
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
This means that when a new PR is opened/reopened or marked as ready for review, PR-Agent will run the `describe` and `review` tools.
|
This means that when a new PR is opened/reopened or marked as ready for review, PR-Agent will run the `describe`, `review` and `improve` tools.
|
||||||
For the `describe` tool, the `add_original_user_description` and `keep_original_user_title` parameters will be set to true.
|
For the `describe` tool, for example, the `add_original_user_description` and `keep_original_user_title` parameters will be set to true.
|
||||||
|
|
||||||
You can override the default tool parameters by uploading a local configuration file called `.pr_agent.toml` to the root of your repo.
|
You can override the default tool parameters by uploading a local configuration file called `.pr_agent.toml` to the root of your repo.
|
||||||
For example, if your local `.pr_agent.toml` file contains:
|
For example, if your local `.pr_agent.toml` file contains:
|
||||||
@ -180,7 +173,7 @@ To cancel the automatic run of all the tools, set:
|
|||||||
handle_pr_actions = []
|
handle_pr_actions = []
|
||||||
```
|
```
|
||||||
|
|
||||||
##### GitHub app automatic tools for new code (PR push)
|
##### GitHub app automatic tools for push actions (commits to an open PR)
|
||||||
In addition to running automatic tools when a PR is opened, the GitHub app can also respond to new code that is pushed to an open PR.
|
In addition to running automatic tools when a PR is opened, the GitHub app can also respond to new code that is pushed to an open PR.
|
||||||
|
|
||||||
The configuration toggle `handle_push_trigger` can be used to enable this feature.
|
The configuration toggle `handle_push_trigger` can be used to enable this feature.
|
||||||
@ -217,17 +210,18 @@ user="""
|
|||||||
Note that the new prompt will need to generate an output compatible with the relevant [post-process function](./pr_agent/tools/pr_description.py#L137).
|
Note that the new prompt will need to generate an output compatible with the relevant [post-process function](./pr_agent/tools/pr_description.py#L137).
|
||||||
|
|
||||||
### Working with GitHub Action
|
### Working with GitHub Action
|
||||||
You can configure settings in GitHub action by adding environment variables under the env section in `.github/workflows/pr_agent.yml` file.
|
`GitHub Action` is a different way to trigger PR-Agent tools, and uses a different configuration mechanism than `GitHub App`.
|
||||||
|
You can configure settings for `GitHub Action` by adding environment variables under the env section in `.github/workflows/pr_agent.yml` file.
|
||||||
Specifically, start by setting the following environment variables:
|
Specifically, start by setting the following environment variables:
|
||||||
```yaml
|
```yaml
|
||||||
env:
|
env:
|
||||||
OPENAI_KEY: ${{ secrets.OPENAI_KEY }} # Make sure to add your OpenAI key to your repo secrets
|
OPENAI_KEY: ${{ secrets.OPENAI_KEY }} # Make sure to add your OpenAI key to your repo secrets
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Make sure to add your GitHub token to your repo secrets
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Make sure to add your GitHub token to your repo secrets
|
||||||
github_action.auto_review: "true" # enable\disable auto review
|
github_action_config.auto_review: "true" # enable\disable auto review
|
||||||
github_action.auto_describe: "true" # enable\disable auto describe
|
github_action_config.auto_describe: "true" # enable\disable auto describe
|
||||||
github_action.auto_improve: "false" # enable\disable auto improve
|
github_action_config.auto_improve: "false" # enable\disable auto improve
|
||||||
```
|
```
|
||||||
`github_action.auto_review`, `github_action.auto_describe` and `github_action.auto_improve` are used to enable/disable automatic tools that run when a new PR is opened.
|
`github_action_config.auto_review`, `github_action_config.auto_describe` and `github_action_config.auto_improve` are used to enable/disable automatic tools that run when a new PR is opened.
|
||||||
If not set, the default option is that only the `review` tool will run automatically when a new PR is opened.
|
If not set, the default option is that only the `review` tool will run automatically when a new PR is opened.
|
||||||
|
|
||||||
Note that you can give additional config parameters by adding environment variables to `.github/workflows/pr_agent.yml`, or by using a `.pr_agent.toml` file in the root of your repo, similar to the GitHub App usage.
|
Note that you can give additional config parameters by adding environment variables to `.github/workflows/pr_agent.yml`, or by using a `.pr_agent.toml` file in the root of your repo, similar to the GitHub App usage.
|
||||||
|
@ -82,14 +82,23 @@ async def run_action():
|
|||||||
if action in ["opened", "reopened"]:
|
if action in ["opened", "reopened"]:
|
||||||
pr_url = event_payload.get("pull_request", {}).get("url")
|
pr_url = event_payload.get("pull_request", {}).get("url")
|
||||||
if pr_url:
|
if pr_url:
|
||||||
|
# legacy - supporting both GITHUB_ACTION and GITHUB_ACTION_CONFIG
|
||||||
auto_review = get_setting_or_env("GITHUB_ACTION.AUTO_REVIEW", None)
|
auto_review = get_setting_or_env("GITHUB_ACTION.AUTO_REVIEW", None)
|
||||||
|
if auto_review is None:
|
||||||
|
auto_review = get_setting_or_env("GITHUB_ACTION_CONFIG.AUTO_REVIEW", None)
|
||||||
|
auto_describe = get_setting_or_env("GITHUB_ACTION.AUTO_DESCRIBE", None)
|
||||||
|
if auto_describe is None:
|
||||||
|
auto_describe = get_setting_or_env("GITHUB_ACTION_CONFIG.AUTO_DESCRIBE", None)
|
||||||
|
auto_improve = get_setting_or_env("GITHUB_ACTION.AUTO_IMPROVE", None)
|
||||||
|
if auto_improve is None:
|
||||||
|
auto_improve = get_setting_or_env("GITHUB_ACTION_CONFIG.AUTO_IMPROVE", None)
|
||||||
|
|
||||||
|
# invoke by default all three tools
|
||||||
|
if auto_describe is None or is_true(auto_describe):
|
||||||
|
await PRDescription(pr_url).run()
|
||||||
if auto_review is None or is_true(auto_review):
|
if auto_review is None or is_true(auto_review):
|
||||||
await PRReviewer(pr_url).run()
|
await PRReviewer(pr_url).run()
|
||||||
auto_describe = get_setting_or_env("GITHUB_ACTION.AUTO_DESCRIBE", None)
|
if auto_improve is None or is_true(auto_improve):
|
||||||
if is_true(auto_describe):
|
|
||||||
await PRDescription(pr_url).run()
|
|
||||||
auto_improve = get_setting_or_env("GITHUB_ACTION.AUTO_IMPROVE", None)
|
|
||||||
if is_true(auto_improve):
|
|
||||||
await PRCodeSuggestions(pr_url).run()
|
await PRCodeSuggestions(pr_url).run()
|
||||||
|
|
||||||
# Handle issue comment event
|
# Handle issue comment event
|
||||||
|
@ -47,7 +47,7 @@ enable_help_text=true # Determines whether to include help text in the PR review
|
|||||||
publish_labels=true
|
publish_labels=true
|
||||||
publish_description_as_comment=false
|
publish_description_as_comment=false
|
||||||
add_original_user_description=true
|
add_original_user_description=true
|
||||||
keep_original_user_title=false
|
keep_original_user_title=true
|
||||||
use_bullet_points=true
|
use_bullet_points=true
|
||||||
extra_instructions = ""
|
extra_instructions = ""
|
||||||
enable_pr_type=true
|
enable_pr_type=true
|
||||||
@ -100,7 +100,7 @@ base_url = "https://api.github.com"
|
|||||||
publish_inline_comments_fallback_with_verification = true
|
publish_inline_comments_fallback_with_verification = true
|
||||||
try_fix_invalid_inline_comments = true
|
try_fix_invalid_inline_comments = true
|
||||||
|
|
||||||
[github_action]
|
[github_action_config]
|
||||||
# auto_review = true # set as env var in .github/workflows/pr-agent.yaml
|
# auto_review = true # set as env var in .github/workflows/pr-agent.yaml
|
||||||
# auto_describe = true # set as env var in .github/workflows/pr-agent.yaml
|
# auto_describe = true # set as env var in .github/workflows/pr-agent.yaml
|
||||||
# auto_improve = true # set as env var in .github/workflows/pr-agent.yaml
|
# auto_improve = true # set as env var in .github/workflows/pr-agent.yaml
|
||||||
|
Reference in New Issue
Block a user