-
Notifications
You must be signed in to change notification settings - Fork 6
/
tasks.py
94 lines (68 loc) · 2 KB
/
tasks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# -*- coding: utf-8 -*-
from invoke import run, task
REQUIREMENTS = 'requirements-dev.txt'
PACKAGE_NAME = 'alchy'
FLAKE8_IGNORE = ','.join([
'F401', # `module` imported but unused
'F811', # redefinition of unused `name` from line `N`
])
PYLINT_IGNORE = ','.join([
'not-callable',
'no-self-argument',
'no-member',
'no-value-for-parameter',
'method-hidden'
])
TEST_TARGETS = ' '.join([PACKAGE_NAME, 'tests'])
COV_TARGET = PACKAGE_NAME
@task
def clean(ctx):
"""Remove temporary files related to development."""
run('find . -name \*.py[cod] -type f -delete')
run('find . -depth -name __pycache__ -type d -exec rm -rf {} \;')
run('rm -rf .tox .coverage .cache .egg* *.egg* dist build')
@task
def install(ctx):
"""Install package development dependencies."""
run('pip install -r {0}'.format(REQUIREMENTS))
@task
def flake8(ctx):
"""Run flake8 checker."""
run('flake8 --ignore={0} {1}'.format(FLAKE8_IGNORE, TEST_TARGETS))
@task
def pylint(ctx):
"""Run pylint checker."""
run('pylint -E -d {0} {1}'.format(PYLINT_IGNORE, TEST_TARGETS))
@task(pre=[flake8, pylint])
def lint(ctx):
"""Run static linter."""
pass
@task
def unit(ctx):
"""Run unit tests."""
run('py.test --cov {0} {1}'.format(COV_TARGET, TEST_TARGETS))
@task(pre=[lint, unit])
def test(ctx):
"""Run all tests."""
pass
@task(post=[clean])
def tox(ctx):
"""Run tox testing."""
run('tox -c tox.ini')
@task
def docs(ctx, serve=False, port=8000):
"""Build documentation."""
run('rm -rf {0}'.format('docs/_build'))
run('cd docs && make doctest && make html')
if serve:
print('Serving docs on port {0} ...'.format(port))
run('cd {0} && python -m http.server {1}'
.format('docs/_build/html', port))
@task
def build(ctx):
"""Build package distribution."""
run('python setup.py sdist bdist_wheel')
@task(pre=[build], post=[clean])
def release(ctx):
"""Upload package distribution to PyPI."""
run('twine upload dist/*')