Lokálne prostredie
Táto stránka vás prevedie nastavením vývojového prostredia pre prácu na GitPulse.
Prerekvizity
Povinné
Odporúčané
| Nástroj | Účel |
| VS Code | IDE s Python extension |
| uv | Rýchly package manager |
| pre-commit | Git hooks |
Inštalácia
1. Klonovanie repozitára
| Bash |
|---|
| git clone https://git.kpi.fei.tuke.sk/kpi-zp/2027/dp.mykyta.olym/workspace/workspace.git gitpulse
cd gitpulse
|
2. Python environment
3. Inštalácia závislostí
| Bash |
|---|
| # Produkčné závislosti
pip install -e .
# Vývojové závislosti (testy, linting)
pip install -e ".[dev]"
# Dokumentácia
pip install -e ".[docs]"
# Všetko
pip install -e ".[dev,docs,security]"
|
4. Spustenie služieb
| Bash |
|---|
| # Spustenie PostgreSQL a Redis
docker compose up -d postgres redis
# Overenie
docker compose ps
|
5. Konfigurácia
Vytvorte súbor .env v root adresári:
| Bash |
|---|
| # .env
DATABASE_URL=postgresql+asyncpg://gitpulse:gitpulse@localhost:5432/gitpulse
REDIS_URL=redis://localhost:6379/0
SECRET_KEY=development-secret-key-change-in-production
GITLAB_URL=https://gitlab.kpi.tuke.sk
GITLAB_TOKEN=glpat-your-token-here
# Feature flags
FEATURE_RBAC=true
FEATURE_GAMING_DETECTION=true
FEATURE_PILOT_TELEMETRY=true
|
6. Databáza
| Bash |
|---|
| # Spustenie migrácií
alembic upgrade head
# Overenie
docker compose exec postgres psql -U gitpulse -c "\dt"
|
7. Spustenie aplikácie
Overenie inštalácie
| Bash |
|---|
| # API health check
curl http://localhost:8000/health
# Swagger UI
open http://localhost:8000/docs
# Dashboard
open http://localhost:8000/dashboard
|
VS Code setup
Odporúčané extensions
| JSON |
|---|
| // .vscode/extensions.json
{
"recommendations": [
"ms-python.python",
"ms-python.vscode-pylance",
"charliermarsh.ruff",
"tamasfe.even-better-toml",
"ms-azuretools.vscode-docker",
"redhat.vscode-yaml"
]
}
|
Workspace settings
| JSON |
|---|
| // .vscode/settings.json
{
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",
"python.analysis.typeCheckingMode": "basic",
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports": "explicit"
}
},
"ruff.lint.args": ["--config=pyproject.toml"]
}
|
Pre-commit hooks
| Bash |
|---|
| # Inštalácia
pip install pre-commit
pre-commit install
pre-commit install --hook-type pre-push # pre-push unit testy
# Manuálne spustenie
pre-commit run --all-files
|
| YAML |
|---|
| # .pre-commit-config.yaml
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-yaml
- id: check-toml
- id: check-merge-conflict
- id: detect-private-key
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-added-large-files
args: ['--maxkb=500']
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v3.4.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
args: [feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert]
- repo: local
hooks:
- id: pre-push-tests
name: Run unit tests before push
language: system
entry: python -m pytest tests/unit/ -x -q --no-header --tb=short
pass_filenames: false
stages: [pre-push]
always_run: true
|
Troubleshooting
Port already in use
| Bash |
|---|
| # Nájdenie procesu
lsof -i :8000
netstat -ano | findstr :8000 # Windows
# Ukončenie procesu
kill -9 <PID>
|
Database connection failed
| Bash |
|---|
| # Overenie, že PostgreSQL beží
docker compose ps postgres
# Reštart
docker compose restart postgres
# Log
docker compose logs postgres
|
Import errors
| Bash |
|---|
| # Reinstall v editable mode
pip install -e ".[dev]"
# Overenie PYTHONPATH
echo $PYTHONPATH
export PYTHONPATH=$PWD/src
|
Ďalšie čítanie