Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
168 changes: 168 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
name: CI

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@v4

- 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: Check Python syntax
run: |
python -m py_compile *.py

- name: Run basic functionality test
run: |
python -c "
import sys
sys.path.append('.')

# Test basic imports
try:
from CartoonGenerator import CartoonGenerator
from TextGenerator import TextGenerator
from ImageAnalyzer import ImageAnalyzer
from CodeAssistant import CodeAssistant
print('✓ All modules import successfully')
except Exception as e:
print(f'✗ Import error: {e}')
sys.exit(1)

# Test basic instantiation with dummy API keys
try:
cg = CartoonGenerator(api_key='test-key')
tg = TextGenerator(api_key='test-key')
ia = ImageAnalyzer(api_key='test-key')
ca = CodeAssistant(api_key='test-key')
print('✓ All classes instantiate successfully')
except Exception as e:
print(f'✗ Instantiation error: {e}')
sys.exit(1)
"

- name: Test examples script syntax
run: |
python -m py_compile examples.py

- name: Create test output directory
run: mkdir -p test_output

- name: Basic integration test
run: |
python -c "
import os
import sys
sys.path.append('.')

# Create a simple test to verify the modules work without API calls
from CartoonGenerator import CartoonGenerator
from TextGenerator import TextGenerator
from ImageAnalyzer import ImageAnalyzer
from CodeAssistant import CodeAssistant

try:
# Test with dummy API keys since they're required
cg = CartoonGenerator(api_key='test-key')
tg = TextGenerator(api_key='test-key')
ia = ImageAnalyzer(api_key='test-key')
ca = CodeAssistant(api_key='test-key')

# Test basic properties/methods that don't require API calls
assert hasattr(cg, 'supported_formats')
assert hasattr(cg, 'style_presets')
print('✓ All classes instantiate and have expected attributes')
except Exception as e:
print(f'✗ Integration test failed: {e}')
sys.exit(1)
"

build:
runs-on: ubuntu-latest
needs: test

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine

- name: Build package
run: |
# Create a basic setup.py for building if it doesn't exist
if [ ! -f setup.py ]; then
cat > setup.py << 'EOF'
from setuptools import setup, find_packages

with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()

with open("requirements.txt", "r", encoding="utf-8") as fh:
requirements = [line.strip() for line in fh if line.strip() and not line.startswith("#")]

setup(
name="ai-driven-python-code",
version="0.1.0",
author="GizzZmo",
description="AI-powered Python tools for cartoon generation, text processing, image analysis, and code assistance",
long_description=long_description,
long_description_content_type="text/markdown",
url="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/GizzZmo/AI-driven-Python-code",
py_modules=["CartoonGenerator", "TextGenerator", "ImageAnalyzer", "CodeAssistant", "examples"],
classifiers=[
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
],
python_requires=">=3.8",
install_requires=requirements,
)
EOF
fi

Comment thread
GizzZmo marked this conversation as resolved.
python -m build

- name: Check build artifacts
run: |
ls -la dist/
python -m twine check dist/*
99 changes: 99 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Code Quality

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]

jobs:
code-quality:
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 dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-quality-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-quality-
${{ runner.os }}-pip-

- name: Install quality tools
run: |
python -m pip install --upgrade pip
pip install flake8 black isort pylint bandit mypy
pip install -r requirements.txt
Comment thread
GizzZmo marked this conversation as resolved.

- name: Run Black formatter check
run: |
black --check --diff *.py

- name: Run isort import sorting check
run: |
isort --check-only --diff *.py

- name: Run Flake8 linting
run: |
# E501: line too long (let black handle this)
# W503: line break before binary operator (black style)
flake8 *.py --max-line-length=88 --extend-ignore=E501,W503

- name: Run Pylint
run: |
pylint *.py --disable=C0301,C0103,R0903,R0913,W0613,C0411 --fail-under=7.0
continue-on-error: true

- name: Run Bandit security linting
run: |
bandit -r *.py -f json -o bandit-report.json
continue-on-error: true

- name: Run MyPy type checking
run: |
mypy *.py --ignore-missing-imports --no-strict-optional
continue-on-error: true

- name: Upload Bandit report
uses: actions/upload-artifact@v3
if: always()
with:
name: bandit-security-report
path: bandit-report.json
retention-days: 30

documentation:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install documentation tools
run: |
python -m pip install --upgrade pip
pip install pydocstyle

- name: Check docstring style
run: |
pydocstyle *.py --convention=google
continue-on-error: true

- name: Check README links
run: |
# Basic check for README structure
grep -q "## Installation" README.md && echo "✓ Installation section found" || echo "✗ Installation section missing"
grep -q "## Usage" README.md && echo "✓ Usage section found" || echo "✗ Usage section missing"
grep -q "## Features" README.md && echo "✓ Features section found" || echo "✗ Features section missing"
82 changes: 82 additions & 0 deletions .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Dependency Updates

on:
schedule:
# Run monthly on the 1st at 3 AM UTC
- cron: '0 3 1 * *'
workflow_dispatch:

jobs:
update-dependencies:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install pip-tools
run: |
python -m pip install --upgrade pip
pip install pip-tools

- name: Backup current requirements
run: |
cp requirements.txt requirements.txt.backup

- name: Check for updates
run: |
# Create requirements.in from requirements.txt if it doesn't exist
if [ ! -f requirements.in ]; then
# Convert pinned versions to flexible ones
sed 's/==/>=/' requirements.txt > requirements.in
fi

# Compile new requirements
pip-compile --upgrade requirements.in

- name: Test updated dependencies
run: |
pip install -r requirements.txt
python -m py_compile *.py

- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'chore: update dependencies'
title: 'Automated dependency update'
body: |
## Dependency Update

This PR contains automated dependency updates.

### Changes
- Updated packages to their latest compatible versions
- Verified Python files still compile with new dependencies

### Testing
- [x] Python syntax check passed
- [x] Dependencies install successfully

Please review the changes and test thoroughly before merging.
branch: automated-dependency-update
delete-branch: true

dependabot-auto-merge:
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'

steps:
- name: Check if PR is from Dependabot
run: echo "This is a Dependabot PR"

- name: Enable auto-merge for Dependabot PRs
run: |
echo "Auto-merge would be enabled for minor/patch updates"
echo "Major updates require manual review"
Comment thread
GizzZmo marked this conversation as resolved.
Loading
Loading