Contributing
Branch workflow
Warning
READ BEFORE CREATE A BRANCH OR OPEN A PR/MR
- We use Github Glow
Commit Message Guidelines
- The messages of the commits use Conventional Commits
- See Angular guideline
Installation
After cloning this repo, create a virtualenv and ensure dependencies are installed by running:
virtualenv venv
source venv/bin/activate
pip install -e ".[test]"
Pipenv
Advantages over plain pip and requirements.txt
Pipenv generates two files: a Pipfile
and a Pipfile.lock
.
* Pipfile
: Is a high level declaration of the dependencies of your project. It can contain "dev" dependencies (usually test related stuff) and "standard" dependencies which are the ones you'll need for your project to function
* Pipfile.lock
: Is the "list" of all the dependencies your Pipfile has installed, along with their version and their hashes. This prevents two things: Conflicts between dependencies and installing a malicious module.
How to...
Here the most 'common' pipenv
commands, for a more in-depth explanation please refer to the official documentation.
Install pipenv
pip install pipenv
Install dependencies defined in a Pipfile
pipenv install
Install both dev and "standard" dependencies defined in a Pipfile
pipenv install --dev
Install a new module
pipenv install django
Install a new dev module (usually test related stuff)
pipenv install nose --dev
Install dependencies in production
pipenv install --deploy
Start a shell
pipenv shell
Testing
Well-written tests and maintaining good test coverage is important to this project. While developing, run new and existing tests with:
pytest --cov=[project/pyms/...] --cov=tests tests/
Add the -s
flag if you have introduced breakpoints into the code for debugging.
Add the -v
("verbose") flag to get more detailed test output. For even more detailed output, use -vv
.
Check out the pytest documentation for more options and test running controls.
PyMS supports several versions of Python3. To make sure that changes do not break compatibility with any of those versions, we use tox
to create virtualenvs for each Python version and run tests with that version. To run against all Python versions defined in the tox.ini
config file, just run:
tox
If you wish to run against a specific version defined in the tox.ini
file:
tox -e py36
Tox can only use whatever versions of Python are installed on your system. When you create a pull request, Travis will also be running the same tests and report the results, so there is no need for potential contributors to try to install every single version of Python on their own system ahead of time.
Linters
MyPy
mypy [project/pyms/...]
Flake8
flake8 [project/pyms/...] --show-source --statistics --statistics
Pylint
pylint --rcfile=pylintrc [project/pyms/...]
Tutorial: Create your own service
See this tutorial