-
Notifications
You must be signed in to change notification settings - Fork 621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix bitbucket pipeline #304
Merged
hussam789
merged 18 commits into
Codium-ai:main
from
sarbjitsinghgrewal:fix_bitbucket_pipeline
Sep 22, 2023
Merged
Changes from 16 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
ed1816a
Merge branch 'main' of https://github.com/Codium-ai/pr-agent into fix…
sarbjitsinghgrewal ca8997b
Merge branch 'main' of https://github.com/Codium-ai/pr-agent into fix…
sarbjitsinghgrewal 12bd9e8
add bitbucket pipeline
sarbjitsinghgrewal 9bd5140
update access token
sarbjitsinghgrewal 9bee305
add bitbucket access token
sarbjitsinghgrewal caee7cb
add bitbucket access token
sarbjitsinghgrewal 67052aa
add bitbucket access token
sarbjitsinghgrewal 4043dff
Merge branch 'main' of https://github.com/Codium-ai/pr-agent into fix…
sarbjitsinghgrewal 978c56c
update pipeline
sarbjitsinghgrewal 7b2c011
Merge pull request #3 from sarbjitsinghgrewal/fix_bitbucket_pipeline
sarbjitsinghgrewal e343ce8
bitbucket pipeline for adding reviews
sarbjitsinghgrewal 43af4aa
remove token from config
sarbjitsinghgrewal a2ca43a
Merge branch 'main' of https://github.com/Codium-ai/pr-agent into fix…
sarbjitsinghgrewal f7abdc6
Merge branch 'main' of https://github.com/Codium-ai/pr-agent into fix…
sarbjitsinghgrewal 5e608cc
Merge branch 'main' of https://github.com/Codium-ai/pr-agent into fix…
sarbjitsinghgrewal 46ec3c0
implement suggestions in bitbucket pipeline
sarbjitsinghgrewal 56cc804
Merge branch 'main' of https://github.com/Codium-ai/pr-agent into fix…
sarbjitsinghgrewal 3e2e2d6
update install.md
sarbjitsinghgrewal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM python:3.10 as base | ||
|
||
ENV OPENAI_API_KEY=${OPENAI_API_KEY} \ | ||
BITBUCKET_BEARER_TOKEN=${BITBUCKET_BEARER_TOKEN} \ | ||
BITBUCKET_PR_ID=${BITBUCKET_PR_ID} \ | ||
BITBUCKET_REPO_SLUG=${BITBUCKET_REPO_SLUG} \ | ||
BITBUCKET_WORKSPACE=${BITBUCKET_WORKSPACE} | ||
|
||
|
||
WORKDIR /app | ||
ADD pyproject.toml . | ||
ADD requirements.txt . | ||
RUN pip install . && rm pyproject.toml requirements.txt | ||
ENV PYTHONPATH=/app | ||
ADD pr_agent pr_agent | ||
ADD bitbucket_pipeline/entrypoint.sh / | ||
RUN chmod +x /entrypoint.sh | ||
ENTRYPOINT ["/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
python /app/pr_agent/servers/bitbucket_pipeline_runner.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import os | ||
from pr_agent.agent.pr_agent import PRAgent | ||
from pr_agent.config_loader import get_settings | ||
from pr_agent.tools.pr_reviewer import PRReviewer | ||
import asyncio | ||
|
||
async def run_action(): | ||
try: | ||
pull_request_id = os.environ.get("BITBUCKET_PR_ID", '') | ||
slug = os.environ.get("BITBUCKET_REPO_SLUG", '') | ||
workspace = os.environ.get("BITBUCKET_WORKSPACE", '') | ||
bearer_token = os.environ.get('BITBUCKET_BEARER_TOKEN', None) | ||
OPENAI_KEY = os.environ.get('OPENAI_API_KEY') or os.environ.get('OPENAI.KEY') | ||
OPENAI_ORG = os.environ.get('OPENAI_ORG') or os.environ.get('OPENAI.ORG') | ||
# Check if required environment variables are set | ||
if not bearer_token: | ||
print("BITBUCKET_BEARER_TOKEN not set") | ||
return | ||
|
||
if not OPENAI_KEY: | ||
print("OPENAI_KEY not set") | ||
return | ||
# Set the environment variables in the settings | ||
get_settings().set("BITBUCKET.BEARER_TOKEN", bearer_token) | ||
get_settings().set("OPENAI.KEY", OPENAI_KEY) | ||
if OPENAI_ORG: | ||
get_settings().set("OPENAI.ORG", OPENAI_ORG) | ||
if pull_request_id and slug and workspace: | ||
pr_url = f"https://bitbucket.org/{workspace}/{slug}/pull-requests/{pull_request_id}" | ||
await PRReviewer(pr_url).run() | ||
except Exception as e: | ||
print(f"An error occurred: {e}") | ||
if __name__ == "__main__": | ||
asyncio.run(run_action()) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please surround it code blocks: ```yaml
The environment variable should be in the yaml or run separately? if its separate, please use different code block.