-
Notifications
You must be signed in to change notification settings - Fork 22
/
tasks.py
70 lines (53 loc) · 1.33 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
"""
Invoke - Tasks
==============
"""
from invoke import task
__author__ = "Colour Developers"
__copyright__ = "Copyright 2018 Colour Developers"
__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"
__maintainer__ = "Colour Developers"
__email__ = "[email protected]"
__status__ = "Production"
__all__ = [
"precommit",
"build",
"release",
]
@task
def precommit(ctx):
"""
Run the "pre-commit" hooks on the codebase.
Parameters
----------
ctx
Context.
"""
print('Running "pre-commit" hooks on the codebase...') # noqa: T201
ctx.run("pre-commit run --all-files")
@task(precommit)
def build(ctx):
"""
Build the project.
Parameters
----------
ctx : invoke.context.Context
Context.
"""
print("Building...") # noqa: T201
ctx.run("cp readme.md docs/index.md")
ctx.run("mkdocs build")
@task(build)
def release(ctx):
"""
Release the project to *Github Pages*.
Parameters
----------
ctx : invoke.context.Context
Context.
"""
print("Releasing...") # noqa: T201
output = ctx.run("git status")
if "nothing to commit, working tree clean" not in output.stdout:
raise RuntimeError("Working tree is not clean, please commit your changes!")
ctx.run("mkdocs gh-deploy")