59 lines
1.1 KiB
YAML
59 lines
1.1 KiB
YAML
image: python:3.10-slim
|
|
|
|
variables:
|
|
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.pip-cache"
|
|
PYTHONPATH: "$CI_PROJECT_DIR"
|
|
|
|
cache:
|
|
paths:
|
|
- .pip-cache
|
|
- venv/
|
|
|
|
stages:
|
|
- setup
|
|
- lint
|
|
- test
|
|
|
|
before_script:
|
|
- python --version
|
|
- pip install virtualenv
|
|
- virtualenv venv
|
|
- source venv/bin/activate
|
|
|
|
setup:
|
|
stage: setup
|
|
script:
|
|
- pip install --no-cache-dir -r requirements.txt
|
|
artifacts:
|
|
paths:
|
|
- venv/
|
|
expire_in: 1 hour
|
|
|
|
lint:
|
|
stage: lint
|
|
needs:
|
|
- setup
|
|
script:
|
|
- black --check app/ main.py tests/
|
|
- flake8 app/ main.py tests/ --max-line-length=100
|
|
|
|
test:
|
|
stage: test
|
|
needs:
|
|
- setup
|
|
script:
|
|
# Run all tests
|
|
- pytest tests/ -v
|
|
# Start FastAPI server
|
|
- uvicorn main:app --host 0.0.0.0 --port 8000 &
|
|
# Wait for server to start
|
|
- sleep 10
|
|
# Test health endpoint
|
|
- |
|
|
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8000/health)
|
|
if [ "$RESPONSE" = "200" ]; then
|
|
echo "✅ Health check passed"
|
|
else
|
|
echo "❌ Health check failed with status $RESPONSE"
|
|
exit 1
|
|
fi
|