Skip to content

Commit

Permalink
Merge main into sweep/pre-commit-github-action
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-nightly[bot] authored Dec 27, 2023
2 parents 15e40e1 + 09e3b4b commit eaffde6
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 3 deletions.
22 changes: 20 additions & 2 deletions docs/pages/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ You can use Sweep to create pull requests - a set of code changes that can be in
### Creating Pull Requests from an Issue
First, you can assign Sweep a task like squashing an old bug in your backlog. To do this, create or use an existing GitHub issue. This issue should be detailed enough for a junior engineer (Sweep) to find the correct files and make the appropriate code changes.

### Assigning Sweep to an Existing Issue
#### Assigning Sweep to an Existing Issue
To have Sweep create a PR for an existing issue, label the issue with the purple "Sweep" label (added to your repository when Sweep is installed).
<div align="center"><Bleed><img src="/assets/tutorial/label_issue.gif" alt="How to label a GitHub issue with Sweep" /></Bleed></div>

### Assigning Sweep to a New Issue
#### Assigning Sweep to a New Issue
To have Sweep create a PR for a new issue, create a new issue with the title `"Sweep: [title of issue]"`.
<div align="center"><Bleed><img src="/assets/tutorial/create_issue.gif" alt="How to create a new GitHub issue with Sweep" /></Bleed></div>

Expand All @@ -46,6 +46,24 @@ For simpler problems, providing a single line and a reference file should suffic

- Description: `“Use the file main/github_utils.py as a reference”`

### Improving Sweep's PRs
Sweep won’t always get it right, as language models aren’t as reliable for as we’d like them to be. <br/>
Sweep has a couple of ways to deal with this though:

#### Running your GitHub Actions
Sweep defines and runs GitHub actions for you. After the PR is created, Sweep will work asynchronously until it fixes your CI. At this point, you can either try to fix it yourself or wait until Sweep completes it.

### Having Sweep edit an existing PR
If you want Sweep to make an edit to it's previous change, you can leave a comment on it's PR. Sweep supports two types of comments - slow and fast.

#### Fast Comments
You can create a fast comment by making a review comment. This comment will only modify the file that’s been commented on.
<div align="center"><Bleed><img src="/assets/tutorial/pr_comment.gif" alt="Creating a review comment on GitHub for Sweep to handle" /></Bleed></div>

#### Slow Comments
You can create a slow comment by making an issue comment. This comment can perform codebase wide changes, and will spin up a new dashboard.
<div align="center"><Bleed><img src="/assets/tutorial/issue_comment.gif" alt="Creating a review comment on GitHub for Sweep to handle" /></Bleed></div>

## 🤝 Contributing

Contributions are welcome and greatly appreciated! For detailed guidelines on how to contribute, please see the [CONTRIBUTING.md](CONTRIBUTING.md) file.
Expand Down
Binary file added docs/public/assets/tutorial/issue_comment.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/public/assets/tutorial/pr_comment.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion self_deploy/app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,4 @@ description: Self-hosted Sweep, an AI-powered junior developer
# Default: true
public: true

# redirect_url: https://github.com/sweepai/sweep/blob/main/docs/installation.md
# redirect_url: https://docs.sweep.dev/#-how-to-use-sweep
26 changes: 26 additions & 0 deletions sweepai/api_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import unittest
import unittest.mock

from sweepai import api


class TestAPI(unittest.TestCase):
def setUp(self):
self.mock_api = unittest.mock.create_autospec(api)

def test_webhook(self):
self.mock_api.webhook.return_value = {"success": True}
result = self.mock_api.webhook()
self.assertEqual(result, {"success": True})
self.mock_api.webhook.assert_called_once()

def test_home(self):
self.mock_api.home.return_value = "<h2>Sweep Webhook is up and running! To get started, copy the URL into the GitHub App settings' webhook field.</h2>"
result = self.mock_api.home()
self.assertEqual(result, "<h2>Sweep Webhook is up and running! To get started, copy the URL into the GitHub App settings' webhook field.</h2>")
self.mock_api.home.assert_called_once()

# Add more test methods as needed for each function in api.py

if __name__ == '__main__':
unittest.main()
35 changes: 35 additions & 0 deletions sweepai/handlers/stack_pr_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import unittest
import unittest.mock

from sweepai.handlers import stack_pr


class TestStackPR(unittest.TestCase):
def setUp(self):
self.mock_stack_pr = unittest.mock.create_autospec(stack_pr)

def test_stack_pr(self):
self.mock_stack_pr.stack_pr.return_value = {"success": True}
result = self.mock_stack_pr.stack_pr(
request="Add type hints to create_payment_messages in on_ticket.py.",
pr_number=2646,
username="kevinlu1248",
repo_full_name="sweepai/sweep",
installation_id=36855882,
tracking_id="test_stack_pr",
)
self.assertEqual(result, {"success": True})
self.mock_stack_pr.stack_pr.assert_called_once_with(
request="Add type hints to create_payment_messages in on_ticket.py.",
pr_number=2646,
username="kevinlu1248",
repo_full_name="sweepai/sweep",
installation_id=36855882,
tracking_id="test_stack_pr",
)

# Add more test methods as needed for each function in stack_pr.py


if __name__ == '__main__':
unittest.main()

0 comments on commit eaffde6

Please sign in to comment.