Skip to content

Full Tests (Manual)

Full Tests (Manual) #5

Workflow file for this run

name: Full Tests (Manual)
on:
workflow_dispatch:
schedule:
# Run full tests daily at 2 AM UTC
- cron: '0 2 * * *'
jobs:
full-test:
runs-on: ubuntu-latest
timeout-minutes: 45
strategy:
matrix:
python-version: [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-full-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install system dependencies with retry
run: |
for i in {1..3}; do
sudo apt-get update -qq && \
sudo apt-get install -y --no-install-recommends ffmpeg && \
break || sleep 30
done
ffmpeg -version
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-cov pytest-asyncio pytest-timeout
- name: Create test environment file
run: |
cat > .env << EOF
BOT_TOKEN=test_token_${{ github.run_id }}
RAPIDAPI_KEY=test_key_${{ github.run_id }}
WEBHOOK_PATH=/webhook
WEBHOOK_URL=http://localhost:8000
BOT_USERNAME=test_bot
MONGODB_URI=mongodb://localhost:27017/test_${{ github.run_id }}
MONGODB_DB_NAME=test_db_${{ github.run_id }}
MONGODB_USERS_COLLECTION=users
MONGODB_COUPONS_COLLECTION=coupons
ADMIN_IDS=123456789
STRIPE_PUBLISHABLE_KEY=pk_test_key
STRIPE_SECRET_KEY=sk_test_key
STRIPE_WEBHOOK_SECRET=whsec_test
STRIPE_SUCCESS_URL=http://localhost:8000/success
STRIPE_CANCEL_URL=http://localhost:8000/cancel
EOF
- name: Run all tests with coverage
timeout-minutes: 30
run: |
python -m pytest tests/ -v \
--tb=short \
--maxfail=10 \
--timeout=300 \
--cov=utils \
--cov=handlers \
--cov-report=xml \
--cov-report=html
- name: Upload coverage to Codecov
if: success()
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: full-tests
name: codecov-full-${{ matrix.python-version }}
fail_ci_if_error: false
- name: Upload coverage HTML report
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-report-${{ matrix.python-version }}
path: htmlcov/
- name: Test summary
if: always()
run: |
echo "## Test Results for Python ${{ matrix.python-version }}" >> $GITHUB_STEP_SUMMARY
if [ -f coverage.xml ]; then
echo "✅ Tests completed with coverage report" >> $GITHUB_STEP_SUMMARY
else
echo "❌ Tests failed or coverage not generated" >> $GITHUB_STEP_SUMMARY
fi