|
| 1 | +# Contributing |
| 2 | + |
| 3 | +## Branch workflow |
| 4 | + |
| 5 | +**READ BEFORE CREATE A BRANCH OR OPEN A PR/MR** |
| 6 | +- We use [Github Glow](https://guides.github.com/introduction/flow/) |
| 7 | + |
| 8 | + |
| 9 | +## Commit Message Guidelines |
| 10 | + |
| 11 | +- The messages of the commits use [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) |
| 12 | +- See [Angular guideline](https://github.com/angular/angular/blob/22b96b9/CONTRIBUTING.md#-commit-message-guidelines) |
| 13 | + |
| 14 | + |
| 15 | +## Installation |
| 16 | + |
| 17 | +After cloning this repo, create a [virtualenv](https://virtualenv.pypa.io/en/stable/) and ensure dependencies are installed by running: |
| 18 | + |
| 19 | +```sh |
| 20 | +virtualenv venv |
| 21 | +source venv/bin/activate |
| 22 | +pip install -e ".[test]" |
| 23 | +``` |
| 24 | + |
| 25 | +Well-written tests and maintaining good test coverage is important to this project. While developing, run new and existing tests with: |
| 26 | + |
| 27 | +```sh |
| 28 | +pytest --cov=pyms --cov=tests tests/ |
| 29 | +``` |
| 30 | + |
| 31 | +Add the `-s` flag if you have introduced breakpoints into the code for debugging. |
| 32 | +Add the `-v` ("verbose") flag to get more detailed test output. For even more detailed output, use `-vv`. |
| 33 | +Check out the [pytest documentation](https://docs.pytest.org/en/latest/) for more options and test running controls. |
| 34 | + |
| 35 | +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: |
| 36 | + |
| 37 | +```sh |
| 38 | +tox |
| 39 | +``` |
| 40 | + |
| 41 | +If you wish to run against a specific version defined in the `tox.ini` file: |
| 42 | + |
| 43 | +```sh |
| 44 | +tox -e py36 |
| 45 | +``` |
| 46 | + |
| 47 | +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. |
| 48 | + |
| 49 | +## Pipenv |
| 50 | + |
| 51 | +### Advantages over plain pip and requirements.txt |
| 52 | +[Pipenv](https://pipenv.readthedocs.io/en/latest/) generates two files: a `Pipfile`and a `Pipfile.lock`. |
| 53 | +* `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 |
| 54 | +* `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. |
| 55 | + |
| 56 | +### How to... |
| 57 | + |
| 58 | +Here the most 'common' `pipenv` commands, for a more in-depth explanation please refer to the [official documentation](https://pipenv.readthedocs.io/en/latest/). |
| 59 | + |
| 60 | +#### Install pipenv |
| 61 | +```bash |
| 62 | +pip install pipenv |
| 63 | +``` |
| 64 | + |
| 65 | +#### Install dependencies defined in a Pipfile |
| 66 | +```bash |
| 67 | +pipenv install |
| 68 | +``` |
| 69 | + |
| 70 | +#### Install both dev and "standard" dependencies defined in a Pipfile |
| 71 | +```bash |
| 72 | +pipenv install --dev |
| 73 | +``` |
| 74 | + |
| 75 | +#### Install a new module |
| 76 | +```bash |
| 77 | +pipenv install django |
| 78 | +``` |
| 79 | + |
| 80 | +#### Install a new dev module (usually test related stuff) |
| 81 | +```bash |
| 82 | +pipenv install nose --dev |
| 83 | +``` |
| 84 | + |
| 85 | +#### Install dependencies in production |
| 86 | +```bash |
| 87 | +pipenv install --deploy |
| 88 | +``` |
| 89 | + |
| 90 | +#### Start a shell |
| 91 | +```bash |
| 92 | +pipenv shell |
| 93 | +``` |
| 94 | + |
| 95 | +## Tutorial: Create your own service |
| 96 | + |
| 97 | +See this [tutorial](tutorial_create_services.md) |
0 commit comments