add local ci
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
.venv
|
||||
__pycache__
|
||||
*.pyc
|
||||
.mypy_cache
|
||||
.ruff_cache
|
||||
.pytest_cache
|
||||
build
|
||||
dist
|
||||
*.egg-info
|
||||
@@ -0,0 +1,9 @@
|
||||
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY pyproject.toml uv.lock* ./
|
||||
RUN uv sync --group dev --no-install-project
|
||||
|
||||
COPY . .
|
||||
RUN uv sync --group dev
|
||||
@@ -21,4 +21,5 @@ source init.sh
|
||||
uv run invoke lint
|
||||
uv run invoke test
|
||||
uv run invoke format
|
||||
uv run invoke ci # lint + test in Docker
|
||||
```
|
||||
|
||||
@@ -28,6 +28,20 @@ def test(c):
|
||||
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)."""
|
||||
|
||||
Reference in New Issue
Block a user