Projekt för CI/CD kurs
| .github/workflows | ||
| static | ||
| templates | ||
| tests | ||
| __init__.py | ||
| .dockerignore | ||
| .gitignore | ||
| app.py | ||
| db.py | ||
| Dockerfile | ||
| LICENSE | ||
| pytest.ini | ||
| README.md | ||
| requirements-dev.txt | ||
| requirements.txt | ||
| todo.db | ||
TODO – Flask + SQLite
Ett enkelt TODO-system byggt med Python, Flask och SQLite.
Projektet är uppsatt med app factory-pattern, pytest-tester och är redo att köras i GitHub Actions CI.
✨ Funktioner
- Skapa TODO-poster (title, description, status)
- Uppdatera status (
not-started,in-progress,done) - Ta bort TODO-poster
- SQLite som databas
- Tester med pytest
- CI-redo (GitHub Actions)
🗂 Projektstruktur
.
├── app.py # Flask app (app factory)
├── db.py # Databasfunktioner (SQLite)
├── todo.db # SQLite-databas (lokalt)
├── requirements.txt # Runtime dependencies
├── requirements-dev.txt # Dev/test dependencies
├── templates/
│ ├── base.html
│ └── index.html
├── static/
│ └── style.css
├── tests/
│ └── test_app.py
├── .gitignore
└── README.md
🚀 Kom igång lokalt
1. Klona repot
git clone <repo-url>
cd todo
2. Skapa och aktivera virtuell miljö
python3 -m venv venv
source venv/bin/activate
3. Installera beroenden
pip install -r requirements.txt
pip install -r requirements-dev.txt
4. Starta applikationen
python app.py
Öppna i webbläsaren:
http://127.0.0.1:5001
🧪 Tester
Kör alla tester lokalt med pytest:
pytest
Med kodtäckning(coverage)
pytest --cov=app --cov-report=term-missing --cov-fail-under=80
🤖 CI – GitHub Actions
Projektet kör automatiskt tester vid varje push och pull request via GitHub Actions.
Exempel på teststeg i CI:
pytest --cov=app --cov-report=term-missing --cov-fail-under=80
🐳 Docker (valfritt)
Detta projekt kan enkelt dockeriseras för lokal utveckling eller deployment.
Exempel (snabbstart):
docker build -t todo-app .
docker run -p 5001:5001 todo-app