-
Notifications
You must be signed in to change notification settings - Fork 1
/
tasks.py
96 lines (70 loc) · 2.22 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
import os
import webbrowser
from invoke import task
def open_browser(path):
try:
from urllib import pathname2url
except Exception:
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-cms-bootstrap-grid-builder 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-cms-bootstrap-grid-builder.rst")
c.run("rm -f docs/modules.rst")
c.run("sphinx-apidoc -o docs/ bootstrap_grid_builder")
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-cms-bootstrap-grid-builder 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_bootstrap_grid_builder
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_bootstrap_grid_builder.__version__
)
)
c.run("git push --tags")
c.run("git push origin master")