fact-checker-backend/.gitlab-ci.yml
2024-12-17 18:34:04 +06:00

50 lines
962 B
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
- 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
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 15
# 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