Skip to content

feat(ai-service): implement humanitarian verification prompt engine with Sphere criteria and fallback flow #24

feat(ai-service): implement humanitarian verification prompt engine with Sphere criteria and fallback flow

feat(ai-service): implement humanitarian verification prompt engine with Sphere criteria and fallback flow #24

Workflow file for this run

name: AI Service CI
on:
push:
paths:
- 'app/ai-service/**'
branches: [ main, develop ]
pull_request:
paths:
- 'app/ai-service/**'
branches: [ main ]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- name: Install dependencies
working-directory: ./app/ai-service
run: |
python -m pip install --upgrade pip
pip install flake8 black mypy
pip install -r requirements.txt
- name: Lint with flake8
working-directory: ./app/ai-service
run: |
# Stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
- name: Check formatting with black
working-directory: ./app/ai-service
run: |
black --check .
continue-on-error: true
- name: Type checking with mypy
working-directory: ./app/ai-service
run: |
mypy . --ignore-missing-imports
continue-on-error: true
test:
runs-on: ubuntu-latest
needs: lint
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- name: Install dependencies
working-directory: ./app/ai-service
run: |
python -m pip install --upgrade pip
pip install pytest pytest-cov httpx
pip install -r requirements.txt
- name: Run tests with pytest
working-directory: ./app/ai-service
run: |
pytest --cov=. --cov-report=xml || echo "No tests found or tests failed"
continue-on-error: true
- name: Run setup verification
working-directory: ./app/ai-service
run: |
python test_setup.py
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
file: ./app/ai-service/coverage.xml
flags: ai-service
continue-on-error: true
build:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- name: Install dependencies
working-directory: ./app/ai-service
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Verify application can start
working-directory: ./app/ai-service
run: |
python -c "from main import app; print(f'✓ App loaded: {app.title}')"
- name: Create deployment package
run: |
mkdir -p deploy
cp -r app/ai-service/* deploy/
cd deploy
zip -r ../ai-service-deploy.zip .
- name: Upload deployment artifact
uses: actions/upload-artifact@v4
with:
name: ai-service-deploy
path: ai-service-deploy.zip
retention-days: 7
docker-build:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build production image
uses: docker/build-push-action@v5
with:
context: ./app/ai-service
file: ./app/ai-service/Dockerfile.simple
push: false
load: true
tags: soter-ai-service:test
- name: Test Docker container
run: |
docker run -d --name test-container -p 8000:8000 soter-ai-service:test
sleep 10
curl -f http://localhost:8000/health || exit 1
docker stop test-container
docker rm test-container
security-scan:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- name: Install safety and bandit
run: |
python -m pip install --upgrade pip
pip install safety bandit
- name: Check dependencies for vulnerabilities
working-directory: ./app/ai-service
run: |
safety check -r requirements.txt || true
- name: Security lint with bandit
working-directory: ./app/ai-service
run: |
bandit -r . -ll || true