Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ repos:
types: [python]
pass_filenames: false

- id: mypy
name: mypy type check
entry: uv run mypy src/eventkit
language: system
types: [python]
pass_filenames: false

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
Expand Down
38 changes: 33 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,24 +214,52 @@ settings = Settings(

## Development

**Run tests:**
**Setup:**
```bash
pytest
# Install dependencies
uv sync --all-extras

# Install pre-commit hooks (one-time setup)
uv run pre-commit install
```

**Run unit tests (fast, no Docker):**
```bash
uv run pytest
```

**Run integration tests (requires Docker):**
```bash
# Start Firestore emulator
docker compose up -d

# Run integration tests
export FIRESTORE_EMULATOR_HOST=localhost:8080
uv run pytest -m integration

# Stop emulator
docker compose down
```

**Run all tests:**
```bash
export FIRESTORE_EMULATOR_HOST=localhost:8080
uv run pytest -m ""
```

**Type check:**
```bash
mypy src/eventkit
uv run mypy src/eventkit
```

**Lint:**
```bash
ruff check src/
uv run ruff check src/
```

**Format:**
```bash
ruff format src/
uv run ruff format src/
```

## Roadmap
Expand Down
17 changes: 17 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Docker Compose for local development and testing
# Runs Firestore emulator for integration tests

services:
firestore-emulator:
image: gcr.io/google.com/cloudsdktool/google-cloud-cli:emulators
command: gcloud emulators firestore start --host-port=0.0.0.0:8080
ports:
- "8080:8080"
environment:
- FIRESTORE_PROJECT_ID=test-project
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080"]
interval: 5s
timeout: 5s
retries: 10
start_period: 10s
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ dependencies = [
"uvicorn[standard]>=0.24.0",
"google-cloud-firestore>=2.13.0",
"structlog>=23.2.0",
"tenacity>=8.2.0",
]

[project.optional-dependencies]
Expand Down
14 changes: 7 additions & 7 deletions specs/core-pipeline/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,13 @@ class ErrorStore(Protocol):
Implement EventStore and ErrorStore using Firestore with batch operations and retry logic.

#### Acceptance Criteria
- [ ] FirestoreEventStore implements EventStore Protocol
- [ ] Batch writes (max 500 docs per batch)
- [ ] Document ID: `{stream}/{timestamp}_{uuid}`
- [ ] Retry logic for transient errors
- [ ] FirestoreErrorStore implements ErrorStore Protocol
- [ ] Unit tests with mocked Firestore client
- [ ] Integration tests with Firestore emulator
- [x] FirestoreEventStore implements EventStore Protocol
- [x] Batch writes (max 500 docs per batch)
- [x] Document ID: `{stream}/{timestamp}_{uuid}`
- [x] Retry logic for transient errors
- [x] FirestoreErrorStore implements ErrorStore Protocol
- [x] Unit tests with mocked Firestore client
- [x] Integration tests with Firestore emulator

#### Checklist
```python
Expand Down
1 change: 1 addition & 0 deletions src/eventkit/schema/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class TypedEvent(BaseModel):
timestamp: datetime = Field(default_factory=lambda: datetime.now(UTC))
event_type: str
properties: dict[str, Any] = Field(default_factory=dict)
stream: str | None = None # Stream identifier for routing

# PostHog-style property updates
set: dict[str, Any] | None = Field(default=None, alias="$set")
Expand Down
Loading
Loading