From 8f81c18647536404039ed2c086bba0a5b0a619b7 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Mon, 25 Sep 2023 18:01:32 +0300 Subject: [PATCH 1/4] auto commands in github action --- pr_agent/servers/github_action_runner.py | 12 +++++++++++- pr_agent/settings/configuration.toml | 5 +++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/pr_agent/servers/github_action_runner.py b/pr_agent/servers/github_action_runner.py index 7dbea972..d1a0f119 100644 --- a/pr_agent/servers/github_action_runner.py +++ b/pr_agent/servers/github_action_runner.py @@ -5,6 +5,8 @@ import os from pr_agent.agent.pr_agent import PRAgent from pr_agent.config_loader import get_settings from pr_agent.git_providers import get_git_provider +from pr_agent.tools.pr_code_suggestions import PRCodeSuggestions +from pr_agent.tools.pr_description import PRDescription from pr_agent.tools.pr_reviewer import PRReviewer @@ -53,7 +55,15 @@ async def run_action(): if action in ["opened", "reopened"]: pr_url = event_payload.get("pull_request", {}).get("url") if pr_url: - await PRReviewer(pr_url).run() + auto_review = os.environ.get('github_action.auto_review') + if auto_review is None or auto_review.lower() == 'true': + await PRReviewer(pr_url).run() + auto_describe = os.environ.get('github_action.auto_describe') + if auto_describe.lower() == 'true': + await PRDescription(pr_url).run() + auto_improve = os.environ.get('github_action.auto_improve') + if auto_improve.lower() == 'true': + await PRCodeSuggestions(pr_url).run() # Handle issue comment event elif GITHUB_EVENT_NAME == "issue_comment": diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index a272e1f9..4f71827c 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -58,6 +58,11 @@ extra_instructions = "" deployment_type = "user" ratelimit_retries = 5 +[github_action] +# auto_review = true # set as env var in .github/workflows/pr-agent.yml +# 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 + [github_app] # these toggles allows running the github app from custom deployments bot_user = "github-actions[bot]" From 388684e2e86207e92131ac5432c965e6ea81e264 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Mon, 25 Sep 2023 18:19:35 +0300 Subject: [PATCH 2/4] none --- pr_agent/servers/github_action_runner.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pr_agent/servers/github_action_runner.py b/pr_agent/servers/github_action_runner.py index d1a0f119..98334339 100644 --- a/pr_agent/servers/github_action_runner.py +++ b/pr_agent/servers/github_action_runner.py @@ -55,13 +55,13 @@ async def run_action(): if action in ["opened", "reopened"]: pr_url = event_payload.get("pull_request", {}).get("url") if pr_url: - auto_review = os.environ.get('github_action.auto_review') + auto_review = os.environ.get('github_action.auto_review', None) if auto_review is None or auto_review.lower() == 'true': await PRReviewer(pr_url).run() - auto_describe = os.environ.get('github_action.auto_describe') + auto_describe = os.environ.get('github_action.auto_describe', None) if auto_describe.lower() == 'true': await PRDescription(pr_url).run() - auto_improve = os.environ.get('github_action.auto_improve') + auto_improve = os.environ.get('github_action.auto_improve', None) if auto_improve.lower() == 'true': await PRCodeSuggestions(pr_url).run() From e7aee84ea85b689ec1751436be703711b8252f9a Mon Sep 17 00:00:00 2001 From: mrT23 Date: Mon, 25 Sep 2023 18:23:56 +0300 Subject: [PATCH 3/4] isinstance --- pr_agent/servers/github_action_runner.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pr_agent/servers/github_action_runner.py b/pr_agent/servers/github_action_runner.py index 98334339..714e7297 100644 --- a/pr_agent/servers/github_action_runner.py +++ b/pr_agent/servers/github_action_runner.py @@ -56,13 +56,13 @@ async def run_action(): pr_url = event_payload.get("pull_request", {}).get("url") if pr_url: auto_review = os.environ.get('github_action.auto_review', None) - if auto_review is None or auto_review.lower() == 'true': + if auto_review is None or (isinstance(auto_review, str) and auto_review.lower() == 'true'): await PRReviewer(pr_url).run() auto_describe = os.environ.get('github_action.auto_describe', None) - if auto_describe.lower() == 'true': + if isinstance(auto_describe, str) and auto_describe.lower() == 'true': await PRDescription(pr_url).run() auto_improve = os.environ.get('github_action.auto_improve', None) - if auto_improve.lower() == 'true': + if isinstance(auto_improve, str) and auto_improve.lower() == 'true': await PRCodeSuggestions(pr_url).run() # Handle issue comment event From 34ed598c20882346e98983eef3539cf5671114dc Mon Sep 17 00:00:00 2001 From: mrT23 Date: Mon, 25 Sep 2023 18:30:20 +0300 Subject: [PATCH 4/4] yaml --- pr_agent/settings/configuration.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index 4f71827c..aa28564c 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -59,7 +59,7 @@ deployment_type = "user" ratelimit_retries = 5 [github_action] -# auto_review = true # set as env var in .github/workflows/pr-agent.yml +# 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_improve = true # set as env var in .github/workflows/pr-agent.yaml