sweepai / sweep

Sweep: open-source AI-powered Software Developer for small features and bug fixes.
https://sweep.dev
Other
7.45k stars 427 forks source link

Sweep: refactor our shell scripts #2749

Closed kevinlu1248 closed 10 months ago

kevinlu1248 commented 10 months ago
Checklist - [X] Modify `bin/server/install_full.sh` ✓ https://github.com/sweepai/sweep/commit/dc2573c4b36664dddee214310362a58167f3f797 [Edit](https://github.com/sweepai/sweep/edit/sweep/refactor-shell-scripts/bin/server/install_full.sh#L1-L50) - [X] Running GitHub Actions for `bin/server/install_full.sh` ✓ [Edit](https://github.com/sweepai/sweep/edit/sweep/refactor-shell-scripts/bin/server/install_full.sh#L1-L50) - [X] Modify `bin/server/install_light.sh` ✓ https://github.com/sweepai/sweep/commit/283ae48dacf121528a4057afb66b4d47e6f8b574 [Edit](https://github.com/sweepai/sweep/edit/sweep/refactor-shell-scripts/bin/server/install_light.sh#L1-L50) - [X] Running GitHub Actions for `bin/server/install_light.sh` ✓ [Edit](https://github.com/sweepai/sweep/edit/sweep/refactor-shell-scripts/bin/server/install_light.sh#L1-L50) - [X] Modify `bin/server/run.sh` ✓ https://github.com/sweepai/sweep/commit/28fd20ea54cd45de11058a7bd244d8e854669a1e [Edit](https://github.com/sweepai/sweep/edit/sweep/refactor-shell-scripts/bin/server/run.sh#L1-L50) - [X] Running GitHub Actions for `bin/server/run.sh` ✓ [Edit](https://github.com/sweepai/sweep/edit/sweep/refactor-shell-scripts/bin/server/run.sh#L1-L50) ![Flowchart](https://raw.githubusercontent.com/sweepai/sweep/sweep/assets/ee796a6f17fa2cfa5188556898590173500f6d857fdb5173957bf7cc598a18f7_2749_flowchart.svg)
sweep-nightly[bot] commented 10 months ago

Here's the PR! https://github.com/sweepai/sweep/pull/2751. See Sweep's process at dashboard.

💎 Sweep Pro: I'm using GPT-4. You have unlimited GPT-4 tickets. (tracking ID: e40dd32657)

Actions (click)

Sandbox Execution ✓

Here are the sandbox execution logs prior to making any changes:

Sandbox logs for 852e0da
Checking bin/server/install_full.sh for syntax errors... ✅ bin/server/install_full.sh has no syntax errors! 1/1 ✓
Checking bin/server/install_full.sh for syntax errors...
✅ bin/server/install_full.sh has no syntax errors!

Sandbox passed on the latest main, so sandbox checks will be enabled for this issue.


Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I think are relevant in decreasing order of relevance (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/sweepai/sweep/blob/852e0dae298492456dc042112b3c349baf396366/docs/pages/blogs/refactor-python.mdx#L15-L30 https://github.com/sweepai/sweep/blob/852e0dae298492456dc042112b3c349baf396366/docs/pages/usage/extra-self-host.mdx#L60-L65 https://github.com/sweepai/sweep/blob/852e0dae298492456dc042112b3c349baf396366/README.md#L30-L45 https://github.com/sweepai/sweep/blob/852e0dae298492456dc042112b3c349baf396366/tests/archive/test_modal_sandbox.py#L32-L61 https://github.com/sweepai/sweep/blob/852e0dae298492456dc042112b3c349baf396366/docs/pages/blogs/super-linter.mdx#L180-L195 https://github.com/sweepai/sweep/blob/852e0dae298492456dc042112b3c349baf396366/docs/pages/blogs/refactor-python.mdx#L150-L165 https://github.com/sweepai/sweep/blob/852e0dae298492456dc042112b3c349baf396366/bin/server/install_full.sh#L45-L49

Step 2: ⌨️ Coding

--- 
+++ 
@@ -7,12 +7,22 @@
 }

 run_until_success "sudo apt update"
-run_until_success "sudo apt install -y gcc g++ curl"
-run_until_success "sudo apt-get update"
-run_until_success "sudo apt-get install -y redis build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python3-openssl git"
+run_until_success "sudo apt install -y gcc g++ curl redis build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python3-openssl git"
+
 run_until_success "sudo systemctl stop redis"
 run_until_success "snap install ngrok"
-sudo apt install -y apt-transport-https ca-certificates curl software-properties-common -y && curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - && sudo add-apt-repository -y "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" && sudo apt update -y && sudo apt install docker-ce -y && sudo systemctl enable docker && sudo systemctl start docker && sudo usermod -aG docker ${USER}
+install_docker() {
+    sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
+    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
+    sudo add-apt-repository -y "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
+    sudo apt update
+    sudo apt install docker-ce
+    sudo systemctl enable docker
+    sudo systemctl start docker
+    sudo usermod -aG docker ${USER}
+}
+
+install_docker

 curl https://pyenv.run | bash
 {
@@ -34,9 +44,11 @@
 cd ~/sweep
 pyenv local 3.11.5

-# Install poetry
+# Install poetry using the official installer.
 curl -sSL https://install.python-poetry.org | python3 -
+# Set the poetry environment to use the installed Python version.
 poetry env use /root/.pyenv/versions/3.11.5/bin/python
+# Start the poetry shell.
 poetry shell

 # Install with this command, pressing only enter when prompted:

Ran GitHub Actions for dc2573c4b36664dddee214310362a58167f3f797:
• black:
• Vercel Preview Comments:

--- 
+++ 
@@ -1,9 +1,20 @@
-git clone http://github.com/sweepai/sweep
-sudo apt install docker.io -y
-sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
+# Clone the sweep repository
+git_repo="http://github.com/sweepai/sweep"
+git clone ${git_repo}
+
+# Install Docker
+docker_package="docker.io"
+sudo apt install ${docker_package} -y
+# Install Docker Compose
+docker_compose_version="1.29.2"
+sudo curl -L "https://github.com/docker/compose/releases/download/${docker_compose_version}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
+# Make Docker Compose executable
 sudo chmod +x /usr/local/bin/docker-compose
+# Navigate to the sweep directory
 cd sweep
+# Remind the user to configure ngrok and how to proceed after setup
 echo "Configure ngrok: https://dashboard.ngrok.com/get-started/setup"
-echo "Then, run docker build/run commands."
+echo "Then, use Docker to build and run the project."

+# The following line is unnecessary as we're already executing `install_light.sh`
 # curl -sSL https://raw.githubusercontent.com/sweepai/sweep/main/bin/server/install_light.sh | bash

Ran GitHub Actions for 283ae48dacf121528a4057afb66b4d47e6f8b574:
• black:
• Vercel Preview Comments:

--- 
+++ 
@@ -1 +1,6 @@
-docker run --env-file .env -p 8080:8080 -d sweepai/sweep:latest
+# Run the Docker container using environment variables and port mapping
+env_file='.env'
+host_port=8080
+container_port=8080
+image_name='sweepai/sweep:latest'
+docker run --env-file ${env_file} -p ${host_port}:${container_port} -d ${image_name}

Ran GitHub Actions for 28fd20ea54cd45de11058a7bd244d8e854669a1e:
• black:
• Vercel Preview Comments:


Step 3: 🔁 Code Review

I have finished reviewing the code for completeness. I did not find errors for sweep/refactor-shell-scripts.


🎉 Latest improvements to Sweep:


💡 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