Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into tr/pypi
Browse files Browse the repository at this point in the history
  • Loading branch information
mrT23 committed Mar 22, 2024
2 parents 0816370 + b4b2c7c commit 887d640
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 15 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ name: Build-and-test

on:
push:
branches:
- main
pull_request:
types: [ opened, reopened ]
branches:
- main

jobs:
build-and-test:
Expand Down
10 changes: 5 additions & 5 deletions docs/docs/installation/azure.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
PAT is faster to create, but has build in experation 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.
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 separate ADO user identity (via AAD) to the agent.

If PAT was choosen, you can assign the value in .secrets.toml.
If DefaultAzureCredential was choosen, 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.
If PAT was chosen, you can assign the value in .secrets.toml.
If DefaultAzureCredential was chosen, you can assigned the additional env vars like AZURE_CLIENT_SECRET directly,
or use managed identity/az cli (for local development) without any additional configuration.
in any case, 'org' value must be assigned in .secrets.toml:
```
[azure_devops]
Expand Down
3 changes: 2 additions & 1 deletion docs/docs/tools/describe.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
- `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 💎

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).
Expand Down
1 change: 1 addition & 0 deletions docs/docs/tools/review.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
- `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 ...".
- `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"
You can enable or disable specific sub-sections of the review tool:
Expand Down
10 changes: 5 additions & 5 deletions docs/docs/usage-guide/automations_and_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
PAT is faster to create, but has build in experation 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.
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 separate ADO user identity (via AAD) to the agent.
If PAT was choosen, you can assign the value in .secrets.toml.
If DefaultAzureCredential was choosen, 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.
If PAT was chosen, you can assign the value in .secrets.toml.
If DefaultAzureCredential was chosen, you can assigned the additional env vars like AZURE_CLIENT_SECRET directly,
or use managed identity/az cli (for local development) without any additional configuration.
in any case, 'org' value must be assigned in .secrets.toml:
```
[azure_devops]
Expand Down
14 changes: 11 additions & 3 deletions pr_agent/servers/github_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,15 @@ async def handle_new_pr_opened(body: Dict[str, Any],
event: str,
sender: str,
sender_id: str,
sender_type: str,
action: str,
log_context: Dict[str, Any],
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", "")

# logic to ignore PRs with specific titles (e.g. "[Auto] ...")
Expand Down Expand Up @@ -224,9 +230,11 @@ def handle_closed_pr(body, event, action, log_context):
def get_log_context(body, event, action, build_number):
sender = ""
sender_id = ""
sender_type = ""
try:
sender = body.get("sender", {}).get("login")
sender_id = body.get("sender", {}).get("id")
sender_type = body.get("sender", {}).get("type")
repo = body.get("repository", {}).get("full_name", "")
git_org = body.get("organization", {}).get("login", "")
app_name = get_settings().get("CONFIG.APP_NAME", "Unknown")
Expand All @@ -236,7 +244,7 @@ def get_log_context(body, event, action, build_number):
except Exception as e:
get_logger().error("Failed to get log context", e)
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):
Expand All @@ -251,7 +259,7 @@ async def handle_request(body: Dict[str, Any], event: str):
if not action:
return {}
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
if action == 'created':
Expand All @@ -260,7 +268,7 @@ async def handle_request(body: Dict[str, Any], event: str):
# handle new PRs
elif event == 'pull_request' and action != 'synchronize' and action != 'closed':
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
elif event == 'pull_request' and action == 'synchronize':
get_logger().debug(f'Request body', artifact=body, event=event)
Expand Down
1 change: 1 addition & 0 deletions pr_agent/settings/configuration.toml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ push_commands = [
"/review --pr_reviewer.num_code_suggestions=0",
]
ignore_pr_title = []
ignore_bot_pr = false

[gitlab]
url = "https://gitlab.com" # URL to the gitlab service
Expand Down

0 comments on commit 887d640

Please sign in to comment.