From 0a5b5473c7be80c53f8389ce95623dc177bd3035 Mon Sep 17 00:00:00 2001 From: MatheusDevlog Date: Fri, 20 Nov 2026 20:00:54 -0300 Subject: [PATCH] chore: configurar empacotamento, ambiente Docker e pipeline CI inicial --- .dockerignore | 13 ++++++ .env.example | 4 ++ .github/workflows/ci.yml | 32 ++++++++++++++ Dockerfile | 18 ++++++++ README.md | 16 ++++++- docker-compose.yml | 8 ++++ docs/roadmap.md | 10 ++--- pyproject.toml | 49 ++++++++++++++++++++++ src/patch_radar/__init__.py | 1 + src/patch_radar/adapters/__init__.py | 0 src/patch_radar/domain/__init__.py | 0 src/patch_radar/interfaces/__init__.py | 0 src/patch_radar/interfaces/cli/__init__.py | 0 src/patch_radar/interfaces/ui/__init__.py | 0 src/patch_radar/use_cases/__init__.py | 0 tests/e2e/.gitkeep | 0 tests/integration/.gitkeep | 0 tests/unit/test_smoke.py | 5 +++ 18 files changed, 149 insertions(+), 7 deletions(-) create mode 100644 .dockerignore create mode 100644 .env.example create mode 100644 .github/workflows/ci.yml create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 pyproject.toml create mode 100644 src/patch_radar/__init__.py create mode 100644 src/patch_radar/adapters/__init__.py create mode 100644 src/patch_radar/domain/__init__.py create mode 100644 src/patch_radar/interfaces/__init__.py create mode 100644 src/patch_radar/interfaces/cli/__init__.py create mode 100644 src/patch_radar/interfaces/ui/__init__.py create mode 100644 src/patch_radar/use_cases/__init__.py create mode 100644 tests/e2e/.gitkeep create mode 100644 tests/integration/.gitkeep create mode 100644 tests/unit/test_smoke.py diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..fac63ef --- /dev/null +++ b/.dockerignore @@ -0,0 +1,13 @@ +.git +.gitignore +.env +.env.* +!.env.example +data/ +.venv/ +__pycache__/ +*.pyc +.pytest_cache/ +.ruff_cache/ +.coverage +htmlcov/ diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..9dbd177 --- /dev/null +++ b/.env.example @@ -0,0 +1,4 @@ +GEMINI_API_KEY= +GITHUB_TOKEN= +PATCH_RADAR_DB_PATH=data/patch_radar.db +PATCH_RADAR_CHROMA_PATH=data/chroma diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b8a6bb0 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,32 @@ +name: CI + +on: + push: + pull_request: + +jobs: + quality-and-tests: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up uv and Python 3.12 + uses: astral-sh/setup-uv@v5 + with: + python-version: "3.12" + enable-cache: true + cache-dependency-glob: "pyproject.toml" + + - name: Install dependencies + run: uv sync + + - name: Lint with ruff + run: uv run ruff check . + + - name: Check formatting with ruff + run: uv run ruff format --check . + + - name: Run tests with coverage + run: uv run pytest --cov=patch_radar diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ccc5abb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM python:3.12-slim + +COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ + +ENV PYTHONDONTWRITEBYTECODE=1 \ + PYTHONUNBUFFERED=1 \ + UV_PROJECT_ENVIRONMENT=/opt/venv \ + PATH="/opt/venv/bin:$PATH" + +WORKDIR /app + +COPY pyproject.toml README.md ./ +RUN uv sync --no-install-project + +COPY src ./src +RUN uv sync + +CMD ["patch-radar", "--help"] diff --git a/README.md b/README.md index 6657869..ef77420 100644 --- a/README.md +++ b/README.md @@ -36,12 +36,24 @@ O projeto segue **Clean Architecture** (`domain`, `use_cases`, `adapters`, `inte --- +## Execução com Docker + +Todo o ambiente de desenvolvimento, testes e lint roda isolado em container: + +```bash +cp .env.example .env +docker compose build +docker compose run --rm app ruff check . +docker compose run --rm app ruff format --check . +docker compose run --rm app pytest --cov=patch_radar +``` + +--- + ## Status do Projeto Em desenvolvimento incremental por fases. Acompanhe o progresso atualizado em [`docs/roadmap.md`](docs/roadmap.md). -> As instruções completas de execução via Docker Compose e exemplos de uso da CLI serão adicionadas ao concluir a configuração do ambiente na **Fase 0.2**. - --- ## Licença diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..190f7de --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,8 @@ +services: + app: + build: . + volumes: + - .:/app + env_file: + - path: .env + required: false diff --git a/docs/roadmap.md b/docs/roadmap.md index 1b03de2..55fc3da 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -13,11 +13,11 @@ Acompanhamento incremental das entregas do **Patch Radar**. Cada item representa - [x] Criar `README.md`, licença MIT (`LICENSE`) e `.gitignore`. ### Etapa 0.2 — Containerização, Empacotamento e CI Inicial -- [ ] Configurar `pyproject.toml` (metadados, dependências, `ruff`, `pytest`, script `patch-radar`) e `.env.example`. -- [ ] Criar `Dockerfile`, `.dockerignore` e `docker-compose.yml` (`python:3.12-slim` + `uv` em `/opt/venv`). -- [ ] Criar estrutura base do pacote `src/patch_radar/` e primeiro teste smoke em `tests/`. -- [ ] Configurar pipeline CI em `.github/workflows/ci.yml` (`ruff check`, `ruff format --check` e `pytest`). -- [ ] Validar execução completa de `ruff` e `pytest` dentro do container e no GitHub Actions. +- [x] Configurar `pyproject.toml` (metadados, dependências, `ruff`, `pytest`, script `patch-radar`) e `.env.example`. +- [x] Criar `Dockerfile`, `.dockerignore` e `docker-compose.yml` (`python:3.12-slim` + `uv` em `/opt/venv`). +- [x] Criar estrutura base do pacote `src/patch_radar/` e primeiro teste smoke em `tests/`. +- [x] Configurar pipeline CI em `.github/workflows/ci.yml` (`ruff check`, `ruff format --check` e `pytest`). +- [x] Validar execução completa de `ruff` e `pytest` dentro do container e no GitHub Actions. --- diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..2426d97 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,49 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "patch-radar" +version = "0.1.0" +description = "Agente em Python para monitoramento automatizado de releases no GitHub e consulta semântica de changelogs via RAG." +readme = "README.md" +requires-python = ">=3.12" +dependencies = [ + "httpx>=0.28.0", + "pydantic>=2.10.0", + "google-genai>=1.0.0", + "chromadb>=0.6.0", + "langgraph>=0.3.0", + "typer>=0.15.0", + "rich>=13.9.0", +] + +[project.optional-dependencies] +ui = [ + "streamlit>=1.42.0", +] + +[project.scripts] +patch-radar = "patch_radar.interfaces.cli.main:app" + +[dependency-groups] +dev = [ + "pytest>=8.3.0", + "pytest-cov>=6.0.0", + "ruff>=0.9.0", +] + +[tool.hatch.build.targets.wheel] +packages = ["src/patch_radar"] + +[tool.ruff] +line-length = 88 +target-version = "py312" +src = ["src", "tests"] + +[tool.ruff.lint] +select = ["E", "F", "I", "UP", "B", "SIM"] + +[tool.pytest.ini_options] +testpaths = ["tests"] +addopts = "-v" diff --git a/src/patch_radar/__init__.py b/src/patch_radar/__init__.py new file mode 100644 index 0000000..3dc1f76 --- /dev/null +++ b/src/patch_radar/__init__.py @@ -0,0 +1 @@ +__version__ = "0.1.0" diff --git a/src/patch_radar/adapters/__init__.py b/src/patch_radar/adapters/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/patch_radar/domain/__init__.py b/src/patch_radar/domain/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/patch_radar/interfaces/__init__.py b/src/patch_radar/interfaces/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/patch_radar/interfaces/cli/__init__.py b/src/patch_radar/interfaces/cli/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/patch_radar/interfaces/ui/__init__.py b/src/patch_radar/interfaces/ui/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/patch_radar/use_cases/__init__.py b/src/patch_radar/use_cases/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/e2e/.gitkeep b/tests/e2e/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/integration/.gitkeep b/tests/integration/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/unit/test_smoke.py b/tests/unit/test_smoke.py new file mode 100644 index 0000000..1048f26 --- /dev/null +++ b/tests/unit/test_smoke.py @@ -0,0 +1,5 @@ +import patch_radar + + +def test_package_exposes_version() -> None: + assert patch_radar.__version__ == "0.1.0"