-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasks.py
106 lines (91 loc) · 2.34 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
104
105
106
from invoke import task
from pathlib import Path
from robot.libdoc import libdoc
# Paths
ROOT = Path(__file__).parent
SRC = ROOT / "src" / "FastHTTPMock"
UTESTS = ROOT / "tests"
ATESTS = ROOT / "atests"
DOCS = ROOT / "docs"
@task
def clean(ctx):
"""Clean up build artifacts."""
patterns = [
"*.pyc",
"*.pyo",
"*.pyd",
"*.so",
"*.egg",
"*.egg-info",
"*.eggs",
".coverage",
"htmlcov",
".pytest_cache",
".tox",
".venv",
"build",
"dist",
"__pycache__",
"FastHTTPMock-debug.log"
]
for pattern in patterns:
ctx.run(f"find . -type f -name '{pattern}' -delete")
ctx.run(f"find . -type d -name '{pattern}' -exec rm -rf {{}} +")
@task
def format(ctx):
"""Format code using black and ruff."""
print("Formatting with black...")
ctx.run(f"black {SRC} {UTESTS}")
print("Formatting with ruff...")
ctx.run(f"ruff check --fix {SRC} {UTESTS}")
@task
def lint(ctx):
"""Run linting checks."""
print("Running black check...")
ctx.run(f"black --check {SRC} {UTESTS}")
print("Running ruff check...")
ctx.run(f"ruff check {SRC} {UTESTS}")
@task
def utest(ctx):
"""Run unit tests."""
ctx.run(f"pytest {UTESTS}")
@task
def atest(ctx):
"""Run acceptance tests."""
ctx.run(f"robot {ATESTS}")
@task
def test(ctx):
"""Run all tests."""
utest(ctx)
atest(ctx)
@task
def docs(ctx):
"""Generate library documentation."""
DOCS.mkdir(exist_ok=True)
print("Generating library documentation...")
# ctx.run(f"python -m robot.libdoc FastHTTPMock {DOCS}/FastHTTPMock.html")
output = f"{DOCS}/index.html"
libdoc("FastHTTPMock", str(output))
print(f"Documentation generated at {DOCS}/index.html")
@task
def build(ctx):
"""Build the package."""
clean(ctx)
ctx.run("python -m build")
@task
def install(ctx):
"""Install the package in development mode."""
ctx.run("pip install -e '.[dev]'")
@task
def uninstall(ctx):
"""Uninstall the package."""
ctx.run("pip uninstall robotframework-fasthttpmock -y")
@task(pre=[clean, lint, test, docs, build])
def release(ctx):
"""Prepare for release."""
print("Release preparation complete")
@task
def dev_setup(ctx):
"""Set up development environment."""
install(ctx)
docs(ctx)