VSCode Setup
This guide walks you through a first time VScode setup for Baserow for developers. It
will ensure you can run and debug all tests and also enable all the relevant linters and
automatic style fixers to make your life as easy as possible.
This guide assumes you have a basic understanding of git, python, virtualenvs,
postgres and command line tools.
- First checkout a fresh copy of Baserow:
git clone git@gitlab.com:baserow/baserow.git
(or your personal fork of the project)
cd baserow
./config/vscode/apply_standard_baserow_vscode_config.sh
- Type
Y
and hit enter to apply the standard Baserow config
- Open VSCode and on the “Welcome to VSCode” screen click the “Open” button
and open the baserow folder you cloned above.
- Make sure you have installed / enabled the Python VSCode plugin.
- Now we will create python virtualenv and configure VSCode to use it to run tests
and linters:
- Choose a location for your virtualenv, it is recommended to store it separately
from the baserow source-code folder so VSCode does not search nor index it.
- Create the virtualenv:
mkdir $HOME/.virtualenvs; python3 -m venv $HOME/.virtualenvs/baserow
or
$HOME/.virtualenvs; virtualenv -p python $HOME/.virtualenvs/baserow
- Activate the virtualenv:
source $HOME/.virtualenvs/baserow/bin/activate
(could differ depending on your shell)
- Run
which pip
and ensure the output of this command is now pointing into the
bin in your new virtualenv
- Change to the Baserow source directory:
cd path/to/your/baserow
- Install all the Baserow python requirements into your virtualenv:
pip install -r backend/requirements/dev.txt -r backend/requirements/base.txt
- Then you will most likely need to select it as default interpreter for the project:
- Type: Ctrl + Shift + P or open the command palette
- Type: Python: select interpreter
- Find and select your virtualenvs
bin/python
executable
- If do not see the python tests in the testing menu:
- Type: Ctrl + Shift + P or open the command palette
- Type: Python: Configure Tests
- Install and get a postgresql database running locally:
- https://www.postgresql.org/docs/11/tutorial-install.html
- Change the default postgres port otherwise it will clash when running with
Baserow (the default VSCode config in the repo assumes your testing db is
running on 5430)
- https://stackoverflow.com/questions/187438/change-pgsql-port
- Create a baserow user called
baserow
with the password baserow
and give them
permission to create databases
-
https://medium.com/coding-blocks/creating-user-database-and-adding-access-on-postgresql-8bfcd2f4a91e
CREATE USER baserow WITH ENCRYPTED PASSWORD 'baserow';
ALTER USER baserow CREATEDB;
- You might also have to
pip install psycopg2-binary
or
sudo apt install libpq-dev
- Now you should be able to run the backend python tests from the testing menu, try
run
backend/tests/baserow/core/test_core_models.py
for instance.
- Now lets set up your frontend dev by changing directory to
baserow/web-frontend
- Install nvm to install the correct version of
node
.
In launch.json
the runtimeVersion
is set to v16.15.0
, so install this specific
version using the command: nvm install v16.15.0
. Then enabled it with the command: nvm use v16.15.0
- Install
yarn
globally: npm install -g yarn
- Now run
yarn install
to install dependencies.
- Select “Trust Project” if you see an VSCode popup after running yarn install
- If you do not see Jest tests in the testing menu:
- Type: Ctrl + Shift + P or open the command palette
- Type: Jest: Start All Runners
- Confirm you can run a web-frontend unit test from vscode
Recommended Plugins
You can use the VSC Export & Import to install what is inside config/vscode/vsc-extensions.txt
.
Otherwise, you can manually install:
- Python
- Volar
- Eslint
- Gitlab Workflow
- Gitlens
- Jest
- SCSS Formatter
- Stylelint
- Mypy
- Docker
- Coverage Gutters