Merge remote-tracking branch 'origin/main' into tr/pypi

This commit is contained in:
mrT23
2024-03-22 21:36:45 +02:00
7 changed files with 29 additions and 15 deletions

View File

@ -2,8 +2,11 @@ name: Build-and-test
on: on:
push: push:
branches:
- main
pull_request: pull_request:
types: [ opened, reopened ] branches:
- main
jobs: jobs:
build-and-test: build-and-test:

View File

@ -7,12 +7,12 @@ git_provider="azure"
``` ```
Azure DevOps provider supports [PAT token](https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=Windows) or [DefaultAzureCredential](https://learn.microsoft.com/en-us/azure/developer/python/sdk/authentication-overview#authentication-in-server-environments) authentication. Azure DevOps provider supports [PAT token](https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=Windows) or [DefaultAzureCredential](https://learn.microsoft.com/en-us/azure/developer/python/sdk/authentication-overview#authentication-in-server-environments) authentication.
PAT is faster to create, but has build in experation date, and will use the user identity for API calls. PAT is faster to create, but has build in expiration date, and will use the user identity for API calls.
Using DefaultAzureCredential you can use managed identity or Service principle, which are more secure and will create seperate ADO user identity (via AAD) to the agent. Using DefaultAzureCredential you can use managed identity or Service principle, which are more secure and will create separate ADO user identity (via AAD) to the agent.
If PAT was choosen, you can assign the value in .secrets.toml. If PAT was chosen, you can assign the value in .secrets.toml.
If DefaultAzureCredential was choosen, you can assigned the additional env vars like AZURE_CLIENT_SECRET directly, If DefaultAzureCredential was chosen, you can assigned the additional env vars like AZURE_CLIENT_SECRET directly,
or use managed identity/az cli (for local develpment) without any additional configuration. or use managed identity/az cli (for local development) without any additional configuration.
in any case, 'org' value must be assigned in .secrets.toml: in any case, 'org' value must be assigned in .secrets.toml:
``` ```
[azure_devops] [azure_devops]

View File

@ -49,7 +49,8 @@ To edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agen
- `enable_semantic_files_types`: if set to true, "Changes walkthrough" section will be generated. Default is true. - `enable_semantic_files_types`: if set to true, "Changes walkthrough" section will be generated. Default is true.
- `collapsible_file_list`: if set to true, the file list in the "Changes walkthrough" section will be collapsible. If set to "adaptive", the file list will be collapsible only if there are more than 8 files. Default is "adaptive". - `collapsible_file_list`: if set to true, the file list in the "Changes walkthrough" section will be collapsible. If set to "adaptive", the file list will be collapsible only if there are more than 8 files. Default is "adaptive".
- `enable_help_text`: if set to true, the tool will display a help text in the comment. Default is false.
### Inline file summary 💎 ### Inline file summary 💎
This feature enables you to copy the `changes walkthrough` table to the "Files changed" tab, so you can quickly understand the changes in each file while reviewing the code changes (diff view). This feature enables you to copy the `changes walkthrough` table to the "Files changed" tab, so you can quickly understand the changes in each file while reviewing the code changes (diff view).

View File

@ -33,6 +33,7 @@ To edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agen
- `inline_code_comments`: if set to true, the tool will publish the code suggestions as comments on the code diff. Default is false. - `inline_code_comments`: if set to true, the tool will publish the code suggestions as comments on the code diff. Default is false.
- `persistent_comment`: if set to true, the review comment will be persistent, meaning that every new review request will edit the previous one. Default is true. - `persistent_comment`: if set to true, the review comment will be persistent, meaning that every new review request will edit the previous one. Default is true.
- `extra_instructions`: Optional extra instructions to the tool. For example: "focus on the changes in the file X. Ignore change in ...". - `extra_instructions`: Optional extra instructions to the tool. For example: "focus on the changes in the file X. Ignore change in ...".
- `enable_help_text`: if set to true, the tool will display a help text in the comment. Default is true.
!!! example "Enable\\disable sub-sections" !!! example "Enable\\disable sub-sections"
You can enable or disable specific sub-sections of the review tool: You can enable or disable specific sub-sections of the review tool:

View File

@ -173,12 +173,12 @@ git_provider="azure"
``` ```
Azure DevOps provider supports [PAT token](https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=Windows) or [DefaultAzureCredential](https://learn.microsoft.com/en-us/azure/developer/python/sdk/authentication-overview#authentication-in-server-environments) authentication. Azure DevOps provider supports [PAT token](https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=Windows) or [DefaultAzureCredential](https://learn.microsoft.com/en-us/azure/developer/python/sdk/authentication-overview#authentication-in-server-environments) authentication.
PAT is faster to create, but has build in experation date, and will use the user identity for API calls. PAT is faster to create, but has build in expiration date, and will use the user identity for API calls.
Using DefaultAzureCredential you can use managed identity or Service principle, which are more secure and will create seperate ADO user identity (via AAD) to the agent. Using DefaultAzureCredential you can use managed identity or Service principle, which are more secure and will create separate ADO user identity (via AAD) to the agent.
If PAT was choosen, you can assign the value in .secrets.toml. If PAT was chosen, you can assign the value in .secrets.toml.
If DefaultAzureCredential was choosen, you can assigned the additional env vars like AZURE_CLIENT_SECRET directly, If DefaultAzureCredential was chosen, you can assigned the additional env vars like AZURE_CLIENT_SECRET directly,
or use managed identity/az cli (for local develpment) without any additional configuration. or use managed identity/az cli (for local development) without any additional configuration.
in any case, 'org' value must be assigned in .secrets.toml: in any case, 'org' value must be assigned in .secrets.toml:
``` ```
[azure_devops] [azure_devops]

View File

@ -118,9 +118,15 @@ async def handle_new_pr_opened(body: Dict[str, Any],
event: str, event: str,
sender: str, sender: str,
sender_id: str, sender_id: str,
sender_type: str,
action: str, action: str,
log_context: Dict[str, Any], log_context: Dict[str, Any],
agent: PRAgent): agent: PRAgent):
# logic to ignore PRs opened by bot
if get_settings().get("GITHUB_APP.IGNORE_BOT_PR", False) and sender_type == "Bot":
get_logger().info(f"Ignoring PR from '{sender=}' due to github_app.ignore_bot_pr setting")
return {}
title = body.get("pull_request", {}).get("title", "") title = body.get("pull_request", {}).get("title", "")
# logic to ignore PRs with specific titles (e.g. "[Auto] ...") # logic to ignore PRs with specific titles (e.g. "[Auto] ...")
@ -224,9 +230,11 @@ def handle_closed_pr(body, event, action, log_context):
def get_log_context(body, event, action, build_number): def get_log_context(body, event, action, build_number):
sender = "" sender = ""
sender_id = "" sender_id = ""
sender_type = ""
try: try:
sender = body.get("sender", {}).get("login") sender = body.get("sender", {}).get("login")
sender_id = body.get("sender", {}).get("id") sender_id = body.get("sender", {}).get("id")
sender_type = body.get("sender", {}).get("type")
repo = body.get("repository", {}).get("full_name", "") repo = body.get("repository", {}).get("full_name", "")
git_org = body.get("organization", {}).get("login", "") git_org = body.get("organization", {}).get("login", "")
app_name = get_settings().get("CONFIG.APP_NAME", "Unknown") app_name = get_settings().get("CONFIG.APP_NAME", "Unknown")
@ -236,7 +244,7 @@ def get_log_context(body, event, action, build_number):
except Exception as e: except Exception as e:
get_logger().error("Failed to get log context", e) get_logger().error("Failed to get log context", e)
log_context = {} log_context = {}
return log_context, sender, sender_id return log_context, sender, sender_id, sender_type
async def handle_request(body: Dict[str, Any], event: str): async def handle_request(body: Dict[str, Any], event: str):
@ -251,7 +259,7 @@ async def handle_request(body: Dict[str, Any], event: str):
if not action: if not action:
return {} return {}
agent = PRAgent() agent = PRAgent()
log_context, sender, sender_id = get_log_context(body, event, action, build_number) log_context, sender, sender_id, sender_type = get_log_context(body, event, action, build_number)
# handle comments on PRs # handle comments on PRs
if action == 'created': if action == 'created':
@ -260,7 +268,7 @@ async def handle_request(body: Dict[str, Any], event: str):
# handle new PRs # handle new PRs
elif event == 'pull_request' and action != 'synchronize' and action != 'closed': elif event == 'pull_request' and action != 'synchronize' and action != 'closed':
get_logger().debug(f'Request body', artifact=body, event=event) get_logger().debug(f'Request body', artifact=body, event=event)
await handle_new_pr_opened(body, event, sender, sender_id, action, log_context, agent) await handle_new_pr_opened(body, event, sender, sender_id, sender_type, action, log_context, agent)
# handle pull_request event with synchronize action - "push trigger" for new commits # handle pull_request event with synchronize action - "push trigger" for new commits
elif event == 'pull_request' and action == 'synchronize': elif event == 'pull_request' and action == 'synchronize':
get_logger().debug(f'Request body', artifact=body, event=event) get_logger().debug(f'Request body', artifact=body, event=event)

View File

@ -156,6 +156,7 @@ push_commands = [
"/review --pr_reviewer.num_code_suggestions=0", "/review --pr_reviewer.num_code_suggestions=0",
] ]
ignore_pr_title = [] ignore_pr_title = []
ignore_bot_pr = false
[gitlab] [gitlab]
url = "https://gitlab.com" # URL to the gitlab service url = "https://gitlab.com" # URL to the gitlab service