-
Notifications
You must be signed in to change notification settings - Fork 15
/
tasks.py
109 lines (84 loc) · 2.21 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import os
import webbrowser
from invoke import task
def open_browser(path):
try:
from urllib import pathname2url
except:
from urllib.request import pathname2url
webbrowser.open("file://" + pathname2url(os.path.abspath(path)))
@task
def clean_build(c):
"""
Remove build artifacts
"""
c.run("rm -fr build/")
c.run("rm -fr dist/")
c.run("rm -fr *.egg-info")
@task
def clean_pyc(c):
"""
Remove python file artifacts
"""
c.run("find . -name '*.pyc' -exec rm -f {} +")
c.run("find . -name '*.pyo' -exec rm -f {} +")
c.run("find . -name '*~' -exec rm -f {} +")
@task
def coverage(c):
"""
check code coverage quickly with the default Python
"""
c.run("coverage run --source django-serverless-cron runtests.py tests")
c.run("coverage report -m")
c.run("coverage html")
c.run("open htmlcov/index.html")
@task
def docs(c):
"""
Build the documentation and open it in the browser
"""
c.run("rm -f docs/django-serverless-cron.rst")
c.run("rm -f docs/modules.rst")
c.run("sphinx-apidoc -o docs/ django_serverless_cron")
c.run("sphinx-build -E -b html docs docs/_build")
open_browser(path='docs/_build/html/index.html')
@task
def test_all(c):
"""
Run tests on every python version with tox
"""
c.run("tox")
@task
def clean(c):
"""
Remove python file and build artifacts
"""
clean_build(c)
clean_pyc(c)
@task
def unittest(c):
"""
Run unittests
"""
c.run("python manage.py test")
@task
def lint(c):
"""
Check style with flake8
"""
c.run("flake8 django-serverless-cron tests")
@task(help={'bumpsize': 'Bump either for a "feature" or "breaking" change'})
def release(c, bumpsize=''):
"""
Package and upload a release
"""
clean(c)
if bumpsize:
bumpsize = '--' + bumpsize
c.run("bumpversion {bump} --no-input".format(bump=bumpsize))
import django_serverless_cron
c.run("python setup.py sdist bdist_wheel")
c.run("twine upload dist/*")
c.run('git tag -a {version} -m "New version: {version}"'.format(version=django_serverless_cron.__version__))
c.run("git push --tags")
c.run("git push origin master")