delete workflow
This commit is contained in:
@@ -1,199 +0,0 @@
|
||||
name: CI/CD Pipeline
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, develop ]
|
||||
pull_request:
|
||||
branches: [ main, develop ]
|
||||
release:
|
||||
types: [ published ]
|
||||
|
||||
env:
|
||||
PYTHON_VERSION: "3.11"
|
||||
POETRY_VERSION: "1.7.1"
|
||||
|
||||
jobs:
|
||||
code-quality:
|
||||
name: Code Quality Checks
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: ${{ env.PYTHON_VERSION }}
|
||||
|
||||
- name: Cache pip dependencies
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pip-
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -e ".[dev]"
|
||||
|
||||
- name: Run Ruff (Linting)
|
||||
run: ruff check src tests --output-format=github
|
||||
|
||||
- name: Run Ruff (Formatting)
|
||||
run: ruff format src tests --check
|
||||
|
||||
- name: Run MyPy (Type Checking)
|
||||
run: mypy src
|
||||
|
||||
- name: Check imports with isort
|
||||
run: ruff check --select I src tests
|
||||
|
||||
security-scan:
|
||||
name: Security Scanning
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: ${{ env.PYTHON_VERSION }}
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -e ".[dev]"
|
||||
pip install safety bandit
|
||||
|
||||
- name: Run Safety (Dependency vulnerability scan)
|
||||
run: safety check --json --output safety-report.json
|
||||
continue-on-error: true
|
||||
|
||||
- name: Run Bandit (Security linting)
|
||||
run: bandit -r src/ -f json -o bandit-report.json
|
||||
continue-on-error: true
|
||||
|
||||
- name: Upload Security Reports
|
||||
uses: actions/upload-artifact@v3
|
||||
if: always()
|
||||
with:
|
||||
name: security-reports
|
||||
path: |
|
||||
safety-report.json
|
||||
bandit-report.json
|
||||
|
||||
test:
|
||||
name: Tests
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ["3.11", "3.12"]
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:15
|
||||
env:
|
||||
POSTGRES_PASSWORD: guardden_test
|
||||
POSTGRES_USER: guardden_test
|
||||
POSTGRES_DB: guardden_test
|
||||
options: >-
|
||||
--health-cmd pg_isready
|
||||
--health-interval 10s
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
ports:
|
||||
- 5432:5432
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
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 }}-${{ matrix.python-version }}-pip-${{ hashFiles('**/pyproject.toml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-${{ matrix.python-version }}-pip-
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -e ".[dev]"
|
||||
|
||||
- name: Set up test environment
|
||||
env:
|
||||
GUARDDEN_DISCORD_TOKEN: "test_token_12345678901234567890123456789012345"
|
||||
GUARDDEN_DATABASE_URL: "postgresql://guardden_test:guardden_test@localhost:5432/guardden_test"
|
||||
GUARDDEN_AI_PROVIDER: "none"
|
||||
GUARDDEN_LOG_LEVEL: "DEBUG"
|
||||
run: |
|
||||
python -c "
|
||||
import os
|
||||
os.environ['GUARDDEN_DISCORD_TOKEN'] = 'test_token_12345678901234567890123456789012345'
|
||||
os.environ['GUARDDEN_DATABASE_URL'] = 'postgresql://guardden_test:guardden_test@localhost:5432/guardden_test'
|
||||
print('Test environment configured')
|
||||
"
|
||||
|
||||
- name: Run tests with coverage
|
||||
env:
|
||||
GUARDDEN_DISCORD_TOKEN: "test_token_12345678901234567890123456789012345"
|
||||
GUARDDEN_DATABASE_URL: "postgresql://guardden_test:guardden_test@localhost:5432/guardden_test"
|
||||
GUARDDEN_AI_PROVIDER: "none"
|
||||
GUARDDEN_LOG_LEVEL: "DEBUG"
|
||||
run: |
|
||||
pytest --cov=src/guardden --cov-report=xml --cov-report=html --cov-report=term-missing
|
||||
|
||||
- name: Upload coverage reports
|
||||
uses: actions/upload-artifact@v3
|
||||
if: matrix.python-version == '3.11'
|
||||
with:
|
||||
name: coverage-reports
|
||||
path: |
|
||||
coverage.xml
|
||||
htmlcov/
|
||||
|
||||
build-docker:
|
||||
name: Build Docker Image
|
||||
runs-on: ubuntu-latest
|
||||
needs: [code-quality, test]
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Build Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: false
|
||||
tags: guardden:${{ github.sha }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
build-args: |
|
||||
INSTALL_AI=false
|
||||
|
||||
- name: Build Docker image with AI
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: false
|
||||
tags: guardden-ai:${{ github.sha }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
build-args: |
|
||||
INSTALL_AI=true
|
||||
|
||||
- name: Test Docker image
|
||||
run: |
|
||||
docker run --rm guardden:${{ github.sha }} python -m guardden --help
|
||||
@@ -1,44 +0,0 @@
|
||||
name: Dependency Updates
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 9 * * 1'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
update-dependencies:
|
||||
name: Update Dependencies
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: "3.11"
|
||||
|
||||
- name: Install pip-tools
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install pip-tools
|
||||
|
||||
- name: Update dependencies
|
||||
run: |
|
||||
pip-compile --upgrade pyproject.toml --output-file requirements.txt
|
||||
pip-compile --upgrade --extra dev pyproject.toml --output-file requirements-dev.txt
|
||||
|
||||
- name: Check for security vulnerabilities
|
||||
run: |
|
||||
pip install safety
|
||||
safety check --file requirements.txt --json --output vulnerability-report.json || true
|
||||
safety check --file requirements-dev.txt --json --output vulnerability-dev-report.json || true
|
||||
|
||||
- name: Upload vulnerability reports
|
||||
uses: actions/upload-artifact@v3
|
||||
if: always()
|
||||
with:
|
||||
name: vulnerability-reports
|
||||
path: |
|
||||
vulnerability-report.json
|
||||
vulnerability-dev-report.json
|
||||
@@ -1,196 +0,0 @@
|
||||
name: NSFW-Only Filtering Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'src/guardden/models/guild.py'
|
||||
- 'src/guardden/cogs/ai_moderation.py'
|
||||
- 'migrations/versions/20260124_add_nsfw_only_filtering.py'
|
||||
- 'tests/test_nsfw_only_filtering.py'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'src/guardden/models/guild.py'
|
||||
- 'src/guardden/cogs/ai_moderation.py'
|
||||
- 'migrations/versions/20260124_add_nsfw_only_filtering.py'
|
||||
- 'tests/test_nsfw_only_filtering.py'
|
||||
|
||||
env:
|
||||
PYTHON_VERSION: "3.11"
|
||||
|
||||
jobs:
|
||||
test-nsfw-only-filtering:
|
||||
name: NSFW-Only Filtering Feature Tests
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:15
|
||||
env:
|
||||
POSTGRES_PASSWORD: guardden_test
|
||||
POSTGRES_USER: guardden_test
|
||||
POSTGRES_DB: guardden_test
|
||||
options: >-
|
||||
--health-cmd pg_isready
|
||||
--health-interval 10s
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
ports:
|
||||
- 5432:5432
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Python ${{ env.PYTHON_VERSION }}
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: ${{ env.PYTHON_VERSION }}
|
||||
|
||||
- name: Cache pip dependencies
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip-nsfw-${{ hashFiles('**/pyproject.toml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pip-nsfw-
|
||||
${{ runner.os }}-pip-
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -e ".[dev,ai]"
|
||||
|
||||
- name: Set up test environment
|
||||
env:
|
||||
GUARDDEN_DISCORD_TOKEN: "test_token_12345678901234567890123456789012345"
|
||||
GUARDDEN_DATABASE_URL: "postgresql://guardden_test:guardden_test@localhost:5432/guardden_test"
|
||||
GUARDDEN_AI_PROVIDER: "none"
|
||||
GUARDDEN_LOG_LEVEL: "DEBUG"
|
||||
run: echo "Test environment configured"
|
||||
|
||||
- name: Run database migration test
|
||||
env:
|
||||
GUARDDEN_DISCORD_TOKEN: "test_token_12345678901234567890123456789012345"
|
||||
GUARDDEN_DATABASE_URL: "postgresql://guardden_test:guardden_test@localhost:5432/guardden_test"
|
||||
GUARDDEN_AI_PROVIDER: "none"
|
||||
run: |
|
||||
echo "Testing database migration for nsfw_only_filtering field..."
|
||||
python -c "
|
||||
import asyncio
|
||||
import sys
|
||||
sys.path.insert(0, 'src')
|
||||
|
||||
from guardden.models.guild import GuildSettings
|
||||
from guardden.services.database import Database
|
||||
|
||||
async def test_migration():
|
||||
db = Database('postgresql://guardden_test:guardden_test@localhost:5432/guardden_test')
|
||||
try:
|
||||
async with db.engine.begin() as conn:
|
||||
await conn.run_sync(db.Base.metadata.create_all)
|
||||
print('✅ Database schema created successfully')
|
||||
|
||||
# Test that the field exists in the model
|
||||
if hasattr(GuildSettings, 'nsfw_only_filtering'):
|
||||
print('✅ nsfw_only_filtering field exists in GuildSettings model')
|
||||
else:
|
||||
print('❌ nsfw_only_filtering field missing from GuildSettings model')
|
||||
sys.exit(1)
|
||||
|
||||
except Exception as e:
|
||||
print(f'❌ Database migration test failed: {e}')
|
||||
sys.exit(1)
|
||||
finally:
|
||||
await db.close()
|
||||
|
||||
asyncio.run(test_migration())
|
||||
"
|
||||
|
||||
- name: Run NSFW-only filtering logic tests
|
||||
env:
|
||||
GUARDDEN_DISCORD_TOKEN: "test_token_12345678901234567890123456789012345"
|
||||
GUARDDEN_DATABASE_URL: "postgresql://guardden_test:guardden_test@localhost:5432/guardden_test"
|
||||
GUARDDEN_AI_PROVIDER: "none"
|
||||
GUARDDEN_LOG_LEVEL: "DEBUG"
|
||||
run: |
|
||||
echo "Running NSFW-only filtering specific tests..."
|
||||
pytest tests/test_nsfw_only_filtering.py -v --tb=short
|
||||
|
||||
- name: Run AI moderation integration tests
|
||||
env:
|
||||
GUARDDEN_DISCORD_TOKEN: "test_token_12345678901234567890123456789012345"
|
||||
GUARDDEN_DATABASE_URL: "postgresql://guardden_test:guardden_test@localhost:5432/guardden_test"
|
||||
GUARDDEN_AI_PROVIDER: "none"
|
||||
GUARDDEN_LOG_LEVEL: "DEBUG"
|
||||
run: |
|
||||
echo "Running AI moderation tests to ensure no regression..."
|
||||
pytest tests/test_ai.py -v --tb=short
|
||||
|
||||
- name: Test command functionality
|
||||
env:
|
||||
GUARDDEN_DISCORD_TOKEN: "test_token_12345678901234567890123456789012345"
|
||||
GUARDDEN_DATABASE_URL: "postgresql://guardden_test:guardden_test@localhost:5432/guardden_test"
|
||||
GUARDDEN_AI_PROVIDER: "none"
|
||||
run: |
|
||||
echo "Testing Discord command integration..."
|
||||
python -c "
|
||||
import sys
|
||||
sys.path.insert(0, 'src')
|
||||
|
||||
from guardden.cogs.ai_moderation import AIModeration
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
# Test that the new command exists
|
||||
bot = MagicMock()
|
||||
cog = AIModeration(bot)
|
||||
|
||||
if hasattr(cog, 'ai_nsfw_only'):
|
||||
print('✅ ai_nsfw_only command exists')
|
||||
else:
|
||||
print('❌ ai_nsfw_only command missing')
|
||||
sys.exit(1)
|
||||
|
||||
print('✅ All command tests passed')
|
||||
"
|
||||
|
||||
- name: Validate feature completeness
|
||||
run: |
|
||||
echo "Validating NSFW-only filtering feature completeness..."
|
||||
|
||||
echo "✅ Checking model updates..."
|
||||
grep -q "nsfw_only_filtering" src/guardden/models/guild.py || (echo "❌ Model not updated" && exit 1)
|
||||
|
||||
echo "✅ Checking migration exists..."
|
||||
test -f migrations/versions/20260124_add_nsfw_only_filtering.py || (echo "❌ Migration missing" && exit 1)
|
||||
|
||||
echo "✅ Checking AI moderation logic..."
|
||||
grep -q "nsfw_only_filtering" src/guardden/cogs/ai_moderation.py || (echo "❌ AI moderation not updated" && exit 1)
|
||||
|
||||
echo "✅ Checking new command exists..."
|
||||
grep -q "ai_nsfw_only" src/guardden/cogs/ai_moderation.py || (echo "❌ New command missing" && exit 1)
|
||||
|
||||
echo "✅ Checking documentation updates..."
|
||||
grep -q "nsfwonly" README.md || (echo "❌ Documentation not updated" && exit 1)
|
||||
|
||||
echo "✅ Checking tests exist..."
|
||||
test -f tests/test_nsfw_only_filtering.py || (echo "❌ Tests missing" && exit 1)
|
||||
|
||||
echo "🎉 All NSFW-only filtering feature checks passed!"
|
||||
|
||||
- name: Generate test coverage for new feature
|
||||
env:
|
||||
GUARDDEN_DISCORD_TOKEN: "test_token_12345678901234567890123456789012345"
|
||||
GUARDDEN_DATABASE_URL: "postgresql://guardden_test:guardden_test@localhost:5432/guardden_test"
|
||||
GUARDDEN_AI_PROVIDER: "none"
|
||||
run: |
|
||||
echo "Generating coverage report for NSFW-only filtering feature..."
|
||||
pytest tests/test_nsfw_only_filtering.py --cov=src/guardden/cogs/ai_moderation --cov=src/guardden/models/guild --cov-report=term-missing --cov-report=xml:nsfw-coverage.xml
|
||||
|
||||
- name: Upload NSFW-only filtering test results
|
||||
uses: actions/upload-artifact@v3
|
||||
if: always()
|
||||
with:
|
||||
name: nsfw-only-filtering-test-results
|
||||
path: |
|
||||
nsfw-coverage.xml
|
||||
pytest-report.xml
|
||||
Reference in New Issue
Block a user