Skip to content

Update ci.yml

Update ci.yml #6

Workflow file for this run

name: CI/CD with Keploy API Testing
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
services:
mongodb:
image: mongo:latest
ports:
- 27017:27017
options: >-
--health-cmd "mongosh --eval 'db.adminCommand({ping: 1})'"
--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: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Wait for MongoDB
run: |
sleep 10
- name: Run unit tests
env:
CI: true
run: |
python -m pytest tests.py -v
- name: Run coverage
env:
CI: true
run: |
coverage run --source=main,db,models -m unittest tests.py
coverage report -m
coverage xml
- name: Start FastAPI server
env:
CI: true
run: |
uvicorn main:app --host 0.0.0.0 --port 8000 &
sleep 10
- name: Test server is running
run: |
curl -f http://localhost:8000/docs || exit 1
- name: Generate OpenAPI Schema
run: |
python generate_openapi.py
- name: Upload OpenAPI Schema
uses: actions/upload-artifact@v4
with:
name: openapi-schema
path: openapi.json
keploy-api-testing:
needs: test
runs-on: ubuntu-latest
services:
mongodb:
image: mongo:latest
ports:
- 27017:27017
options: >-
--health-cmd "mongosh --eval 'db.adminCommand({ping: 1})'"
--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: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Wait for MongoDB
run: |
sleep 10
- name: Start FastAPI server
env:
CI: true
run: |
uvicorn main:app --host 0.0.0.0 --port 8000 &
sleep 10
- name: Download OpenAPI Schema
uses: actions/download-artifact@v4
with:
name: openapi-schema
- name: Install Keploy CLI
run: |
curl --silent -L https://keploy.io/ent/install.sh | bash
- name: Run Keploy Test Suite
env:
CI: true
KEPLOY_API_KEY: ${{ secrets.KEPLOY_API_KEY }}
run: |