Skip to content

updated model to anthropic #10

updated model to anthropic

updated model to anthropic #10

Workflow file for this run

name: Sukoon API Testing CI/CD
on:
push:
branches: [ langgraph ]
pull_request:
branches: [ langgraph ]
jobs:
test:
runs-on: ubuntu-latest
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
LANGCHAIN_API_KEY: ${{ secrets.LANGCHAIN_API_KEY}}
PORTKEY_API_KEY: ${{ secrets.PORTKEY_API_KEY }}
PORTKEY_VIRTUAL_KEY: ${{ secrets.PORTKEY_VIRTUAL_KEY }}
PORTKEY_VIRTUAL_KEY_A: ${{ secrets.PORTKEY_VIRTUAL_KEY_A }}
steps:
- name: Checkout
uses: actions/[email protected]
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-asyncio httpx fastapi uvicorn
pip install -r requirements.txt
# Create logs directory for test outputs
- name: Create directories
run: |
mkdir -p logs
mkdir -p test_reports
# Run the main sukoon tests
- name: Run Sukoon tests
run: |
pytest tests/test_sukoon.py -v --html=test_reports/sukoon_report.html
# Run the API tests
- name: Run API tests
run: |
pytest tests/test_api.py -v --html=test_reports/api_report.html
# Start the FastAPI server and test live endpoints
- name: Start FastAPI server
run: |
nohup python sukoon_api.py &
sleep 5
- name: Test live endpoints
run: |
curl -f http://0.0.0.0:8001/health || exit 1
curl -f http://0.0.0.0:8001/ || exit 1
# Test query endpoint with actual input
curl -X POST -H "Content-Type: application/json" \
-d '{"input":"Hello"}' \
http://0.0.0.0:8001/query || exit 1
# Upload test reports and logs as artifacts
- name: Upload test artifacts
if: always()
uses: actions/upload-artifact@v3
with:
name: test-reports
path: |
test_reports/
logs/
retention-days: 5
# - name: Create test file
# run: |
# cat > test_api.py << EOL
# import pytest
# from fastapi.testclient import TestClient
# from sukoon_api import app
# client = TestClient(app)
# def test_health_endpoint():
# response = client.get("/health")
# assert response.status_code == 200
# assert response.json() == {"status": "healthy"}
# def test_root_endpoint():
# response = client.get("/")
# assert response.status_code == 200
# assert "message" in response.json()
# def test_query_endpoint():
# test_input = {"input": "Hello"}
# response = client.post("/query", json=test_input)
# assert response.status_code == 200
# assert "output" in response.json()
# assert isinstance(response.json()["output"], str)
# EOL
# - name: Run tests
# run: |
# pytest test_api.py -v
# - name: Start FastAPI server
# run: |
# nohup python sukoon_api.py &
# sleep 5
# - name: Test live endpoints
# run: |
# curl -f http://0.0.0.0:8001/health || exit 1
# curl -f http://0.0.0.0:8001/ || exit 1
# PREVIOUS VERSION
# # .github/workflows/ci-cd.yml
# name: Sukoon CI/CD
# on:
# push:
# branches: [ langgraph ]
# pull_request:
# branches: [ langgraph ]
# permissions:
# contents: read
# jobs:
# test:
# runs-on: ubuntu-latest
# env:
# OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
# LANGCHAIN_API_KEY: ${{ secrets.LANGCHAIN_API_KEY }}
# PORTKEY_API_KEY: ${{ secrets.PORTKEY_API_KEY }}
# PORTKEY_VIRTUAL_KEY: ${{ secrets.PORTKEY_VIRTUAL_KEY }}
# PORTKEY_VIRTUAL_KEY_A: ${{ secrets.PORTKEY_VIRTUAL_KEY_A }}
# steps:
# - uses: actions/checkout@v4
# - name: Set up Python
# uses: actions/setup-python@v4
# with:
# python-version: '3.10'
# - name: Cache pip packages
# uses: actions/cache@v3
# with:
# path: ~/.cache/pip
# key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
# restore-keys: |
# ${{ runner.os }}-pip-
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install -r requirements.txt
# pip install pytest pytest-cov pytest-html flake8
# - name: Lint with flake8
# run: |
# # Stop the build if there are Python syntax errors or undefined names
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# # Exit-zero treats all errors as warnings
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
# - name: Create logs directory
# run: mkdir -p logs
# # - name: Run tests
# # run: |
# # python -m pytest tests/ -v --cov=./ --cov-report=xml --html=test_reports/report.html
# - name: Run API tests
# run: |
# python -m pytest tests/test_api.py -v --cov=./ --cov-report=xml --html=test_reports/report.html
# - name: Upload test reports
# uses: actions/upload-artifact@v3
# with:
# name: test-reports
# path: |
# test_reports/
# logs/
# retention-days: 5
# build:
# needs: test
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - name: Set up Python
# uses: actions/setup-python@v4
# with:
# python-version: '3.10'
# - name: Cache pip packages
# uses: actions/cache@v3
# with:
# path: ~/.cache/pip
# key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
# restore-keys: |
# ${{ runner.os }}-pip-
# - name: Install build tools
# run: |
# python -m pip install --upgrade pip
# pip install build wheel
# - name: Build project
# run: |
# python -m pip install --upgrade pip
# pip install build
# python -m build
# - name: Verify build artifacts
# run: |
# ls -la dist/
# if [ ! -f dist/*.whl ] || [ ! -f dist/*.tar.gz ]; then
# echo "Build artifacts missing"
# exit 1
# fi
# - name: Save build artifacts
# uses: actions/upload-artifact@v3
# with:
# name: build-artifacts
# path: dist/
# retention-days: 5
# deploy-api:
# needs: build
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - name: Download build artifacts
# uses: actions/download-artifact@v3
# with:
# name: build-artifacts
# path: dist/
# # Using v3, merge-multiple is not needed as we're uploading a single artifact
# - name: Set up Python
# uses: actions/setup-python@v4
# with:
# python-version: '3.10'
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install dist/*.whl
# pip install uvicorn fastapi
# - name: Create prompts directory
# run: |
# mkdir -p prompts
# touch prompts/prompts.yaml
# - name: Start API server
# env:
# OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
# LANGCHAIN_API_KEY: ${{ secrets.LANGCHAIN_API_KEY }}
# PORTKEY_API_KEY: ${{ secrets.PORTKEY_API_KEY }}
# PORTKEY_VIRTUAL_KEY: ${{ secrets.PORTKEY_VIRTUAL_KEY }}
# PORTKEY_VIRTUAL_KEY_A: ${{ secrets.PORTKEY_VIRTUAL_KEY_A }}
# run: |
# nohup uvicorn sukoon_api:app --host 127.0.0.1 --port 8001 &
# - name: Health check
# run: |
# echo "Waiting for API server to start..."
# sleep 10 # Give the server time to start
# max_retries=5
# retry_count=0
# until curl -s http://127.0.0.1:8001/ || [ $retry_count -eq $max_retries ]
# do
# echo "API server not responding yet... retrying ($((retry_count+1))/$max_retries)"
# sleep 5
# retry_count=$((retry_count+1))
# done
# if [ $retry_count -eq $max_retries ]; then
# echo "API server failed to start"
# exit 1
# else
# echo "API server is up and running!"
# fi