Skip to content

Commit 8a2f020

Browse files
authored
Fix Travis integration, set up tox and pre-commit
Merge pull request #188 from jnak/travis-tox
2 parents d00d9a0 + 3106c6e commit 8a2f020

File tree

6 files changed

+115
-65
lines changed

6 files changed

+115
-65
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+
# TDOO Enable in separate PR
11+
# - id: end-of-file-fixer
12+
# exclude: ^docs/.*$
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
```

setup.cfg

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,9 @@
22
exclude = setup.py,docs/*,examples/*,tests
33
max-line-length = 120
44

5-
[coverage:run]
6-
omit = */tests/*
7-
5+
# TODO Add isort as a pre-commit hook
86
[isort]
97
known_first_party=graphene,graphene_sqlalchemy
108

11-
[tool:pytest]
12-
testpaths = graphene_sqlalchemy/
13-
addopts =
14-
-s
15-
; --cov graphene-sqlalchemy
16-
norecursedirs =
17-
__pycache__
18-
*.egg-info
19-
.cache
20-
.git
21-
.tox
22-
appdir
23-
docs
24-
filterwarnings =
25-
error
26-
ignore::DeprecationWarning
27-
289
[bdist_wheel]
2910
universal=1

setup.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
ast.literal_eval(_version_re.search(f.read().decode("utf-8")).group(1))
1111
)
1212

13+
tests_require = [
14+
"pytest==4.3.1",
15+
"mock==2.0.0",
16+
"pytest-cov==2.6.1",
17+
"sqlalchemy_utils==0.33.9",
18+
]
1319

1420
setup(
1521
name="graphene-sqlalchemy",
@@ -37,10 +43,20 @@
3743
keywords="api graphql protocol rest relay graphene",
3844
packages=find_packages(exclude=["tests"]),
3945
install_requires=[
40-
"six>=1.10.0",
41-
"graphene>=2.1.3",
42-
"SQLAlchemy",
43-
"singledispatch>=3.4.0.3",
46+
# To keep things simple, we only support newer versions of Graphene
47+
"graphene>=2.1.3,<3",
48+
# Tests fail with 1.0.19
49+
"SQLAlchemy>=1.1,<2",
50+
"six>=1.10.0,<2",
51+
"singledispatch>=3.4.0.3,<4",
4452
],
45-
tests_require=["pytest>=2.7.2", "mock", "sqlalchemy_utils"],
53+
extras_require={
54+
"dev": [
55+
"tox==3.7.0", # Should be kept in sync with tox.ini
56+
"coveralls==1.7.0",
57+
"pre-commit==1.14.4",
58+
],
59+
"test": tests_require,
60+
},
61+
tests_require=tests_require,
4662
)

tox.ini

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[tox]
2+
envlist = pre-commit,py{34,35,36,37}-sql{11,12,13}
3+
skipsdist = true
4+
minversion = 3.7.0
5+
6+
[testenv]
7+
deps =
8+
.[test]
9+
sql11: sqlalchemy>=1.1,<1.2
10+
sql12: sqlalchemy>=1.2,<1.3
11+
sql13: sqlalchemy>=1.3,<1.4
12+
commands =
13+
pytest graphene_sqlalchemy --cov=graphene_sqlalchemy {posargs}
14+
15+
[testenv:pre-commit]
16+
basepython=python3.7
17+
deps =
18+
.[dev]
19+
commands =
20+
pre-commit {posargs:run --all-files}

0 commit comments

Comments
 (0)