auto tools in github action

This commit is contained in:
mrT23
2023-09-25 18:56:10 +03:00
parent 34ed598c20
commit 4c72cfbff4
4 changed files with 23 additions and 5 deletions

View File

@ -156,7 +156,7 @@ The GITHUB_TOKEN secret is automatically created by GitHub.
3. Merge this change to your main branch.
When you open your next PR, you should see a comment from `github-actions` bot with a review of your PR, and instructions on how to use the rest of the tools.
4. You may configure PR-Agent by adding environment variables under the env section corresponding to any configurable property in the [configuration](./Usage.md) file. Some examples:
4. You may configure PR-Agent by adding environment variables under the env section corresponding to any configurable property in the [configuration]((pr_agent/settings/configuration.toml)) file. Some examples:
```yaml
env:
# ... previous environment values

View File

@ -142,7 +142,21 @@ 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).
### Working with GitHub Action
TBD
You can configure settings in GitHyb action by adding environment variables under the env section in `.github/workflows/pr_agent.yml` file. Some examples:
```yaml
env:
# ... previous environment values
OPENAI.ORG: "<Your organization name under your OpenAI account>"
PR_REVIEWER.REQUIRE_TESTS_REVIEW: "false" # Disable tests review
PR_CODE_SUGGESTIONS.NUM_CODE_SUGGESTIONS: 6 # Increase number of code suggestions
github_action.auto_review: "true" # Enable auto review
github_action.auto_describe: "true" # Enable auto describe
github_action.auto_improve: "false" # Disable auto improve
```
specifically, `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.
if not set, the default option is that only the `review` tool will run automatically when a new PR is opened.
### Appendix - additional configurations walkthrough

View File

@ -239,9 +239,10 @@ class GithubProvider(GitProvider):
def get_user_id(self):
if not self.github_user_id:
try:
self.github_user_id = self.github_client.get_user().login
self.github_user_id = self.github_client.get_user().raw_data['login']
except Exception as e:
logging.exception(f"Failed to get user id, error: {e}")
self.github_user_id = ""
# logging.exception(f"Failed to get user id, error: {e}")
return self.github_user_id
def get_notifications(self, since: datetime):

View File

@ -22,7 +22,10 @@ class PRCodeSuggestions:
)
# extended mode
self.is_extended = any(["extended" in arg for arg in args])
try:
self.is_extended = any(["extended" in arg for arg in args])
except:
self.is_extended = False
if self.is_extended:
num_code_suggestions = get_settings().pr_code_suggestions.num_code_suggestions_per_chunk
else: