Skip to content

docs: Add Buy Me a Coffee badge #6

docs: Add Buy Me a Coffee badge

docs: Add Buy Me a Coffee badge #6

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
workflow_dispatch:
jobs:
lint:
name: Code Quality Check
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
run: |
python -m pip install --upgrade pip
pip install flake8 bandit
pip install -r requirements.txt
- name: Lint with flake8
run: |
# Stop 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=120 --statistics --exclude=__pycache__,venv,.git
- name: Security check with Bandit
run: |
bandit -r . -x ./venv,./tests,./.git --skip B101 -ll || true
test:
name: Test Application
runs-on: ubuntu-latest
needs: lint
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-cov
- name: Create test config
run: |
cat > config.py << 'EOF'
# Test configuration
AZURE_OPENAI_ENDPOINT = "https://test.openai.azure.com/"
AZURE_OPENAI_KEY = "test-key"
AZURE_OPENAI_DEPLOYMENT = "test-deployment"
AZURE_OPENAI_API_VERSION = "2024-02-15-preview"
EOF
- name: Verify imports
run: |
python -c "from main import app; print('Flask app imports successfully')"
- name: Run tests
run: |
pytest tests/ -v --tb=short || echo "No tests found, skipping..."
build:
name: Build Validation
runs-on: ubuntu-latest
needs: [lint, 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
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Create config for build test
run: |
cp config.example.py config.py
- name: Validate application structure
run: |
echo "Checking required files..."
test -f main.py && echo "✓ main.py exists"
test -f config.example.py && echo "✓ config.example.py exists"
test -f requirements.txt && echo "✓ requirements.txt exists"
test -f templates/index.html && echo "✓ templates/index.html exists"
test -f README.md && echo "✓ README.md exists"
echo "All required files present!"
- name: Check Flask app starts
run: |
timeout 5 python -c "
import sys
sys.argv = ['main.py']
from main import app
with app.test_client() as client:
response = client.get('/')
assert response.status_code == 200, f'Expected 200, got {response.status_code}'
print('✓ Flask app starts and serves index page')
" || true
dependency-check:
name: Dependency Security Scan
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 pip-audit
run: pip install pip-audit
- name: Run dependency audit
run: |
pip install -r requirements.txt
pip-audit --strict || echo "Some vulnerabilities found, please review"
continue-on-error: true