## Description Added more details for running local setup. <img width="730" alt="Screenshot 2024-08-29 at 12 15 09 PM" src="https://github.com/user-attachments/assets/45c63a3a-119a-4d8d-9be3-0dd9232023d7"> Fixes #`35852` ## Automation /ok-to-test tags="@tag.Sanity" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/10766942068> > Commit: b8938d14a457ec99439d4df884089b3e0751df2f > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10766942068&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Sanity` > Spec: > <hr>Mon, 09 Sep 2024 05:29:13 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced the setup process for integration tests with interactive prompts, allowing users to choose options regarding local server setup and Docker container usage. - Improved user experience by providing clear choices and consequences, making the setup more configurable and informative. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
11 KiB
Running Client Codebase
Appsmith's client (UI/frontend) uses the ReactJS library and Typescript. The application also uses libraries like react-redux and redux-saga for workflows. We use VS Code Editor as our primary editor.
Pre-requisites:
On your development machine, please ensure that:
-
You have
dockerinstalled in your system. If not, please visit: https://docs.docker.com/get-docker/ -
You have
mkcertinstalled. Please visit: https://github.com/FiloSottile/mkcert#installation for details.-
For
mkcertto work with Firefox, you may need to install thenssutility. Details are in the link above. -
On Linux, you can easily install
mkcertusing the following commandcurl -s https://api.github.com/repos/FiloSottile/mkcert/releases/latest \ | grep "browser_download_url.*linux-amd64" \ | cut -d : -f 2,3 | tr -d \" \ | wget -i - -O mkcert chmod +x mkcert sudo mv mkcert /usr/local/bin
-
-
You have
envsubstinstalled. Usebrew install gettexton MacOS. Linux machines usually have this installed. -
You have cloned the repo in your local machine.
-
You have yarn installed as a global npm package, i.e.
npm install -g yarn. -
Create local HTTPS certificates
-
Run the following command from the project root.
cd app/client/docker && mkcert -install && mkcert "*.appsmith.com" && cd ../../..This command will create 2 files in the
docker/directory:_wildcard.appsmith.com-key.pem_wildcard.appsmith.com.pem
-
Add the domain
dev.appsmith.comto/etc/hosts.echo "127.0.0.1 dev.appsmith.com" | sudo tee -a /etc/hostsNote:
-
Please be careful when copying the above string as space between the IP and the string goes missing sometimes.
-
Please check that the string is copied properly
cat /etc/hosts | grep appsmith
-
-
-
Run cmd:
cp .env.example .env -
Run Backend server
-
The backend server can be run in two ways
- Use Appsmith's staging server hosted at
https://release.app.appsmith.comfor development purposes. (Recommended) - Run the backend server locally. To setup the backend server locally, refer here.
- Use Appsmith's staging server hosted at
-
Run the script
start-https.shto start the nginx container that will proxy the frontend requests to the backend server.-
Pass the server name as an argument to this command to use that server as backend.
cd app/client ./start-https.sh https://release.app.appsmith.com // uses Appsmith's staging backend server as backend for your local frontend code -
If you want to use the backend server running on your local, you do not need to pass a parameter when running
start-https.sh.
-
-
Steps to build & run the code:
-
Run
yarn install.Note:
-
On the Ubuntu Linux platform, please run the following cmd before step 2 below:
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
-
-
Run
yarn start.- 🎉 Your Appsmith client is now running on https://dev.appsmith.com.
- This URL must be opened with https and not have port 3000 in it.
-
If yarn start throws mismatch node version error
-
This error occurs because the node version is not compatible with the app environment. In this case, Node version manager can be used, allowing multiple node versions in different projects.
-
Check below for installation and usage details:
-
Running Tests on Client
Integration Tests
Pre-flight checks
- The base URL can be updated on a temporary basis in the
cypress.config.tsfile based on the configuration you used for running the codebase locally. By default, it’shttps://dev.appsmith.com. - If you wish to run Git test cases locally, please add
APPSMITH_GIT_ROOT=./container-volumes/git-storageto the folderapp/server/.envand run the server locally instead of via Docker container.
Setup Cypress configurations
To setup the configurations for running integration tests via Cypress, use these commands below,
cd app/client/cypress/scripts
yarn install
yarn run setup
Prompt:
Do you wish to continue without setting up the local server with docker? (yes/no):
Options:
no: Selecting "no" will trigger the setup of a local server using Docker with theappsmith-ce:releaseimage.yes: Selecting "yes" will skip the local server setup process.
Prompt:
https://dev.appsmith.com is not accessible. Do you wish to continue without setting it up? (yes/no):
Options:
no: Simply close the process.yes: Continue on the process for next stage
Prompt:
TED (TestEventDriver) is not running. Do you want to pull & run the latest Docker container for TED (TestEventDriver)? (yes/no):
Options:
no: It will not create TED setup in local machine.yes: Download the TED image and run the image for test purposes.
Running Cypress tests locally
To run a specific test file in headless fashion, use the following command:
cd app/client/
yarn install
npx cypress run --spec <spec path> --browser chrome
To open Cypress in the browser and run the tests visually
cd app/client/
yarn install
npx cypress open
-
Running appsmith backend server locally
-
There are two configurations available for running the backend server locally.
-
Running the server from source code.
- Refer to documentation for setting up backend to do this.
-
Running the server from a docker image. There are two ways to get a backend docker image
-
Pull latest release branch docker image from Appsmith's public docker hub account.
docker rm appsmith; cd ~/appsmith; rm -rf stacks; docker pull appsmith/appsmith-ce docker run -d --name appsmith -p 8000:80 appsmith/appsmith-ce:latest; docker logs -f appsmith; ./start-https.sh http://localhost:8000 // if nginx is installed locally ./start-https.sh http://host.docker.internal:8000 // if nginx is running on docker -
Create docker image from local source code
cd ~/appsmith ./scripts/local_testing.sh -l # This builds a fat docker image of local backend and frontend # The docker image created above will show up in your docker desktop application docker run -d --name appsmith -p 8000:80 appsmith/appsmith-ce:local-testing; ./start-https.sh http://localhost:8000 // if nginx is installed locally ./start-https.sh http://host.docker.internal:8000 // if nginx is running on docker
-
-
-
-
Please check out our Testing Contribution guide for more details on setting up & troubleshooting Cypress runs on your machine.
Running Unit Tests
-
To run the Jest unit tests, run:
cd app/client yarn run test:unit -
To run a single jest test,
cd app/client # Run either command below to run a test npx jest <file_path/file_name> # or yarn jest src/widgets/<filepath>/<filename>.test.ts --silent=false -
To run a single jest test in watch mode,
npx jest --watch <file_path/file_name>
Windows WSL2 Setup
Before you follow the instructions above, make sure to check the following steps:
- You have WSL2 setup in your machine. If not, please visit: https://docs.microsoft.com/en-us/windows/wsl/install-win10.
- You have Node.js installed on the WSL Distro.
- You have Docker Desktop installed with the WSL2 backend. If not, please visit: https://docs.docker.com/docker-for-windows/wsl/.
In the above Docker Desktop Setup instructions, make sure to:
- Set WSL Distro to run in WSL2 mode.
- Enable integration with the WSL Distro in Docker Desktop.
- Install Remote-WSL extension in VSCode.
Make sure to Clone the Repo in the WSL file system instead of the Windows file system.
And finally, you can open the folder in VSCode with WSL by following the instructions in Docker Desktop Setup, or by,
- Clicking on the Green button on the Bottom Left corner in VSCode.
- Selecting Open Folder in WSL and navigating to the folder in WSL.
After this, you can continue Setting up from here.
Troubleshooting
I am on WSL and can't reach dev.appsmith.com
-
You will need to add
dev.appsmith.comto Windows'C:\Windows\System32\drivers\etc\hostsinstead of/etc/hosts. Alternately, you can install a desktop environment in WSL to opendev.appsmith.comfrom a browser in WSL.127.0.0.1 dev.appsmith.com -
WSL network with windows can be brittle; make sure you can reach http://127.0.0.1:3000 from windows. If not, restarting wsl usually resolves the issue.
Docker container doesn't work
-
You can check logs with
docker logs wildcard-nginx. -
If you see
Address already in useerrors, look for the service running on port 80 and 443 withlsof -i tcp:80,443 | grep LISTENand stop the process.Example: Some Linux distros have
apache2listening on 80. Stop them withsudo systemctl stop apache2
I want to add dev.appsmith.com conf to my local Nginx without Docker.
- Copy
app/client/docker/templates/nginx-app.conf.templateover to your nginx sites directory. - You can remove or replace values for all the
sub_filter. None of those properties are required. - Change
proxy_passvalue for client from__APPSMITH_CLIENT_PROXY_PASS__tohttp://localhost:3000 - Replace all occurrences of
__APPSMITH_SERVER_PROXY_PASS__withhttp://localhost:8080(or the server you want to point to) - Generate the certificates manually via
mkcert. - Change the value of the certificate location for keys
ssl_certificate&ssl_certificate_keyto the place where these certificates were generated. - Reload nginx! 🎉
I still need help!
Please open a Github issue or join our discord server.