Skip to content

feat: Add inline mode support for YouTube Music downloads #145

feat: Add inline mode support for YouTube Music downloads

feat: Add inline mode support for YouTube Music downloads #145

Workflow file for this run

name: Continuous Integration
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
workflow_dispatch:
env:
PYTHON_VERSION: '3.10'
jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:14
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: test_db
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis:6
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
strategy:
fail-fast: false
matrix:
python-version: ["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: 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: |
sudo apt-get update
sudo apt-get install -y postgresql-client
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Wait for PostgreSQL
run: |
until pg_isready -h localhost -p 5432 -U postgres; do
echo "Waiting for PostgreSQL to be ready..."
sleep 2
done
- name: Debug Database Configuration
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/test_db
DB_HOST: localhost
DB_PORT: "5432"
DB_NAME: test_db
DB_USER: postgres
DB_PASSWORD: postgres
run: |
echo "DATABASE_URL: $DATABASE_URL"
echo "DB_HOST: $DB_HOST"
echo "DB_USER: $DB_USER"
echo "DB_NAME: $DB_NAME"
python -c "
import os
from urllib.parse import urlparse
db_url = os.getenv('DATABASE_URL')
print(f'DATABASE_URL from env: {db_url}')
if db_url and db_url.startswith('postgresql://'):
parsed = urlparse(db_url)
print(f'Parsed - Host: {parsed.hostname}, User: {parsed.username}, DB: {parsed.path.lstrip(\"/\")}')
else:
print('Using individual env vars')
print(f'DB_HOST: {os.getenv(\"DB_HOST\")}')
print(f'DB_USER: {os.getenv(\"DB_USER\")}')
print(f'DB_PASSWORD: {\"***\" if os.getenv(\"DB_PASSWORD\") else \"None\"}')
"
- name: Initialize Database
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/test_db
DB_HOST: localhost
DB_PORT: "5432"
DB_NAME: test_db
DB_USER: postgres
DB_PASSWORD: postgres
run: |
python scripts/init_database.py
- name: Run type checking with mypy
run: |
python -m mypy modules/ config/ --ignore-missing-imports
- name: Lint with flake8
run: |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
env:
USE_EMPTY_PROMPTS: "true"
TELEGRAM_BOT_TOKEN: test_token
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/test_db
REDIS_URL: redis://localhost:6379
OPENAI_API_KEY: test_key
OPENWEATHER_API_KEY: test_key
# Override .env file database settings
DB_HOST: localhost
DB_PORT: "5432"
DB_NAME: test_db
DB_USER: postgres
DB_PASSWORD: postgres
run: |
pytest -c pytest-ci.ini --ignore=tests/test_service.py --ignore=tests/test_suite_optimizer -v --cov=modules --cov=config --cov-report=xml --cov-report=html --cov-fail-under=5
- name: Show gpt.py lines 80-100
run: sed -n '80,100p' modules/gpt.py
- name: Remove old venv
run: rm -rf .venv
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
path: |
htmlcov/
bandit-report.json
safety-report.json
coverage.xml
overwrite: true
security-scan:
runs-on: ubuntu-latest
needs: test
permissions:
actions: read
contents: read
security-events: write
steps:
- uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
format: 'sarif'
output: 'trivy-results.sarif'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: 'trivy-results.sarif'