Skip to content

Final commit

Final commit #34

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, "3.10", "3.11"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip dependencies
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 flake8 black
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 src --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings
flake8 src --count --exit-zero --max-complexity=10 --max-line-length=88 --statistics
- name: Check code formatting with black
run: |
black --check src/
- name: Test with pytest
run: |
pytest tests/ -v --cov=src --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
web-test:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Start web server
run: |
python -m uvicorn web.app:app --host 127.0.0.1 --port 8000 &
sleep 10
- name: Test web endpoints
run: |
curl -f http://127.0.0.1:8000/health
curl -f http://127.0.0.1:8000/
- name: Test API endpoint
run: |
curl -X POST http://127.0.0.1:8000/api/analyze \
-H "Content-Type: application/json" \
-d '{"pain_point":{"description":"Test pain point","context":{"industry":"technology","company_size":"startup","urgency_level":"medium","budget_range":null},"affected_areas":["customer_service"],"current_impact":{"description":"Test pain point"}}}' \
-f -v
security-scan:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install "bandit<1.8.0" "safety<2.0.0"
pip install -r requirements.txt
- name: Run safety check
run: |
safety check --ignore 70612
continue-on-error: true
- name: Run bandit security check
run: |
bandit -r src/ -f json -o bandit-report.json --skip B101,B601
continue-on-error: true
- name: Upload bandit report
uses: actions/upload-artifact@v4
if: always()
with:
name: bandit-report
path: bandit-report.json
docker-build:
runs-on: ubuntu-latest
needs: [test, web-test]
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build Docker image
run: |
docker build -t filum-pain-point-agent:latest .
- name: Test Docker image
run: |
docker run -d -p 8000:8000 --name test-container filum-pain-point-agent:latest
sleep 20
# Wait for container to be ready
timeout 60s bash -c 'until curl -f http://localhost:8000/health; do sleep 2; done'
docker stop test-container
docker rm test-container
deploy-docs:
runs-on: ubuntu-latest
needs: [test, web-test]
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
force_orphan: true