1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-03-15 04:54:50 +00:00
bramw_baserow/docs/development/code-quality.md

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

54 lines
2.4 KiB
Markdown
Raw Normal View History

2020-07-13 19:10:24 +00:00
# Code quality
The quality of the code is very important. That is why we have linters, unit tests, API
2020-10-12 09:39:53 +00:00
docs, in-code docs, developer docs, modular code, and have put a lot of thought into the
2020-07-13 19:10:24 +00:00
underlying architecture of both the backend and the web-frontend.
## Running linters and tests
2021-03-11 14:07:51 +00:00
If you have the [development environment](./development-environment.md) up and running
2020-10-12 09:39:53 +00:00
you can easily run the linters. Both the backend and the web-frontend have `make` files
to help.
2020-07-13 19:10:24 +00:00
* `make format` (backend): auto format all python code using black.
* `make lint` (backend): all the python code will be checked with flake8 and black.
2020-07-13 19:10:24 +00:00
* `make eslint` (web-frontend): all the javascript code will be checked with eslint.
* `make stylelint` (web-frontend): all the scss code will be checked with stylelint.
## Running tests
There are also commands to easily run the tests.
* `make test` (backend): all the backend python code will be tested with pytest.
* `make jest` (web-frontend): all the web frontend code will be tested with jest.
## Continuous integration
2020-10-12 09:39:53 +00:00
To make sure nothing was missed during development we also have a continuous
2022-07-29 09:12:43 +00:00
integration pipeline that runs every time a branch is pushed. All the commands explained
2020-10-12 09:39:53 +00:00
above will execute in an isolated environment. In order to improve speed
they are separated by lint and test stages. It is not allowed to merge a branch if
2020-07-13 19:10:24 +00:00
one of these jobs fails.
2020-10-12 09:39:53 +00:00
The pipeline also has a build job. During this job
2020-07-13 19:10:24 +00:00
[plugin boilerplate](../plugins/boilerplate.md) Baserow will be installed as a
2021-03-11 14:07:51 +00:00
dependency to ensure that this still works.
2020-07-13 19:10:24 +00:00
### Run the GitLab runners locally
2020-10-12 09:39:53 +00:00
If you want to check if your job would succeed before pushing your branch then you can
2020-07-13 19:10:24 +00:00
also run them locally. Make sure that you have installed the GitLab runner by following
the steps on https://docs.gitlab.com/runner/install/. After that you should be able to
run the `gitlab-runner --help` command in your terminal. The jobs can be executed by
2021-03-11 14:07:51 +00:00
running the commands below.
2020-07-13 19:10:24 +00:00
> Make sure that you are in the root of the Baserow repository and that all changes
2020-10-12 09:39:53 +00:00
> have been committed because the runner checks out the current branch.
2020-07-13 19:10:24 +00:00
* `gitlab-runner exec docker web-frontend-eslint`
* `gitlab-runner exec docker web-frontend-stylelint`
* `gitlab-runner exec docker web-frontend-test`
* `gitlab-runner exec docker backend-flake8`
* `gitlab-runner exec docker backend-pytest`
* `gitlab-runner exec docker backend-setup`