Skip to main content

Desenvolvimento Local

Estrutura do projeto

raro-reviewer/
├── src/
│ ├── core/ # Lógica de negócio pura
│ │ ├── models.py
│ │ ├── diff_parser.py
│ │ ├── position_mapper.py
│ │ └── review_pipeline.py
│ ├── ports/ # Interfaces (Protocol)
│ │ ├── gitlab_client.py
│ │ ├── llm_client.py
│ │ └── dispatcher.py
│ ├── adapters/ # Implementações
│ │ ├── gitlab/
│ │ ├── llm/
│ │ └── dispatch/
│ ├── webhook/ # FastAPI routes
│ ├── app.py # Container entrypoint
│ ├── lambda_handler.py # Lambda entrypoint
│ ├── webapp.py # App factory
│ └── logging_config.py
├── tests/
│ ├── unit/
│ └── integration/
├── terraform/
├── Dockerfile
└── pyproject.toml

Setup do ambiente

# Criar virtualenv
python3 -m venv .venv
source .venv/bin/activate

# Instalar dependências
pip install -e ".[dev]"

Rodar os testes

# Todos os testes
pytest -v

# Testes de uma pasta específica
pytest tests/unit/ -v

# Teste específico
pytest tests/unit/test_models.py -v

Rodar localmente (sem Docker)

export GITLAB_URL=https://gitlab.com/api/v4
export GITLAB_TOKEN=glpat-xxxx
export GITLAB_WEBHOOK_SECRET=meu-segredo
export NVIDIA_API_KEY=nvapi-xxxx

cd src
uvicorn app:app --reload --port 8000

Simular um webhook

curl -X POST http://localhost:8000/webhook \
-H "Content-Type: application/json" \
-H "X-Gitlab-Token: meu-segredo" \
-d '{
"object_kind": "merge_request",
"project": {"id": 1},
"object_attributes": {
"iid": 42,
"action": "open",
"target_branch": "main",
"source_branch": "feature",
"title": "feat: add feature",
"description": "Description here",
"diff_refs": {
"base_sha": "abc123",
"start_sha": "def456",
"head_sha": "ghi789"
}
}
}'

Convenções de commit

O projeto segue Conventional Commits:

feat: add NVIDIA NIM LLM client
fix: handle empty diff in parser
docs: update deployment guide

Adicionando um novo adapter

  1. Defina a interface em src/ports/
  2. Implemente em src/adapters/
  3. Escreva testes com mocks em tests/unit/
  4. Wire up no entrypoint apropriado