|
| 1 | +# Contibuting |
| 2 | + |
| 3 | +All contributions to *databases* are welcome! |
| 4 | + |
| 5 | +## Issues |
| 6 | + |
| 7 | +To make it as simple as possible for us to help you, please include the following: |
| 8 | + |
| 9 | +* OS |
| 10 | +* python version |
| 11 | +* databases version |
| 12 | +* database backend (mysql, sqlite or postgresql) |
| 13 | +* database driver (aiopg, aiomysql etc.) |
| 14 | + |
| 15 | +Please try to always include the above unless you're unable to install *databases* or **know** it's not relevant |
| 16 | +to your question or feature request. |
| 17 | + |
| 18 | +## Pull Requests |
| 19 | + |
| 20 | +It should be quite straight forward to get started and create a Pull Request. |
| 21 | + |
| 22 | +!!! note |
| 23 | + Unless your change is trivial (typo, docs tweak etc.), please create an issue to discuss the change before |
| 24 | + creating a pull request. |
| 25 | + |
| 26 | +To make contributing as easy and fast as possible, you'll want to run tests and linting locally. |
| 27 | + |
| 28 | +You'll need to have **python >= 3.6 (recommended 3.7+)** and **git** installed. |
| 29 | + |
| 30 | +## Getting started |
| 31 | + |
| 32 | +1. Clone your fork and cd into the repo directory |
| 33 | +```bash |
| 34 | +git clone [email protected]: <your username >/databases.git |
| 35 | +cd databases |
| 36 | +``` |
| 37 | + |
| 38 | +2. Create and activate virtual env |
| 39 | +```bash |
| 40 | +virtualenv env |
| 41 | +source env/bin/activate |
| 42 | +``` |
| 43 | + |
| 44 | +3. Install databases, dependencies and test dependencies |
| 45 | +```bash |
| 46 | +pip install -r requirements.txt |
| 47 | +``` |
| 48 | + |
| 49 | +4. Checkout a new branch and make your changes |
| 50 | +```bash |
| 51 | +git checkout -b my-new-feature-branch |
| 52 | +``` |
| 53 | + |
| 54 | +## Make your changes... |
| 55 | + |
| 56 | +## Contribute |
| 57 | + |
| 58 | +1. Formatting and linting - databases uses black for formatting, autoflake for linting and mypy for type hints check |
| 59 | +run all of those with lint script |
| 60 | +```bash |
| 61 | +./scripts/lint |
| 62 | +``` |
| 63 | + |
| 64 | +2. Prepare tests (basic) |
| 65 | + 1. Set-up `TEST_DATABASE_URLS` env variable where you can comma separate urls for several backends |
| 66 | + 2. The simples one is for sqlite alone: `sqlite:///test.db` |
| 67 | + |
| 68 | +3. Prepare tests (all backends) |
| 69 | + 1. In order to run all backends you need either a docker installation on your system or all supported backends servers installed on your local machine. |
| 70 | + 2. A sample docker configuration that reflects the CI/CD workflow of databases might be: |
| 71 | + |
| 72 | + ```dockerfile |
| 73 | + version: '2.1' |
| 74 | + services: |
| 75 | + postgres: |
| 76 | + image: postgres:10.8 |
| 77 | + environment: |
| 78 | + POSTGRES_USER: username |
| 79 | + POSTGRES_PASSWORD: password |
| 80 | + POSTGRES_DB: testsuite |
| 81 | + ports: |
| 82 | + - 5432:5432 |
| 83 | + |
| 84 | + mysql: |
| 85 | + image: mysql:5.7 |
| 86 | + environment: |
| 87 | + MYSQL_USER: username |
| 88 | + MYSQL_PASSWORD: password |
| 89 | + MYSQL_ROOT_PASSWORD: password |
| 90 | + MYSQL_DATABASE: testsuite |
| 91 | + ports: |
| 92 | + - 3306:3306 |
| 93 | + ``` |
| 94 | + 3. To test all backends, the test urls need to consist of all possible drivers too, so a sample might look like following: |
| 95 | + ```text |
| 96 | + sqlite:///test.db, |
| 97 | + sqlite+aiosqlite:///test.db, |
| 98 | + mysql+aiomysql://username:password@localhost:3306/testsuite, |
| 99 | + mysql+asyncmy://username:password@localhost:3306/testsuite, |
| 100 | + postgresql+aiopg://username:[email protected]:5432/testsuite, |
| 101 | + postgresql+asyncpg://username:password@localhost:5432/testsuite |
| 102 | + ``` |
| 103 | + |
| 104 | +4. Run tests |
| 105 | +```bash |
| 106 | +./scripts/test |
| 107 | +``` |
| 108 | + |
| 109 | +5. Build documentation |
| 110 | + 1. If you have changed the documentation make sure it runs successfully. |
| 111 | + You can preview the live documentation by running the following command: |
| 112 | +```bash |
| 113 | +./scripts/docs |
| 114 | +``` |
| 115 | + |
| 116 | +6. Commit, push, and create your pull request |
0 commit comments