KI-Chat-Bot-Eugen/.github/workflows/python-package.yml
Workflow config file is invalid. Please check your config file: yaml: unmarshal errors: line 170: mapping key "name" already defined at line 1 line 172: mapping key "on" already defined at line 3 line 178: mapping key "jobs" already defined at line 9

206 lines
5.8 KiB
YAML

name: Python Package CI
on:
push:
branches: [ main, master, develop, claude/** ]
pull_request:
branches: [ main, master, develop ]
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Lint with flake8
run: |
pip install flake8
# 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
continue-on-error: true
- name: Check code formatting with black
run: |
pip install black
black --check --diff .
continue-on-error: true
- name: Type checking with mypy
run: |
pip install mypy
mypy --install-types --non-interactive --ignore-missing-imports *.py
continue-on-error: true
- name: Compile all Python files
run: |
python -m compileall -q .
- name: Run basic import tests
run: |
python -c "import config; print('config.py OK')"
python -c "import utils; print('utils.py OK')"
python -c "import memory; print('memory.py OK')"
python -c "import ai_provider; print('ai_provider.py OK')"
python -c "import gui; print('gui.py OK')"
- name: Test configuration loading
run: |
python -c "from config import Config; c = Config(); print('Config loads successfully')"
env:
TWITCH_OAUTH_TOKEN: oauth:test_token
TWITCH_CHANNEL: '#test_channel'
TWITCH_BOT_NICKNAME: TestBot
PERPLEXITY_API_KEY: pplx-test_key
- name: Test utility classes
run: |
python -c "
from utils import MentionDetector, Logger
detector = MentionDetector('TestBot')
assert detector.is_mentioned('@TestBot hello')
assert detector.is_mentioned('TestBot: hello')
assert not detector.is_mentioned('hello world')
print('MentionDetector tests passed')
logger = Logger(debug_mode=True)
logger.info('Test message')
print('Logger tests passed')
"
- name: Test memory system
run: |
python -c "
from memory import ConversationMemory
mem = ConversationMemory(data_dir='test_data')
mem.add_message('testuser', 'user', 'Hello')
mem.add_message('testuser', 'assistant', 'Hi there')
history = mem.get_user_history('testuser')
assert len(history) == 2
print('ConversationMemory tests passed')
"
security-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Security scan with bandit
run: |
pip install bandit
bandit -r . -f json -o bandit-report.json
continue-on-error: true
- name: Check for known vulnerabilities
run: |
pip install safety
safety check --json
continue-on-error: true
code-quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pylint radon
- name: Analyze code with pylint
run: |
pylint --exit-zero --output-format=text *.py
continue-on-error: true
- name: Calculate code metrics
run: |
radon cc . -a -nb
radon mi . -nb
continue-on-error: true
build-status:
runs-on: ubuntu-latest
needs: [test, security-scan, code-quality]
if: always()
steps:
- name: Check build status
run: |
echo "Tests: ${{ needs.test.result }}"
echo "Security: ${{ needs.security-scan.result }}"
echo "Quality: ${{ needs.code-quality.result }}"
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python package
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- 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. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest