forked from NRWLDev/pogo-migrate
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtasks.py
More file actions
89 lines (66 loc) · 1.98 KB
/
tasks.py
File metadata and controls
89 lines (66 loc) · 1.98 KB
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
"""Collection of useful commands for code management.
To view a list of available commands:
$ invoke --list
"""
import subprocess
import invoke
def current_branch():
"""Get the current branch from git cli using subprocess."""
try:
rev_parse_out = (
subprocess.check_output(
[
"git",
"rev-parse",
"--tags",
"--abbrev-ref",
"HEAD",
],
stderr=subprocess.STDOUT,
)
.decode()
.strip()
.split("\n")
)
except subprocess.CalledProcessError as e:
msg = "Could not get current branch name."
raise invoke.exceptions.Exit(msg) from e
return rev_parse_out[-1]
def enforce_branch(branch_name):
"""Enforce that the current branch matches the supplied branch_name."""
if current_branch() != branch_name:
msg = f"Command can not be run outside of {branch_name}."
raise invoke.exceptions.Exit(msg)
@invoke.task
def install(context):
"""Install production requirements."""
context.run("uv sync")
@invoke.task
def install_dev(context):
"""Install development requirements."""
context.run("uv sync --all-extras")
context.run("uv run pre-commit install")
@invoke.task
def check_style(context):
"""Run style checks."""
context.run("ruff check .")
@invoke.task
def tests(context):
"""Run pytest unit tests."""
context.run("pytest -x -s")
@invoke.task
def tests_coverage(context):
"""Run pytest unit tests with coverage."""
context.run("pytest --cov -x --cov-report=xml")
@invoke.task
def infra_test_start(context):
"""Run local unittest infrastructure."""
context.run(
"docker compose -f unittest-compose.yml up -d",
)
@invoke.task
def infra_test_stop(context):
"""Stop local unittest infrastructure."""
context.run(
"docker compose -f unittest-compose.yml down",
)