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
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ __pycache__
*.pyc
.git
.env
tests/
Makefile
.pre-commit-config.yaml
requirements-dev.txt
docs/
13 changes: 12 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
python-version: "3.12"
- run: pip install ruff
- run: ruff check app/ scripts/
- run: ruff format --check app/ scripts/

import-check:
runs-on: ubuntu-latest
Expand All @@ -44,6 +45,16 @@ jobs:
- name: Static security analysis
run: pip install bandit && bandit -r app/ -c pyproject.toml

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- run: pip install -r requirements-dev.txt
- run: pytest tests/ -v

docker:
runs-on: ubuntu-latest
steps:
Expand All @@ -58,7 +69,7 @@ jobs:

publish:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: [lint, import-check, security, docker]
needs: [lint, import-check, test, security, docker]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ build/
.venv/
venv/
data/
tests/*.csv
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.6
hooks:
- id: ruff
args: [--fix]
- id: ruff-format
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/).

## [0.13.0] - 2026-02-23

### Added

- **Automated test suite** (#25): 69 pytest tests covering `postal_patterns.py` (preprocessing, tercet_map, extraction), `data_loader.py` (normalize functions, all 5 lookup tiers), and FastAPI endpoints (`/lookup`, `/pattern`, `/health`). CI now runs tests before publish.
- **Makefile** (#24): standard targets for `lint`, `format`, `test`, `run`, `docker-build`, `docker-run`.
- **Pre-commit hooks** (#24): ruff lint + format via `.pre-commit-config.yaml`.
- **`requirements-dev.txt`** (#22): dev/test dependencies (ruff, bandit, pip-audit, pytest).
- **`ruff format` CI check** (#24): enforces consistent code formatting in CI.

### Changed

- **Centralized duplicated logic** (#22): `normalize_country()` replaces duplicate GR→EL blocks, `_db_connection()` context manager replaces 6 manual SQLite connect/close patterns, `_build_result()` helper replaces repetitive result dict construction across all lookup tiers.
- **Narrowed exception handling** (#23): 9 bare `except Exception` blocks in `data_loader.py` replaced with specific types (`sqlite3.Error`, `httpx.RequestError`, `OSError`, etc.). Silent catch in `import_estimates.py` now logs a message.
- **Return type hints** added to `dispatch()` and `_rate_limit_handler()` in `main.py`.

## [0.12.0] - 2026-02-23

### Fixed
Expand Down
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.PHONY: lint format test run docker-build docker-run

lint:
ruff check app/ scripts/

format:
ruff format app/ scripts/

test:
pytest tests/ -v

run:
uvicorn app.main:app --reload --port 8000

docker-build:
docker build -t postalcode2nuts .

docker-run:
docker run -p 8000:8000 postalcode2nuts
2 changes: 1 addition & 1 deletion app/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.12.0"
__version__ = "0.13.0"
Loading
Loading