Migrate project to uv and add Docker CI
All checks were successful
CI / test (push) Successful in 5m48s
CI / test (pull_request) Successful in 48s
CI / docker-build (push) Successful in 3m7s
CI / docker-build (pull_request) Successful in 45s

This commit is contained in:
steve-w
2026-04-06 16:51:36 +00:00
parent 18af835645
commit b2f7d0480a
8 changed files with 516 additions and 40 deletions

View File

@@ -2,21 +2,67 @@
A simple internal API to track shopping list items using SQLite and FastAPI.
## Setup
## Tech Stack
- Python 3.12
- FastAPI
- SQLite
- `uv` for dependency management and local workflows
- Docker for container packaging
- Gitea Actions for CI
## Local Development
### Prerequisites
- `uv` installed: https://docs.astral.sh/uv/
- Python 3.12 available locally
### Install dependencies
```bash
# Install dependencies
pip install -r requirements.txt
uv sync --dev
```
# Run the server
uvicorn main:app --reload
### Run the server
```bash
uv run uvicorn main:app --reload
```
The API will be available at http://localhost:8000.
## Running Tests
```bash
uv run pytest
```
Tests cover:
- Root endpoint
- Product CRUD
- List CRUD
- List items management (add, update, delete, cascade)
## Docker
### Build the image
```bash
docker build -t shopping-list-api:local .
```
### Run the container
```bash
docker run --rm -p 8000:8000 -v "$PWD/data:/app/data" -e DB_PATH=/app/data/shopping.db shopping-list-api:local
```
This stores the SQLite database on the host under `./data/shopping.db`.
## Database
SQLite database file: `shopping.db` (created automatically on first startup).
SQLite database file: `shopping.db` by default (created automatically on first startup).
Schema:
@@ -132,19 +178,16 @@ curl -X DELETE http://localhost:8000/lists/1/items/2
curl -X DELETE http://localhost:8000/lists/1
```
## Running Tests
## CI
```bash
pytest test_main.py
```
The repository includes a Gitea Actions workflow at `.gitea/workflows/ci.yml` that:
Tests cover:
- Root endpoint
- Product CRUD
- List CRUD
- List items management (add, update, delete, cascade)
1. installs Python 3.12 and `uv`
2. syncs locked dependencies
3. runs the test suite
4. builds the Docker image
## Notes
- This is an internal API; security/auth not implemented.
- For production use, add proper error handling, validation, and possibly a connection pool.
- This is an internal API; security/auth is not implemented.
- For production use, consider adding stronger validation, structured logging, and a non-SQLite database if concurrency requirements grow.