generated from tjdcs/CS-Workbench
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtasks.py
More file actions
91 lines (67 loc) · 2 KB
/
tasks.py
File metadata and controls
91 lines (67 loc) · 2 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
90
91
"""OLE-Toolset development tasks powered by Invoke."""
from __future__ import annotations
import shutil
from pathlib import Path
from invoke import Context, task
ROOT = Path(__file__).resolve().parent
@task
def lint(ctx: Context, fix: bool = False) -> None:
"""Run ruff linter."""
cmd = "ruff check ."
if fix:
cmd += " --fix"
ctx.run(cmd, pty=True)
@task
def format(ctx: Context, check: bool = False) -> None:
"""Run ruff formatter."""
cmd = "ruff format ."
if check:
cmd += " --check"
ctx.run(cmd, pty=True)
@task
def typecheck(ctx: Context) -> None:
"""Run pyright type checker."""
ctx.run("pyright", pty=True)
@task
def spellcheck(ctx: Context) -> None:
"""Run cspell spell checker."""
ctx.run('npx cspell "ole/**/*" "tests/**/*" "*.md"', pty=True)
@task
def check(ctx: Context) -> None:
"""Run all quality checks (lint, format --check, typecheck, spellcheck)."""
lint(ctx)
format(ctx, check=True)
typecheck(ctx)
spellcheck(ctx)
@task(name="check-fix")
def check_fix(ctx: Context) -> None:
"""Run lint --fix and format."""
lint(ctx, fix=True)
format(ctx)
@task
def test(ctx: Context) -> None:
"""Run pytest test suite."""
ctx.run("python -m pytest", pty=True)
@task
def clean(ctx: Context) -> None: # noqa: ARG001
"""Remove build artifacts and caches."""
patterns = ["__pycache__", ".pytest_cache", ".ruff_cache"]
for pattern in patterns:
for path in ROOT.rglob(pattern):
if path.is_dir():
shutil.rmtree(path)
print(f"Removed {path}")
@task(name="ai-developer-quality")
def ai_developer_quality(ctx: Context) -> None:
"""Run quality checks suitable for AI-assisted development."""
format(ctx)
lint(ctx, fix=True)
typecheck(ctx)
spellcheck(ctx)
@task
def dev(ctx: Context) -> None:
"""Run full development workflow (check-fix, typecheck, spellcheck, test)."""
check_fix(ctx)
typecheck(ctx)
spellcheck(ctx)
test(ctx)