forked from fwallacevt/notion-recurring-tasks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ci_helper.py
50 lines (37 loc) · 1.1 KB
/
ci_helper.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
#!/usr/bin/env python3
#
# Usage: python ci_helper.py
import subprocess
from os import environ
def run(cmd: str, *args: str):
"""Run a shell command and raise an error if it fails."""
subprocess.run([cmd, *args], check=True)
def pipenv_run(cmd: str, *args: str):
"""Run a shell command inside the virtual environment created by `pipenv`.
This should include all of our installed Python packages and CLI tools."""
run("pipenv", "run", cmd, *args)
# Run the type checker.
pipenv_run("mypy", "--version")
pipenv_run("mypy", "--show-traceback", ".")
try:
pipenv_run("isort", "--version")
pipenv_run("check")
except Exception as e:
print("Failed formatting check; please run 'pipenv run format' and re-commit")
raise e
def pytest(*args: str):
"""Run pytest with the specified arguments."""
pipenv_run(
"pytest",
"--log-level=debug",
"--capture=no",
*args,
)
pytest(
"--cov-config=.coveragerc",
"--cov=.",
"-n",
"8",
"--cov-report",
"xml:../../test_output/test-output-model_train/coverage/cobertura-coverage.xml",
)