- OS: Linux
- Python: python3 (python 3.8 is recommended)
- Mysql: mysql Ver 14.14 Distrib 5.7.24, for Linux (x86_64) (if needed)
- Redis: Redis server v=5.0.3
- Nginx: nginx version: nginx/1.13.12
- Docker: Docker version 18.09.0
- Docker-compose: docker-compose version 1.23.1
- Supervisord: v3.3.1
- Install
virtualenv
pip install virtualenv
- Create virtual environment:
virtualenv -p python3 venv
- Active and install dependencies:
source ./venv/bin/activate
cd project_folder && make deps
cd project_folder # if needed
make init # to copy secret files
- Create database and re-config settings, env file. Example:
# project_folder/settings/development.py
from settings.common import *
# SQLAlchemy override
SQLALCHEMY_DATABASE_URI = 'mysql://test:123456@localhost:3306/database_test'
# Redis override
REDIS_DB = 0
REDIS_HOST = 'localhost'
REDIS_PORT = 6379
REDIS_TTL = 60
# project_folder/.env
DYNACONF_SETTINGS=settings.development
- Make migrations and migrate. Example:
cd project_folder # if needed
export APP_ENV=development
make migrate # if needed
Fix if error migrate: https://stackoverflow.com/questions/32311366/alembic-util-command-error-cant-find-identifier
- Add host if environment is development
cd project_folder # if needed
python manager.py
cd project_folder # if needed
docker-compose up -d --build
- Auto format code with black and isort
make auto-lint
Copy settings file and edit the value according to the unittest
environment:
cd project_folder # if needed
cp settings/unittest.py.orig settings/unittest.py
- Re-config settings, env file. Example:
# microservices/settings/unittest.py
from settings.common import *
# SQLAlchemy override
SQLALCHEMY_DATABASE_URI = 'sqlite:////tmp/test.db'
# Redis settings
REDIS_HOST = 'redis'
REDIS_PORT = 6379
REDIS_DB = 0
REDIS_TTL = 60
# microservices/.env
DYNACONF_SETTINGS=settings.unittest
Run all test case
make test
Check style with flake8:
make lint
Coverage all test suites:
make coverage
Coverage with html view
coverage html