-
Notifications
You must be signed in to change notification settings - Fork 264
Add contributing docs #453
Changes from 9 commits
6e36535
002e579
94fab6e
890ea91
c5e0068
e2b1a18
17909cd
0c012b6
f8bff8f
5ad5eb3
3900cd1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.vscode/ | ||
.idea/ | ||
*.pyc | ||
test.db | ||
.coverage | ||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,115 @@ | ||||||||||
# Contibuting | ||||||||||
|
||||||||||
All contributions to *databases* are welcome! | ||||||||||
|
||||||||||
## Issues | ||||||||||
|
||||||||||
To make it as simple as possible for us to help you, please include the following: | ||||||||||
|
||||||||||
* OS | ||||||||||
* python version | ||||||||||
* databases version | ||||||||||
* database backend (mysql, sqlite or postgresql) | ||||||||||
* database driver (aiopg, aiomysql etc.) | ||||||||||
|
||||||||||
Please try to always include the above unless you're unable to install *databases* or **know** it's not relevant | ||||||||||
to your question or feature request. | ||||||||||
|
||||||||||
## Pull Requests | ||||||||||
|
||||||||||
It should be quite straight forward to get started and create a Pull Request. | ||||||||||
|
||||||||||
!!! note | ||||||||||
Unless your change is trivial (typo, docs tweak etc.), please create an issue to discuss the change before | ||||||||||
creating a pull request. | ||||||||||
|
||||||||||
To make contributing as easy and fast as possible, you'll want to run tests and linting locally. | ||||||||||
|
||||||||||
You'll need to have **python >= 3.6 (recommended 3.7+)** and **git** installed. | ||||||||||
|
||||||||||
## Getting started | ||||||||||
|
||||||||||
1. Clone your fork and cd into the repo directory | ||||||||||
```bash | ||||||||||
git clone [email protected]:<your username>/databases.git | ||||||||||
cd databases | ||||||||||
``` | ||||||||||
|
||||||||||
2. Create and activate virtual env | ||||||||||
```bash | ||||||||||
virtualenv -p `which python3.6` env | ||||||||||
source env/bin/activate | ||||||||||
``` | ||||||||||
|
||||||||||
3. Install databases, dependencies and test dependencies | ||||||||||
```bash | ||||||||||
pip install -r requirements.txt | ||||||||||
``` | ||||||||||
|
||||||||||
4. Checkout a new branch and make your changes | ||||||||||
```bash | ||||||||||
git checkout -b my-new-feature-branch | ||||||||||
``` | ||||||||||
|
||||||||||
## Make your changes... | ||||||||||
|
||||||||||
## Contribute | ||||||||||
|
||||||||||
1. Formatting and linting - databases uses black for formatting, autoflake for linting and mypy for type hints check | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why? It should run mypy: Lines 10 to 13 in f8bff8f
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm. In all other encode projects we don't have that line. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we unify this or do I leave it as it is? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's worth unifiying it, but not that important really. Up to you. |
||||||||||
run all of those with lint script | ||||||||||
```bash | ||||||||||
./scripts/lint | ||||||||||
``` | ||||||||||
|
||||||||||
2. Prepare tests (basic) | ||||||||||
1. Set-up `TEST_DATABASE_URLS` env variable where you can comma separate urls for several backends | ||||||||||
2. The simples one is for sqlite alone: `sqlite:///test.db` | ||||||||||
|
||||||||||
3. Prepare tests (all backends) | ||||||||||
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. | ||||||||||
2. A sample docker configuration that reflects the CI/CD workflow of databases might be: | ||||||||||
|
||||||||||
```dockerfile | ||||||||||
version: '2.1' | ||||||||||
services: | ||||||||||
postgres: | ||||||||||
image: postgres:10.8 | ||||||||||
environment: | ||||||||||
POSTGRES_USER: username | ||||||||||
POSTGRES_PASSWORD: password | ||||||||||
POSTGRES_DB: testsuite | ||||||||||
ports: | ||||||||||
- 5432:5432 | ||||||||||
|
||||||||||
mysql: | ||||||||||
image: mysql:5.7 | ||||||||||
environment: | ||||||||||
MYSQL_USER: username | ||||||||||
MYSQL_PASSWORD: password | ||||||||||
MYSQL_ROOT_PASSWORD: password | ||||||||||
MYSQL_DATABASE: testsuite | ||||||||||
ports: | ||||||||||
- 3306:3306 | ||||||||||
``` | ||||||||||
3. To test all backends, the test urls need to consist of all possible drivers too, so a sample might look like following: | ||||||||||
```text | ||||||||||
sqlite:///test.db, | ||||||||||
sqlite+aiosqlite:///test.db, | ||||||||||
mysql+aiomysql://username:password@localhost:3306/testsuite, | ||||||||||
mysql+asyncmy://username:password@localhost:3306/testsuite, | ||||||||||
postgresql+aiopg://username:[email protected]:5432/testsuite, | ||||||||||
postgresql+asyncpg://username:password@localhost:5432/testsuite | ||||||||||
``` | ||||||||||
|
||||||||||
4. Run tests | ||||||||||
```bash | ||||||||||
./scripts/test | ||||||||||
``` | ||||||||||
|
||||||||||
5. Build documentation | ||||||||||
1. If you have changed the documentation make sure it runs successfully | ||||||||||
```bash | ||||||||||
./scripts/test | ||||||||||
collerek marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
``` | ||||||||||
|
||||||||||
6. Commit, push, and create your pull request |
Uh oh!
There was an error while loading. Please reload this page.