Skip to content

Commit

Permalink
feat: Updated 3 files
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-nightly[bot] committed May 4, 2024
1 parent 89c4a1f commit d2ef91e
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
14 changes: 12 additions & 2 deletions sweepai/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
)
from sweepai.handlers.on_comment import on_comment
from sweepai.handlers.on_jira_ticket import handle_jira_ticket
from sweepai.handlers.on_linear_ticket import handle_linear_ticket
from sweepai.handlers.on_ticket import on_ticket
from sweepai.utils.buttons import (
check_button_activated,
Expand Down Expand Up @@ -333,13 +334,22 @@ def call_jira_ticket(*args, **kwargs):
thread.start()
call_jira_ticket(event=request_dict)

# Set up cronjob for this
@app.post("/linear")
def linear_webhook(
request_dict: dict = Body(...),
) -> None:
def call_linear_ticket(*args, **kwargs):
thread = threading.Thread(target=handle_linear_ticket, args=args, kwargs=kwargs)
thread.start()
call_linear_ticket(event=request_dict)

# Set up cronjob for this
@app.get("/update_sweep_prs_v2")
def update_sweep_prs_v2(repo_full_name: str, installation_id: int):
# Get a Github client
_, g = get_github_client(installation_id)

# Get the repository
# Get the repository
repo = g.get_repo(repo_full_name)
config = SweepConfig.get_config(repo)

Expand Down
6 changes: 4 additions & 2 deletions sweepai/config/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
ENV = "prod" if GITHUB_BOT_USERNAME != TEST_BOT_NAME else "dev"

PROGRESS_BASE_URL = os.environ.get(
"PROGRESS_BASE_URL", "https://progress.sweep.dev"
"PROGRESS_BASE_URL", "https://progress.sweep.dev"
).rstrip("/")

DISABLED_REPOS = os.environ.get("DISABLED_REPOS", "").split(",")
Expand Down Expand Up @@ -200,7 +200,9 @@
JIRA_API_TOKEN = os.environ.get("JIRA_API_TOKEN", None)
JIRA_URL = os.environ.get("JIRA_URL", None)

LINEAR_API_KEY = os.environ.get("LINEAR_API_KEY", None)

SLACK_API_KEY = os.environ.get("SLACK_API_KEY", None)

LICENSE_KEY = os.environ.get("LICENSE_KEY", None)
LICENSE_KEY = os.environ.get("LICENSE_KEY", None)
ALTERNATE_AWS = os.environ.get("ALTERNATE_AWS", "none").lower() == "true"
22 changes: 22 additions & 0 deletions sweepai/handlers/on_linear_ticket.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from typing import Dict

from sweepai.utils.event_logger import logger

def handle_linear_ticket(event: Dict):
"""Handle a Linear ticket event."""
logger.info(f"Received Linear ticket event: {event}")

# Extract relevant information from the event payload
ticket_id = event["data"]["id"]
ticket_title = event["data"]["title"]
ticket_description = event["data"]["description"]

# Check if the ticket has the "Sweep" label
has_sweep_label = any(label["name"] == "Sweep" for label in event["data"]["labels"]["nodes"])

if has_sweep_label:
# Invoke the Sweep workflow for the Linear ticket
logger.info(f"Linear ticket {ticket_id} has the Sweep label, invoking Sweep workflow")
# TODO: Implement Sweep workflow for Linear tickets
else:
logger.info(f"Linear ticket {ticket_id} does not have the Sweep label, ignoring")

0 comments on commit d2ef91e

Please sign in to comment.