Skip to content

Commit 174ed5f

Browse files
author
Julien Nakache
committed
fix ci, set up tox, set up pre-commit, various cleanups
1 parent d00d9a0 commit 174ed5f

File tree

18 files changed

+131
-81
lines changed

18 files changed

+131
-81
lines changed

.pre-commit-config.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
default_language_version:
2+
python: python3.7
3+
repos:
4+
- repo: git://github.com/pre-commit/pre-commit-hooks
5+
rev: c8bad492e1b1d65d9126dba3fe3bd49a5a52b9d6 # v2.1.0
6+
hooks:
7+
- id: check-merge-conflict
8+
- id: check-yaml
9+
- id: debug-statements
10+
- id: end-of-file-fixer
11+
exclude: ^docs/.*$
12+
# TODO Enable in its own PR
13+
# - id: trailing-whitespace
14+
# exclude: README.md
15+
- repo: git://github.com/PyCQA/flake8
16+
rev: 88caf5ac484f5c09aedc02167c59c66ff0af0068 # 3.7.7
17+
hooks:
18+
- id: flake8

.travis.yml

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,47 @@
11
language: python
2-
sudo: false
3-
python:
4-
- 2.7
5-
- 3.4
6-
- 3.5
7-
- 3.6
8-
before_install:
9-
install:
10-
- |
11-
if [ "$TEST_TYPE" = build ]; then
12-
pip install pytest==3.0.2 pytest-cov pytest-benchmark coveralls six mock sqlalchemy_utils
13-
pip install -e .
14-
python setup.py develop
15-
elif [ "$TEST_TYPE" = lint ]; then
16-
pip install flake8
17-
fi
18-
script:
19-
- |
20-
if [ "$TEST_TYPE" = lint ]; then
21-
echo "Checking Python code lint."
22-
flake8 graphene_sqlalchemy
23-
exit
24-
elif [ "$TEST_TYPE" = build ]; then
25-
py.test --cov=graphene_sqlalchemy graphene_sqlalchemy examples
26-
fi
27-
after_success:
28-
- |
29-
if [ "$TEST_TYPE" = build ]; then
30-
coveralls
31-
fi
32-
env:
33-
matrix:
34-
- TEST_TYPE=build
352
matrix:
36-
fast_finish: true
373
include:
38-
- python: '2.7'
39-
env: TEST_TYPE=lint
4+
# Python 2.7
5+
# TODO Fix enum and add back tests for py27
6+
# See https://github.com/graphql-python/graphene-sqlalchemy/pull/177
7+
# - env: TOXENV=py27
8+
# python: 2.7
9+
# Python 3.5
10+
- env: TOXENV=py34
11+
python: 3.4
12+
# Python 3.5
13+
- env: TOXENV=py35
14+
python: 3.5
15+
# Python 3.6
16+
- env: TOXENV=py36
17+
python: 3.6
18+
# Python 3.7
19+
- env: TOXENV=py37
20+
python: 3.7
21+
dist: xenial
22+
# SQLAlchemy 1.1
23+
- env: TOXENV=py37-sql11
24+
python: 3.7
25+
dist: xenial
26+
# SQLAlchemy 1.2
27+
- env: TOXENV=py37-sql12
28+
python: 3.7
29+
dist: xenial
30+
# SQLAlchemy 1.3
31+
- env: TOXENV=py37-sql13
32+
python: 3.7
33+
dist: xenial
34+
# Pre-commit
35+
- env: TOXENV=pre-commit
36+
python: 3.7
37+
dist: xenial
38+
install: pip install .[dev]
39+
script: tox
40+
after_success: coveralls
41+
cache:
42+
directories:
43+
- $HOME/.cache/pip
44+
- $HOME/.cache/pre-commit
4045
deploy:
4146
provider: pypi
4247
user: syrusakbary

README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,24 @@ To learn more check out the following [examples](examples/):
112112

113113
## Contributing
114114

115-
After cloning this repo, ensure dependencies are installed by running:
115+
Set up our development dependencies:
116116

117117
```sh
118-
python setup.py install
118+
pip install -e ".[dev]"
119+
pre-commit install
119120
```
120121

121-
After developing, the full test suite can be evaluated by running:
122+
We use `tox` to test this library against different versions of `python` and `SQLAlchemy`.
123+
While developping locally, it is usually fine to run the tests against the most recent versions:
122124

123125
```sh
124-
python setup.py test # Use --pytest-args="-v -s" for verbose mode
126+
tox -e py37 # Python 3.7, SQLAlchemy < 2.0
127+
tox -e py37 -- -v -s # Verbose output
128+
tox -e py37 -- -k test_query # Only test_query.py
129+
```
130+
131+
Our linters will run automatically when committing via git hooks but you can also run them manually:
132+
133+
```sh
134+
tox -e pre-commit
125135
```

examples/nameko_sqlalchemy/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ Now the following command will setup the database, and start the server:
5151

5252
Now head on over to postman and send POST request to:
5353
[http://127.0.0.1:5000/graphql](http://127.0.0.1:5000/graphql)
54-
and run some queries!
54+
and run some queries!

examples/nameko_sqlalchemy/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ def parse_body(self,request):
3333
elif content_type in ('application/x-www-form-urlencoded', 'multipart/form-data'):
3434
return request.form
3535

36-
return {}
36+
return {}

examples/nameko_sqlalchemy/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
WEB_SERVER_ADDRESS: '0.0.0.0:5000'
1+
WEB_SERVER_ADDRESS: '0.0.0.0:5000'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
graphene[sqlalchemy]
22
SQLAlchemy==1.0.11
33
nameko
4-
graphql-server-core
4+
graphql-server-core

examples/nameko_sqlalchemy/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22
echo "Starting application service server"
33
# Run Service
4-
nameko run --config config.yml service
4+
nameko run --config config.yml service

examples/nameko_sqlalchemy/service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ class DepartmentService:
88

99
@http('POST', '/graphql')
1010
def query(self, request):
11-
return App().query(request)
11+
return App().query(request)

graphene_sqlalchemy/tests/test_converter.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ class Test(Base):
168168
)
169169

170170
graphene_type = convert_sqlalchemy_column(Test.column)
171-
assert graphene_type.kwargs["required"] == False
171+
assert not graphene_type.kwargs["required"]
172172

173173

174174
def test_should_scalar_list_convert_list():
@@ -343,4 +343,3 @@ def __init__(self, col1, col2):
343343
)
344344

345345
assert "Don't know how to convert the composite field" in str(excinfo.value)
346-

0 commit comments

Comments
 (0)