swydd/tasks.py

48 lines
984 B
Python
Raw Normal View History

2024-03-05 13:52:37 -06:00
#!/usr/bin/env python3
2024-07-22 15:17:58 -05:00
__import__("sys").path.append("src")
2024-03-08 12:54:35 -06:00
2024-03-08 12:57:04 -06:00
import shutil
import sys
2024-07-22 15:17:58 -05:00
from swydd import cli, get, option, path, sub, task
2024-03-05 13:52:37 -06:00
2024-07-22 15:17:58 -05:00
@task
2024-03-08 12:57:04 -06:00
def bootstrap():
"""setup swydd dev environment"""
2024-07-22 15:17:58 -05:00
if not shutil.which("uv"):
sys.exit("uv necessary for swydd development")
sub < "uv sync"
sub < "uv run pre-commit install"
2024-03-08 12:57:04 -06:00
2024-07-22 15:17:58 -05:00
@task
def tests():
"""run pytest"""
sub < "uv run pytest"
2024-03-05 13:52:37 -06:00
2024-07-22 15:17:58 -05:00
@task
@option("skip-mypy", "skip mypy")
def check(skip_mypy: bool = False):
"""run pre-commit (and mypy)"""
sub < "uv run pre-commit run --all"
if not skip_mypy:
sub < "uv run mypy src/"
2024-07-19 14:10:33 -05:00
2024-10-20 13:05:37 -05:00
@task
def docs():
"""build docs"""
2024-07-22 15:17:58 -05:00
tags = get < "git tag --list"
versions = [line for line in tags.splitlines() if line.startswith("v")]
for tag in versions:
(path / f"docs/{tag}/swydd.py") < (
get < f"git show {tag}:src/swydd/__init__.py"
)
(path / "docs/swydd.py") < (path / "src/swydd/__init__.py")
2024-07-19 14:10:33 -05:00
2024-07-22 15:17:58 -05:00
cli()