Files
python-cli-template/{{cookiecutter.project_slug}}/tasks.py
T
2026-04-22 20:54:57 +02:00

51 lines
1.1 KiB
Python

# type: ignore
from invoke import task
@task
def venv(c):
"""Sync dependencies."""
c.run("uv sync --group dev")
@task
def format(c):
"""Format code."""
c.run("uv run ruff format src tests")
@task
def lint(c):
"""Run linters."""
c.run("uv run ruff check src tests")
c.run("uv run ruff format --check src tests")
c.run("uv run mypy src")
@task
def test(c):
"""Run tests with coverage."""
c.run("uv run pytest --cov=src --cov-report=term-missing")
@task
def ci(c):
"""Run lint and tests in a clean Docker container."""
image = "{{ cookiecutter.project_slug }}-ci"
c.run(f"docker build --network=host -t {image} .")
cmd = (
"uv run ruff check src tests && "
"uv run ruff format --check src tests && "
"uv run mypy src && "
"uv run pytest --cov=src --cov-report=term-missing"
)
c.run(f"docker run --rm {image} sh -c '{cmd}'")
@task
def clean(c):
"""Preview files to delete (safe mode)."""
c.run("git clean -nfdx")
if input("Delete? [y/N] ").lower() == "y":
c.run("git clean -fdx")