Open bartbot opened 7 months ago
d1438e7478
)[!TIP] I'll email you at gptaas.bootstrap@gmail.com when I complete this pull request!
Here are the GitHub Actions logs prior to making any changes:
3408bf0
Checking sweepai/config/server.py for syntax errors... ✅ sweepai/config/server.py has no syntax errors!
1/1 ✓Checking sweepai/config/server.py for syntax errors... ✅ sweepai/config/server.py has no syntax errors!
Sandbox passed on the latest main
, so sandbox checks will be enabled for this issue.
I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.
sweepai/config/gitlab_oauth.py
✓ https://github.com/bartbot/sweep/commit/a95430dc12d96b8d156b0e71277478fb21adace8 Edit
Create sweepai/config/gitlab_oauth.py with contents:
• Create a new Python file named gitlab_oauth.py in the sweepai/config directory.
• Define a class `GitLabOAuthConfig` with class variables to store GitLab OAuth settings such as `APP_ID`, `APP_SECRET`, and `REDIRECT_URI`.
• Initialize these variables with default values or environment variables, similar to how GitHub settings are currently handled in server.py.
• Import this class in the __init__.py file within the sweepai/config directory to make it available for import in other parts of the application.
sweepai/config/gitlab_oauth.py
✓ Edit
Check sweepai/config/gitlab_oauth.py with contents:
Ran GitHub Actions for a95430dc12d96b8d156b0e71277478fb21adace8:
• black: ✓
sweepai/config/server.py
✓ https://github.com/bartbot/sweep/commit/075527a438106f33364782830c157ff393c40262 Edit
Modify sweepai/config/server.py with contents:
• Remove the GitHub-specific environment variable settings related to `GITHUB_APP_PEM`, `GITHUB_APP_ID`, `GITHUB_BOT_USERNAME`, and any other GitHub-specific settings.
• Import the `GitLabOAuthConfig` class from the newly created gitlab_oauth.py file.
• Replace the removed GitHub environment variables with the GitLab OAuth settings by accessing the class variables of `GitLabOAuthConfig`.
• Ensure that the GitLab OAuth settings are used throughout the server.py file wherever the GitHub settings were previously used.
• Update any comments or documentation strings in the server.py file to reflect the use of GitLab OAuth settings.
--- +++ @@ -1,4 +1,5 @@ -import base64 +from sweepai.config.gitlab_oauth import GitLabOAuthConfig + import os from dotenv import load_dotenv @@ -7,17 +8,6 @@ logger.print = logger.info load_dotenv(dotenv_path=".env") - -os.environ["GITHUB_APP_PEM"] = os.environ.get("GITHUB_APP_PEM") or base64.b64decode( - os.environ.get("GITHUB_APP_PEM_BASE64", "") -).decode("utf-8") - -if os.environ["GITHUB_APP_PEM"]: - os.environ["GITHUB_APP_ID"] = ( - (os.environ.get("GITHUB_APP_ID") or os.environ.get("APP_ID")) - .replace("\\n", "\n") - .strip('"') - ) os.environ["TRANSFORMERS_CACHE"] = os.environ.get( "TRANSFORMERS_CACHE", "/tmp/cache/model" @@ -57,41 +47,12 @@ SWEEP_HEALTH_URL = os.environ.get("SWEEP_HEALTH_URL") DISCORD_STATUS_WEBHOOK_URL = os.environ.get("DISCORD_STATUS_WEBHOOK_URL") -# goes under Modal 'github' secret name -GITHUB_APP_ID = os.environ.get("GITHUB_APP_ID", os.environ.get("APP_ID")) -# deprecated: old logic transfer so upstream can use this -if GITHUB_APP_ID is None: - if ENV == "prod": - GITHUB_APP_ID = "307814" - elif ENV == "dev": - GITHUB_APP_ID = "324098" - elif ENV == "staging": - GITHUB_APP_ID = "327588" -GITHUB_BOT_USERNAME = os.environ.get("GITHUB_BOT_USERNAME") - -# deprecated: left to support old logic -if not GITHUB_BOT_USERNAME: - if ENV == "prod": - GITHUB_BOT_USERNAME = "sweep-ai[bot]" - elif ENV == "dev": - GITHUB_BOT_USERNAME = "sweep-nightly[bot]" - elif ENV == "staging": - GITHUB_BOT_USERNAME = "sweep-canary[bot]" -elif not GITHUB_BOT_USERNAME.endswith("[bot]"): - GITHUB_BOT_USERNAME = GITHUB_BOT_USERNAME + "[bot]" +# GitLab OAuth settings +GITLAB_APP_ID = GitLabOAuthConfig.APP_ID +GITLAB_APP_SECRET = GitLabOAuthConfig.APP_SECRET +GITLAB_REDIRECT_URI = GitLabOAuthConfig.REDIRECT_URI GITHUB_LABEL_NAME = os.environ.get("GITHUB_LABEL_NAME", "sweep") -GITHUB_LABEL_COLOR = os.environ.get("GITHUB_LABEL_COLOR", "9400D3") -GITHUB_LABEL_DESCRIPTION = os.environ.get( - "GITHUB_LABEL_DESCRIPTION", "Sweep your software chores" -) -GITHUB_APP_PEM = os.environ.get("GITHUB_APP_PEM") -GITHUB_APP_PEM = GITHUB_APP_PEM or os.environ.get("PRIVATE_KEY") -if GITHUB_APP_PEM is not None: - GITHUB_APP_PEM = GITHUB_APP_PEM.strip(' \n"') # Remove whitespace and quotes - GITHUB_APP_PEM = GITHUB_APP_PEM.replace("\\n", "\n") - -GITHUB_CONFIG_BRANCH = os.environ.get("GITHUB_CONFIG_BRANCH", "sweep/add-sweep-config") GITHUB_DEFAULT_CONFIG = os.environ.get( "GITHUB_DEFAULT_CONFIG", """# Sweep AI turns bugs & feature requests into code changes (https://sweep.dev) @@ -104,8 +65,8 @@ # This is the branch that Sweep will develop from and make pull requests to. Most people use 'main' or 'master' but some users also use 'dev' or 'staging'. branch: 'main' -# By default Sweep will read the logs and outputs from your existing Github Actions. To disable this, set this to false. -gha_enabled: True +# By default Sweep will read the logs and outputs from your existing GitLab CI/CD pipelines. To disable this, set this to false. +gitlab_ci_enabled: True # This is the description of your project. It will be used by sweep when creating PRs. You can tell Sweep what's unique about your project, what frameworks you use, or anything else you want. # @@ -193,10 +154,10 @@ MULTI_REGION_CONFIG = MULTI_REGION_CONFIG.strip("'").replace("\\n", "\n") MULTI_REGION_CONFIG = [item.split(",") for item in MULTI_REGION_CONFIG.split("\n")] -WHITELISTED_USERS = os.environ.get("WHITELISTED_USERS", None) -if WHITELISTED_USERS: - WHITELISTED_USERS = WHITELISTED_USERS.split(",") - WHITELISTED_USERS.append(GITHUB_BOT_USERNAME) +WHITELISTED_USERS = os.environ.get("WHITELISTED_USERS", "").split(",") + +DEBUG: bool = True +ENV = os.environ.get("ENV", "dev") DEFAULT_GPT4_32K_MODEL = os.environ.get("DEFAULT_GPT4_32K_MODEL", "gpt-4-1106-preview") DEFAULT_GPT35_MODEL = os.environ.get("DEFAULT_GPT35_MODEL", "gpt-3.5-turbo-1106")
sweepai/config/server.py
✓ Edit
Check sweepai/config/server.py with contents:
Ran GitHub Actions for 075527a438106f33364782830c157ff393c40262:
• black: ✓
I have finished reviewing the code for completeness. I did not find errors for sweep/update_sweepaiconfigserverpy_to_leverage
.
💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request. Join Our Discord
This is an automated message generated by Sweep AI.
Sorry, Sweep could not find any appropriate files to edit to address this issue. If this is a mistake, please provide more context and Sweep will retry!
@bartbot, please edit the issue description to include more details about this issue.
For bonus GPT-4 tickets, please report this bug on Discord (tracking ID: 0d92befc9c
).
💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request.
Details
Update sweepai/config/server.py to leverage the GitLab Oauth 2.0 identity provider API instead of GitHub environment variables for GitHub Applications.
You can refer to GitLab's Oauth 2.0 identity provider documentation here: https://docs.gitlab.com/ee/api/oauth2.html
Checklist
- [X] Create `sweepai/config/gitlab_oauth.py` ✓ https://github.com/bartbot/sweep/commit/a95430dc12d96b8d156b0e71277478fb21adace8 [Edit](https://github.com/bartbot/sweep/edit/sweep/update_sweepaiconfigserverpy_to_leverage/sweepai/config/gitlab_oauth.py) - [X] Running GitHub Actions for `sweepai/config/gitlab_oauth.py` ✓ [Edit](https://github.com/bartbot/sweep/edit/sweep/update_sweepaiconfigserverpy_to_leverage/sweepai/config/gitlab_oauth.py) - [X] Modify `sweepai/config/server.py` ✓ https://github.com/bartbot/sweep/commit/075527a438106f33364782830c157ff393c40262 [Edit](https://github.com/bartbot/sweep/edit/sweep/update_sweepaiconfigserverpy_to_leverage/sweepai/config/server.py#L10-L90) - [X] Running GitHub Actions for `sweepai/config/server.py` ✓ [Edit](https://github.com/bartbot/sweep/edit/sweep/update_sweepaiconfigserverpy_to_leverage/sweepai/config/server.py#L10-L90)