-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdev.py
executable file
·105 lines (78 loc) · 1.84 KB
/
dev.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
#!/usr/bin/env -S poetry run python
import os
import click
from dotenv import load_dotenv
from executor import execute
load_dotenv()
def python_source_files():
import glob
return (
glob.glob("*.py")
+ glob.glob("werkit/*.py")
+ glob.glob("werkit/**/*.py")
+ glob.glob("werkit/**/**/*.py")
) # + ["doc/"]
@click.group()
def cli():
pass
@cli.command()
def install():
execute(
"poetry",
"install",
"--sync",
"--extras",
"aws_lambda_build",
"--extras",
"client",
"--extras",
"lambda_common",
"--extras",
"rds_graphile_worker",
"--extras",
"compute_graph",
)
@cli.command()
@click.option("--slow/--not-slow", default=True)
def test(slow):
args = ["python3", "-m", "pytest"]
if not slow:
args += ["-m", "not slow"]
execute(*args)
@cli.command()
@click.option("--slow/--not-slow", default=True)
def coverage(slow):
args = ["python3", "-m", "pytest", "--cov=werkit"]
if not slow:
args += ["-m", "not slow"]
execute(*args)
@cli.command()
def coverage_report():
execute("coverage html")
execute("open htmlcov/index.html")
@cli.command()
def check_types():
execute(
"mypy",
"--package",
"werkit",
"--show-error-codes",
"--enable-incomplete-feature=Unpack",
)
@cli.command()
def lint():
execute("flake8", *python_source_files())
@cli.command()
def black():
execute("black", *python_source_files())
@cli.command()
def black_check():
execute("black", "--check", *python_source_files())
@cli.command()
def publish():
execute("rm -rf dist/")
execute("poetry build")
execute("twine upload dist/*")
if __name__ == "__main__":
os.chdir(os.path.abspath(os.path.dirname(__file__)))
cli()