-
Notifications
You must be signed in to change notification settings - Fork 18
/
tasks.py
103 lines (78 loc) · 2.16 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
# -*- coding: utf-8 -*-
from __future__ import (
absolute_import,
division,
print_function,
unicode_literals,
)
from invoke import task
@task
def changelog(x):
"""
Generates a new Change Log.
:param x: invoke.context.Context
"""
x.run("github_changelog_generator -u NathanUrwin -p cookiecutter-git")
@task
def clean_build(x):
"""
Removes build artifacts.
:param x: invoke.context.Context
"""
x.run("rm -frv build/")
x.run("rm -frv dist/")
x.run("rm -frv .eggs/")
x.run("find . -name '*.egg-info' -exec rm -frv {} +")
x.run("find . -name '*.egg' -exec rm -frv {} +")
@task
def clean_pyc(x):
"""
Removes python file artifacts.
:param x: invoke.context.Context
"""
x.run("find . -name '*.pyc' -exec rm -frv {} +")
x.run("find . -name '*.pyo' -exec rm -frv {} +")
x.run("find . -name '__pycache__' -exec rm -frv {} +")
x.run("find . -name '*~' -exec rm -frv {} +")
@task
def clean_test(x):
"""
Removes test artifacts.
:param x: invoke.context.Context
"""
x.run("rm -fr .tox/")
x.run("rm -f .coverage")
x.run("rm -fr htmlcov/")
@task(clean_build, clean_pyc, clean_test)
def clean(x):
"""
Removes all build artifacts.
:param x: invoke.context.Context
"""
x.run("find . -name '*~' -exec rm -frv {} +")
@task
def copy_cookie(x):
"""
Copies the cookiecutter-git features into the to-be generated project dir.
:param x: invoke.context.Context
"""
x.run("cp -afrv cookiecutter.json '{{cookiecutter.repo_slug}}'")
x.run("cp -afrv hooks '{{cookiecutter.repo_slug}}'")
x.run("cp -afrv '{{cookiecutter.repo_slug}}' '{{cookiecutter.repo_slug}}'")
@task(name="format")
def format_python(x):
"""
Formats the python source files using the uncompromising black.
:param x: invoke.context.Context
"""
x.run("black --line-length 79 .")
x.run("git add --all")
@task
def tests(x):
"""
Runs the py.test no-stdout-capture, entire-repo-coverage tests.
:param x: invoke.context.Context
"""
x.run(
"pytest --capture=no --cov-report term:skip-covered --cov-report html --cov=. tests"
)