skygate / skyexpo-matchmaking

The matchmaking app for skyexpo AI 2020
http://skyexpo.hal.skygate.io/
0 stars 0 forks source link

skyexpo-matchmaking

The matchmaking app for skyexpo AI 2020.

wemake-python-styleguide Build Status

Prerequisites

You need:

Development

Development with Docker

To start development server inside docker you will need to run:

docker-compose build
docker-compose run --rm web python manage.py migrate
docker-compose up

Secret settings

We store secret settings in config/.env file. Before running a project, you will need to copy file config/.env.template to config/.env:

cp ./backend/config/.env.template ./backend/config/.env

Then you can set up your secret variables there.

Documentation

API documentation is available at localhost:8000/redoc.

Staging

Staging is available at: skyexpo.hal.skygate.io.

pre-commit hooks

We use pre-commit hooks to run all checks locally before pushing a commit to CI. It prevents you from pushing broken code to the repository.

To install pre-commit hooks you will need to run:

docker-compose run --rm web poetry shell
pre-commit install

Django shell

Thanks to django-extensions, ipython and jupyter notebooks we can easily leverage Python interactive interpreter to debug our code live.

To do so run ./manage.py shell_plus --notebook. Then copy generated link and paste into browser.

mypy

Running mypy is required before any commit:

This will eliminate a lot of possible TypeError and other issues. However, this will not make code 100% safe from errors. So, both the testing and review process are still required.

mypy is configured via setup.cfg. Read the docs for more information.

We also use django-stubs to type django internals.

There are three common ways to execute mypy:

  1. in terminal using docker containers (slower way):

docker-compose exec web bash -c ": "${PYTHONPATH:=''}"; PYTHONPATH="$PYTHONPATH:$PWD" mypy server"

  1. in terminal locally (much faster):

    • python3.7 -m pip install poetry
    • poetry install
    • poetry shell
    • PYTHONPATH="$PWD" mypy server
  2. If you use PyCharm we highly recommend installing mypy-PyCharm-plugin. You must go through steps in point 2. Then in mypy-PyCharm-plugin go to Configure plugin and set Mypy command to:

cd /PycharmProjectsDir/v1-video/backend; PYTHONPATH="$PYTHONPATH:$PWD" /PoetryVirtualEnvsDir/virtualenvs/v1-video-py3.7/bin/mypy server.

E.g:

cd /Users/marcinjosinski/PycharmProjects/v1-video/backend; PYTHONPATH="$PYTHONPATH:$PWD" /Users/marcinjosinski/Library/Caches/pypoetry/virtualenvs/v1-video-py3.7/bin/mypy server

Testing

We use mypy for optional static typing. We run tests with pytest framework.

We use a lot of pytest plugins that enchance our development experience. List of these plugins is available inside pyproject.toml file.

To run tests you can use docker-compose run --rm web pytest ..

Linters

This project uses wemake-python-styleguide which is a flake8 based plugin. And it is also the strictest and most opinionated python linter ever. See wemake-python-styleguide docs.

Production

To run production you will need to to execute:

docker-compose -f docker-compose.yml -f docker-compose.prod.yml up --build

Secret settings in production

We do not store our secret settings inside our source code. All sensible settings are stored in config/.env file, which is not tracked by the version control.

We store them as secret environment variables in our Drone CI Then we use dump-env to dump variables from both environment and .env file template. Then, this file is copied inside docker image and when this image is built - everything is ready for production. Check out dump-env project to read more.

Useful links

Authors