Initial commit #12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: ReliAPI CI/CD | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| paths: | |
| - 'reliapi/**' | |
| pull_request: | |
| branches: [ main, develop ] | |
| paths: | |
| - 'reliapi/**' | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| services: | |
| redis: | |
| image: redis:7-alpine | |
| ports: | |
| - 6379:6379 | |
| options: >- | |
| --health-cmd "redis-cli ping" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| cd reliapi | |
| pip install --upgrade pip | |
| pip install fastapi uvicorn httpx redis pyyaml pydantic prometheus-client | |
| - name: Lint | |
| run: | | |
| cd reliapi | |
| pip install flake8 | |
| flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics || true | |
| - name: Start ReliAPI | |
| run: | | |
| cd reliapi | |
| PYTHONPATH=$(pwd)/.. RELIAPI_CONFIG=test_config.yaml REDIS_URL=redis://localhost:6379/0 python3 -m uvicorn app.main:app --host 0.0.0.0 --port 8000 & | |
| echo $! > /tmp/reliapi.pid | |
| sleep 5 | |
| env: | |
| OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY || 'test-key' }} | |
| ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY || 'test-key' }} | |
| - name: Health check | |
| run: | | |
| sleep 3 | |
| curl -f http://localhost:8000/healthz || exit 1 | |
| - name: Run HTTP proxy test | |
| run: | | |
| curl -X POST http://localhost:8000/proxy/http \ | |
| -H "Content-Type: application/json" \ | |
| -H "X-API-Key: test-key" \ | |
| -d '{"target":"test_http","method":"GET","path":"/get","query":{"test":"value"}}' \ | |
| | python3 -m json.tool | |
| - name: Check metrics | |
| run: | | |
| curl -s http://localhost:8000/metrics | grep -q "reliapi_" || exit 1 | |
| - name: Cleanup | |
| if: always() | |
| run: | | |
| pkill -f "uvicorn" || true | |
| load-test: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| services: | |
| redis: | |
| image: redis:7-alpine | |
| ports: | |
| - 6379:6379 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| cd reliapi | |
| pip install --upgrade pip | |
| pip install fastapi uvicorn httpx redis pyyaml pydantic prometheus-client | |
| - name: Install k6 | |
| run: | | |
| sudo gpg -k | |
| sudo gpg --no-default-keyring --keyring /usr/share/keyrings/k6-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C5AD17C747E3415A3642D57D77C6C491D6AC1D69 | |
| echo "deb [signed-by=/usr/share/keyrings/k6-archive-keyring.gpg] https://dl.k6.io/deb stable main" | sudo tee /etc/apt/sources.list.d/k6.list | |
| sudo apt-get update | |
| sudo apt-get install k6 | |
| - name: Start ReliAPI | |
| run: | | |
| cd reliapi | |
| PYTHONPATH=$(pwd)/.. RELIAPI_CONFIG=test_config.yaml REDIS_URL=redis://localhost:6379/0 python3 -m uvicorn app.main:app --host 0.0.0.0 --port 8000 & | |
| echo $! > /tmp/reliapi.pid | |
| sleep 5 | |
| - name: Run load tests | |
| run: | | |
| cd reliapi/load_test | |
| k6 run --duration 10s --vus 5 k6_simple_test.js || true | |
| - name: Cleanup | |
| if: always() | |
| run: | | |
| pkill -f "uvicorn" || true | |