Skip to content

Commit cfea834

Browse files
committed
chore: contributing docs and refactor dev packages
1 parent ad392b5 commit cfea834

File tree

12 files changed

+182
-81
lines changed

12 files changed

+182
-81
lines changed

.travis.yml

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,18 @@
11
language: python
2-
matrix:
3-
include:
4-
- python: "3.7"
5-
env: TOX_ENV=black,flake8,mypy,py37
6-
- python: "3.6"
7-
env: TOX_ENV=py36
8-
- python: "3.5"
9-
env: TOX_ENV=py35
10-
- python: "2.7"
11-
env: TOX_ENV=py27
12-
- python: pypy3
13-
env: TOX_ENV=pypy3
14-
- python: pypy
15-
env: TOX_ENV=pypy
16-
cache:
17-
directories:
18-
- "$HOME/.cache/pip"
19-
- "$TRAVIS_BUILD_DIR/.tox"
20-
install:
21-
- pip install tox codecov
22-
script:
23-
- tox -e $TOX_ENV -- --cov-report term-missing --cov=graphql_server
24-
after_success:
25-
- codecov
2+
sudo: false
3+
python:
4+
- 2.7
5+
- 3.5
6+
- 3.6
7+
- 3.7
8+
- 3.8
9+
- 3.9-dev
10+
- pypy
11+
- pypy3
12+
cache: pip
13+
install: pip install tox-travis codecov
14+
script: tox
15+
after_success: codecov
2616
deploy:
2717
provider: pypi
2818
on:

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"python.pythonPath": "D:\\Anaconda3\\envs\\graphql-sc-dev\\python.exe"
3+
}

CONTRIBUTING.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Contributing
2+
3+
Thanks for helping to make graphql-server-core awesome!
4+
5+
We welcome all kinds of contributions:
6+
7+
- Bug fixes
8+
- Documentation improvements
9+
- New features
10+
- Refactoring & tidying
11+
12+
13+
## Getting started
14+
15+
If you have a specific contribution in mind, be sure to check the [issues](https://github.com/graphql-python/graphql-server-core/issues) and [pull requests](https://github.com/graphql-python/graphql-server-core/pulls) in progress - someone could already be working on something similar and you can help out.
16+
17+
18+
## Project setup
19+
20+
### Development with virtualenv (recommended)
21+
22+
After cloning this repo, create a virtualenv:
23+
24+
```console
25+
virtualenv graphql-server-core-dev
26+
```
27+
28+
Activate the virtualenv and install dependencies by running:
29+
30+
```console
31+
python pip install -e ".[test]"
32+
```
33+
34+
If you are using Linux or MacOS, you can make use of Makefile command
35+
`make dev-setup`, which is a shortcut for the above python command.
36+
37+
### Development on Conda
38+
39+
You must create a new env (e.g. `graphql-sc-dev`) with the following command:
40+
41+
```sh
42+
conda create -n graphql-sc-dev python=3.8
43+
```
44+
45+
Then activate the environment with `conda activate graphql-sc-dev`.
46+
47+
Proceed to install all dependencies by running:
48+
49+
```console
50+
pip install -e.[dev]
51+
```
52+
53+
And you ready to start development!
54+
55+
## Running tests
56+
57+
After developing, the full test suite can be evaluated by running:
58+
59+
```sh
60+
pytest tests --cov=graphql-server-core -vv
61+
```
62+
63+
If you are using Linux or MacOS, you can make use of Makefile command
64+
`make tests`, which is a shortcut for the above python command.
65+
66+
You can also test on several python environments by using tox.
67+
68+
### Running tox on virtualenv
69+
70+
Install tox:
71+
72+
```console
73+
pip install tox
74+
```
75+
76+
Run `tox` on your virtualenv (do not forget to activate it!)
77+
and that's it!
78+
79+
### Running tox on Conda
80+
81+
In order to run `tox` command on conda, install
82+
[tox-conda](https://github.com/tox-dev/tox-conda):
83+
84+
```sh
85+
conda install -c conda-forge tox-conda
86+
```
87+
88+
This install tox underneath so no need to install it before.
89+
90+
Then uncomment the `requires = tox-conda` line on `tox.ini` file.
91+
92+
Run `tox` and you will see all the environments being created
93+
and all passing tests. :rocket:
94+

MANIFEST.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
include README.md
22
include LICENSE
3+
include CONTRIBUTING.md
4+
5+
include tox.ini
6+
7+
global-exclude *.py[co] __pycache__

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ You can also use one of the existing integrations listed above as
4242
blueprint to build your own integration or GraphQL server implementations.
4343

4444
Please let us know when you have built something new, so we can list it here.
45+
46+
## Contributing
47+
See [CONTRIBUTING.md](CONTRIBUTING.md)

setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[flake8]
22
exclude = docs
3-
max-line-length = 88
3+
max-line-length = 120
44

55
[isort]
66
known_first_party=graphql_server
77

88
[tool:pytest]
9-
norecursedirs = venv .venv .tox .git .cache .mypy_cache .pytest_cache
9+
norecursedirs = venv .venv .tox .git .cache .mypy_cache .pytest_cache
1010

1111
[bdist_wheel]
1212
universal=1

setup.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
from setuptools import setup, find_packages
22

3-
required_packages = ["graphql-core>=2.3,<3", "promise>=2.3,<3"]
4-
tests_require = ["pytest==4.6.9", "pytest-cov==2.8.1"]
3+
install_requires = [
4+
"graphql-core>=2.3,<3",
5+
"promise>=2.3,<3",
6+
]
7+
8+
tests_requires = [
9+
"pytest==4.6.9",
10+
"pytest-cov==2.8.1"
11+
]
12+
13+
dev_requires = [
14+
'flake8==3.7.9',
15+
'isort<4.0.0',
16+
'black==19.10b0',
17+
'mypy==0.761',
18+
'check-manifest>=0.40,<1',
19+
] + tests_requires
520

621
setup(
722
name="graphql-server-core",
@@ -30,9 +45,12 @@
3045
],
3146
keywords="api graphql protocol rest",
3247
packages=find_packages(exclude=["tests"]),
33-
install_requires=required_packages,
34-
tests_require=tests_require,
35-
extras_require={"test": tests_require},
48+
install_requires=install_requires,
49+
tests_require=tests_requires,
50+
extras_require={
51+
'test': tests_requires,
52+
'dev': dev_requires,
53+
},
3654
include_package_data=True,
3755
zip_safe=False,
3856
platforms="any",

tests/schema.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
from graphql.type.definition import (
2-
GraphQLArgument,
3-
GraphQLField,
4-
GraphQLNonNull,
5-
GraphQLObjectType,
6-
)
1+
from graphql.type.definition import (GraphQLArgument, GraphQLField,
2+
GraphQLNonNull, GraphQLObjectType)
73
from graphql.type.scalars import GraphQLString
84
from graphql.type.schema import GraphQLSchema
95

tests/test_asyncio.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
import asyncio
2-
3-
from promise import Promise
4-
51
from graphql.execution.executors.asyncio import AsyncioExecutor
6-
from graphql.type.definition import (
7-
GraphQLField,
8-
GraphQLNonNull,
9-
GraphQLObjectType,
10-
)
2+
from graphql.type.definition import (GraphQLField, GraphQLNonNull,
3+
GraphQLObjectType)
114
from graphql.type.scalars import GraphQLString
125
from graphql.type.schema import GraphQLSchema
6+
from promise import Promise
7+
8+
import asyncio
139
from graphql_server import RequestParams, run_http_query
1410

1511
from .utils import as_dicts

tests/test_helpers.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,12 @@
33
from graphql.error import GraphQLError
44
from graphql.execution import ExecutionResult
55
from graphql.language.location import SourceLocation
6-
7-
from graphql_server import (
8-
HttpQueryError,
9-
ServerResponse,
10-
encode_execution_results,
11-
json_encode,
12-
json_encode_pretty,
13-
load_json_body,
14-
)
156
from pytest import raises
167

8+
from graphql_server import (HttpQueryError, ServerResponse,
9+
encode_execution_results, json_encode,
10+
json_encode_pretty, load_json_body)
11+
1712

1813
def test_json_encode():
1914
result = json_encode({"query": "{test}"})

0 commit comments

Comments
 (0)